From f8689be4515d5693004da17bb2244a385ac1e794 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 24 Apr 2015 20:07:12 +0200 Subject: [PATCH] fix(all): update all code to latest version * add new APIs * remove old ones * add latest json files --- .../v1.2/adexchangebuyer-api.json | 6 +- .../v1.3/adexchangebuyer-api.json | 6 +- etc/api/admin/directory_v1/admin-api.json | 8 +- etc/api/adsensehost/v4.1/adsensehost-api.json | 4 +- etc/api/analytics/v2.4/analytics-api.json | 4 +- etc/api/analytics/v3/analytics-api.json | 4 +- .../v1.1/androidpublisher-api.json | 4 +- .../v1/androidpublisher-api.json | 4 +- .../v2/androidpublisher-api.json | 4 +- etc/api/api-list.yaml | 4 +- etc/api/appstate/v1/appstate-api.json | 4 +- etc/api/audit/v1/audit-api.json | 4 +- etc/api/bigquery/v2/bigquery-api.json | 24 +- etc/api/blogger/v2/blogger-api.json | 4 +- etc/api/blogger/v3/blogger-api.json | 16 +- etc/api/books/v1/books-api.json | 9 +- etc/api/calendar/v3/calendar-api.json | 4 +- .../v2beta2/cloudmonitoring-api.json | 8 +- etc/api/cloudsearch/v1/cloudsearch-api.json | 587 +- etc/api/compute/v1/compute-api.json | 17 +- etc/api/container/v1beta1/container-api.json | 78 +- etc/api/content/v2/content-api.json | 46 +- etc/api/dataflow/v1beta3/dataflow-api.json | 4 +- etc/api/datastore/v1beta1/datastore-api.json | 8 +- etc/api/datastore/v1beta2/datastore-api.json | 16 +- .../v2beta1/deploymentmanager-api.json | 4 +- etc/api/dns/v1beta1/dns-api.json | 10 +- etc/api/drive/v2/drive-api.json | 56 +- etc/api/fitness/v1/fitness-api.json | 51 +- etc/api/fusiontables/v1/fusiontables-api.json | 4 +- etc/api/fusiontables/v2/fusiontables-api.json | 4 +- etc/api/games/v1/games-api.json | 4 +- .../gamesconfiguration-api.json | 6 +- .../v1management/gamesmanagement-api.json | 4 +- etc/api/genomics/v1beta2/genomics-api.json | 68 +- .../v3/identitytoolkit-api.json | 58 +- etc/api/mapsengine/exp2/mapsengine-api.json | 4 +- etc/api/mapsengine/v1/mapsengine-api.json | 4 +- etc/api/oauth2/v1/oauth2-api.json | 4 +- etc/api/oauth2/v2/oauth2-api.json | 4 +- etc/api/plus/v1/plus-api.json | 4 +- etc/api/plusdomains/v1/plusdomains-api.json | 4 +- etc/api/pubsub/v1beta1/pubsub-api.json | 8 +- .../v1beta1/replicapoolupdater-api.json | 52 +- etc/api/sqladmin/v1beta4/sqladmin-api.json | 38 +- etc/api/storage/v1/storage-api.json | 277 +- etc/api/youtube/v3/youtube-api.json | 871 +- gen/adexchangebuyer1d3-cli/Cargo.toml | 5 +- gen/adexchangebuyer1d3-cli/mkdocs.yml | 2 +- gen/adexchangebuyer1d3-cli/src/cmn.rs | 95 +- gen/adexchangebuyer1d3-cli/src/main.rs | 431 +- gen/adexchangebuyer1d3/Cargo.toml | 4 +- gen/adexchangebuyer1d3/README.md | 4 +- gen/adexchangebuyer1d3/src/cmn.rs | 15 +- gen/adexchangebuyer1d3/src/lib.rs | 612 +- gen/adexchangeseller2-cli/Cargo.toml | 3 +- gen/adexchangeseller2-cli/src/cmn.rs | 95 +- gen/adexchangeseller2-cli/src/main.rs | 114 +- gen/adexchangeseller2/Cargo.toml | 2 +- gen/adexchangeseller2/src/cmn.rs | 15 +- gen/adexchangeseller2/src/lib.rs | 466 +- gen/admin1_directory-cli/Cargo.toml | 30 - gen/admin1_directory-cli/README.md | 4 - gen/admin1_directory-cli/mkdocs.yml | 83 - gen/admin1_directory-cli/src/cmn.rs | 439 - gen/admin1_directory-cli/src/main.rs | 4769 --- gen/admin1_directory/Cargo.toml | 4 +- gen/admin1_directory/README.md | 4 +- gen/admin1_directory/src/cmn.rs | 15 +- gen/admin1_directory/src/lib.rs | 1765 +- gen/admin1_reports-cli/Cargo.toml | 30 - gen/admin1_reports-cli/mkdocs.yml | 21 - gen/admin1_reports-cli/src/main.rs | 535 - gen/admin1_reports/Cargo.toml | 2 +- gen/admin1_reports/README.md | 2 +- gen/admin1_reports/src/cmn.rs | 15 +- gen/admin1_reports/src/lib.rs | 224 +- gen/admin2_email_migration-cli/Cargo.toml | 30 - gen/admin2_email_migration-cli/README.md | 4 - gen/admin2_email_migration-cli/mkdocs.yml | 17 - gen/admin2_email_migration-cli/src/cmn.rs | 439 - gen/admin2_email_migration-cli/src/main.rs | 224 - gen/admin2_email_migration/Cargo.toml | 2 +- gen/admin2_email_migration/README.md | 2 +- gen/admin2_email_migration/src/cmn.rs | 15 +- gen/admin2_email_migration/src/lib.rs | 28 +- gen/adsense1d4-cli/Cargo.toml | 3 +- gen/adsense1d4-cli/src/cmn.rs | 95 +- gen/adsense1d4-cli/src/main.rs | 257 +- gen/adsense1d4/Cargo.toml | 2 +- gen/adsense1d4/src/cmn.rs | 15 +- gen/adsense1d4/src/lib.rs | 1078 +- gen/adsensehost4d1-cli/Cargo.toml | 30 - gen/adsensehost4d1-cli/README.md | 4 - gen/adsensehost4d1-cli/mkdocs.yml | 42 - gen/adsensehost4d1-cli/src/main.rs | 1906 -- gen/adsensehost4d1/Cargo.toml | 4 +- gen/adsensehost4d1/README.md | 2 +- gen/adsensehost4d1/src/cmn.rs | 15 +- gen/adsensehost4d1/src/lib.rs | 728 +- gen/analytics3-cli/Cargo.toml | 5 +- gen/analytics3-cli/mkdocs.yml | 2 +- gen/analytics3-cli/src/cmn.rs | 95 +- gen/analytics3-cli/src/main.rs | 1915 +- gen/analytics3/Cargo.toml | 4 +- gen/analytics3/README.md | 4 +- gen/analytics3/src/cmn.rs | 15 +- gen/analytics3/src/lib.rs | 2596 +- gen/androidenterprise1-cli/Cargo.toml | 3 +- gen/androidenterprise1-cli/src/cmn.rs | 95 +- gen/androidenterprise1-cli/src/main.rs | 390 +- gen/androidenterprise1/Cargo.toml | 2 +- gen/androidenterprise1/README.md | 2 +- gen/androidenterprise1/src/cmn.rs | 15 +- gen/androidenterprise1/src/lib.rs | 1110 +- gen/androidpublisher2-cli/Cargo.toml | 3 +- gen/androidpublisher2-cli/src/cmn.rs | 95 +- gen/androidpublisher2-cli/src/main.rs | 585 +- gen/androidpublisher2/Cargo.toml | 2 +- gen/androidpublisher2/README.md | 2 +- gen/androidpublisher2/src/cmn.rs | 15 +- gen/androidpublisher2/src/lib.rs | 1322 +- gen/appsactivity1-cli/Cargo.toml | 3 +- gen/appsactivity1-cli/src/cmn.rs | 95 +- gen/appsactivity1-cli/src/main.rs | 49 +- gen/appsactivity1/Cargo.toml | 2 +- gen/appsactivity1/src/cmn.rs | 15 +- gen/appsactivity1/src/lib.rs | 90 +- gen/appstate1-cli/Cargo.toml | 5 +- gen/appstate1-cli/mkdocs.yml | 2 +- gen/appstate1-cli/src/cmn.rs | 95 +- gen/appstate1-cli/src/main.rs | 74 +- gen/appstate1/Cargo.toml | 4 +- gen/appstate1/README.md | 4 +- gen/appstate1/src/cmn.rs | 15 +- gen/appstate1/src/lib.rs | 138 +- gen/audit1-cli/Cargo.toml | 30 - gen/audit1-cli/LICENSE.md | 30 - gen/audit1-cli/README.md | 4 - gen/audit1-cli/mkdocs.yml | 17 - gen/audit1-cli/src/cmn.rs | 439 - gen/audit1-cli/src/main.rs | 196 - gen/audit1/Cargo.toml | 4 +- gen/audit1/README.md | 2 +- gen/audit1/src/cmn.rs | 15 +- gen/audit1/src/lib.rs | 46 +- gen/autoscaler1_beta2-cli/Cargo.toml | 3 +- gen/autoscaler1_beta2-cli/src/cmn.rs | 95 +- gen/autoscaler1_beta2-cli/src/main.rs | 215 +- gen/autoscaler1_beta2/Cargo.toml | 2 +- gen/autoscaler1_beta2/src/cmn.rs | 15 +- gen/autoscaler1_beta2/src/lib.rs | 354 +- gen/bigquery2-cli/Cargo.toml | 5 +- gen/bigquery2-cli/src/cmn.rs | 95 +- gen/bigquery2-cli/src/main.rs | 668 +- gen/bigquery2/Cargo.toml | 4 +- gen/bigquery2/README.md | 4 +- gen/bigquery2/src/cmn.rs | 15 +- gen/bigquery2/src/lib.rs | 860 +- gen/blogger3-cli/Cargo.toml | 5 +- gen/blogger3-cli/mkdocs.yml | 2 +- gen/blogger3-cli/src/cmn.rs | 95 +- gen/blogger3-cli/src/main.rs | 452 +- gen/blogger3/Cargo.toml | 4 +- gen/blogger3/README.md | 2 +- gen/blogger3/src/cmn.rs | 15 +- gen/blogger3/src/lib.rs | 968 +- gen/books1-cli/Cargo.toml | 5 +- gen/books1-cli/mkdocs.yml | 2 +- gen/books1-cli/src/cmn.rs | 95 +- gen/books1-cli/src/main.rs | 710 +- gen/books1/Cargo.toml | 4 +- gen/books1/README.md | 2 +- gen/books1/src/cmn.rs | 15 +- gen/books1/src/lib.rs | 1557 +- gen/calendar3-cli/Cargo.toml | 5 +- gen/calendar3-cli/mkdocs.yml | 2 +- gen/calendar3-cli/src/cmn.rs | 95 +- gen/calendar3-cli/src/main.rs | 712 +- gen/calendar3/Cargo.toml | 4 +- gen/calendar3/README.md | 4 +- gen/calendar3/src/cmn.rs | 15 +- gen/calendar3/src/lib.rs | 1042 +- gen/civicinfo2-cli/Cargo.toml | 3 +- gen/civicinfo2-cli/src/cmn.rs | 95 +- gen/civicinfo2-cli/src/main.rs | 75 +- gen/civicinfo2/Cargo.toml | 2 +- gen/civicinfo2/src/cmn.rs | 15 +- gen/civicinfo2/src/lib.rs | 226 +- gen/cloudlatencytest2-cli/Cargo.toml | 3 +- gen/cloudlatencytest2-cli/src/cmn.rs | 95 +- gen/cloudlatencytest2-cli/src/main.rs | 68 +- gen/cloudlatencytest2/Cargo.toml | 2 +- gen/cloudlatencytest2/README.md | 2 +- gen/cloudlatencytest2/src/cmn.rs | 15 +- gen/cloudlatencytest2/src/lib.rs | 68 +- gen/cloudmonitoring2_beta2-cli/Cargo.toml | 5 +- gen/cloudmonitoring2_beta2-cli/mkdocs.yml | 2 +- gen/cloudmonitoring2_beta2-cli/src/cmn.rs | 95 +- gen/cloudmonitoring2_beta2-cli/src/main.rs | 124 +- gen/cloudmonitoring2_beta2/Cargo.toml | 4 +- gen/cloudmonitoring2_beta2/README.md | 4 +- gen/cloudmonitoring2_beta2/src/cmn.rs | 15 +- gen/cloudmonitoring2_beta2/src/lib.rs | 232 +- gen/cloudsearch1-cli/Cargo.toml | 5 +- gen/cloudsearch1-cli/mkdocs.yml | 8 +- gen/cloudsearch1-cli/src/cmn.rs | 95 +- gen/cloudsearch1-cli/src/main.rs | 398 +- gen/cloudsearch1/Cargo.toml | 4 +- gen/cloudsearch1/README.md | 36 +- gen/cloudsearch1/src/cmn.rs | 15 +- gen/cloudsearch1/src/lib.rs | 2231 +- gen/compute1-cli/Cargo.toml | 3 +- gen/compute1-cli/src/cmn.rs | 95 +- gen/compute1-cli/src/main.rs | 1373 +- gen/compute1/Cargo.toml | 2 +- gen/compute1/src/cmn.rs | 15 +- gen/compute1/src/lib.rs | 4327 +-- gen/container1_beta1-cli/Cargo.toml | 5 +- gen/container1_beta1-cli/mkdocs.yml | 3 +- gen/container1_beta1-cli/src/cmn.rs | 95 +- gen/container1_beta1-cli/src/main.rs | 219 +- gen/container1_beta1/Cargo.toml | 4 +- gen/container1_beta1/README.md | 4 +- gen/container1_beta1/src/cmn.rs | 15 +- gen/container1_beta1/src/lib.rs | 562 +- gen/content2-cli/Cargo.toml | 5 +- gen/content2-cli/mkdocs.yml | 2 +- gen/content2-cli/src/cmn.rs | 95 +- gen/content2-cli/src/main.rs | 589 +- gen/content2/Cargo.toml | 4 +- gen/content2/README.md | 4 +- gen/content2/src/cmn.rs | 15 +- gen/content2/src/lib.rs | 1665 +- gen/coordinate1-cli/Cargo.toml | 30 - gen/coordinate1-cli/LICENSE.md | 30 - gen/coordinate1-cli/README.md | 4 - gen/coordinate1-cli/mkdocs.yml | 28 - gen/coordinate1-cli/src/cmn.rs | 439 - gen/coordinate1-cli/src/main.rs | 1110 - gen/coordinate1/Cargo.toml | 2 +- gen/coordinate1/README.md | 2 +- gen/coordinate1/src/cmn.rs | 15 +- gen/coordinate1/src/lib.rs | 392 +- gen/customsearch1-cli/Cargo.toml | 30 - gen/customsearch1-cli/LICENSE.md | 30 - gen/customsearch1-cli/README.md | 4 - gen/customsearch1-cli/mkdocs.yml | 17 - gen/customsearch1-cli/src/cmn.rs | 439 - gen/customsearch1-cli/src/main.rs | 262 - gen/customsearch1/Cargo.toml | 2 +- gen/customsearch1/src/cmn.rs | 15 +- gen/customsearch1/src/lib.rs | 192 +- gen/dataflow1_b4-cli/Cargo.toml | 29 - gen/dataflow1_b4-cli/LICENSE.md | 30 - gen/dataflow1_b4-cli/README.md | 4 - gen/dataflow1_b4-cli/mkdocs.yml | 16 - gen/dataflow1_b4-cli/src/cmn.rs | 439 - gen/dataflow1_b4-cli/src/main.rs | 118 - gen/dataflow1_b4/Cargo.toml | 22 - gen/dataflow1_b4/LICENSE.md | 30 - gen/dataflow1_b4/README.md | 142 - gen/dataflow1_b4/src/lib.rs | 255 - gen/datastore1_beta2-cli/Cargo.toml | 5 +- gen/datastore1_beta2-cli/mkdocs.yml | 2 +- gen/datastore1_beta2-cli/src/cmn.rs | 95 +- gen/datastore1_beta2-cli/src/main.rs | 284 +- gen/datastore1_beta2/Cargo.toml | 4 +- gen/datastore1_beta2/README.md | 4 +- gen/datastore1_beta2/src/cmn.rs | 15 +- gen/datastore1_beta2/src/lib.rs | 346 +- gen/deploymentmanager2_beta1-cli/Cargo.toml | 5 +- gen/deploymentmanager2_beta1-cli/mkdocs.yml | 2 +- gen/deploymentmanager2_beta1-cli/src/cmn.rs | 95 +- gen/deploymentmanager2_beta1-cli/src/main.rs | 118 +- gen/deploymentmanager2_beta1/Cargo.toml | 4 +- gen/deploymentmanager2_beta1/README.md | 2 +- gen/deploymentmanager2_beta1/src/cmn.rs | 15 +- gen/deploymentmanager2_beta1/src/lib.rs | 344 +- gen/dfareporting2-cli/LICENSE.md | 30 - gen/dfareporting2-cli/README.md | 4 - gen/dfareporting2-cli/src/cmn.rs | 439 - gen/dfareporting2/LICENSE.md | 30 - gen/dfareporting2/README.md | 289 - .../Cargo.toml | 17 +- .../LICENSE.md | 0 .../README.md | 2 +- .../mkdocs.yml | 30 +- .../src/cmn.rs | 95 +- .../src/main.rs | 6458 ++-- .../Cargo.toml | 10 +- .../LICENSE.md | 0 gen/dfareporting2d1/README.md | 303 + .../src/cmn.rs | 15 +- .../src/lib.rs | 27201 +++++++++++----- gen/discovery1-cli/Cargo.toml | 3 +- gen/discovery1-cli/src/cmn.rs | 95 +- gen/discovery1-cli/src/main.rs | 54 +- gen/discovery1/Cargo.toml | 2 +- gen/discovery1/src/cmn.rs | 15 +- gen/discovery1/src/lib.rs | 232 +- gen/{dns1_beta1-cli => dns1-cli}/Cargo.toml | 19 +- .../LICENSE.md | 0 gen/{drive2-cli => dns1-cli}/README.md | 2 +- gen/{dns1_beta1-cli => dns1-cli}/mkdocs.yml | 6 +- .../src/cmn.rs | 95 +- gen/{dns1_beta1-cli => dns1-cli}/src/main.rs | 136 +- gen/{dns1_beta1 => dns1}/Cargo.toml | 12 +- gen/{adsensehost4d1-cli => dns1}/LICENSE.md | 0 gen/{dns1_beta1 => dns1}/README.md | 70 +- gen/{dfareporting2 => dns1}/src/cmn.rs | 15 +- gen/{dns1_beta1 => dns1}/src/lib.rs | 342 +- gen/dns1_beta1-cli/LICENSE.md | 30 - gen/dns1_beta1-cli/README.md | 4 - gen/dns1_beta1-cli/src/cmn.rs | 439 - gen/dns1_beta1/LICENSE.md | 30 - gen/dns1_beta1/src/cmn.rs | 643 - gen/doubleclickbidmanager1-cli/Cargo.toml | 3 +- gen/doubleclickbidmanager1-cli/src/cmn.rs | 95 +- gen/doubleclickbidmanager1-cli/src/main.rs | 165 +- gen/doubleclickbidmanager1/Cargo.toml | 2 +- gen/doubleclickbidmanager1/src/cmn.rs | 15 +- gen/doubleclickbidmanager1/src/lib.rs | 102 +- gen/doubleclicksearch2-cli/Cargo.toml | 3 +- gen/doubleclicksearch2-cli/src/cmn.rs | 95 +- gen/doubleclicksearch2-cli/src/main.rs | 184 +- gen/doubleclicksearch2/Cargo.toml | 2 +- gen/doubleclicksearch2/src/cmn.rs | 15 +- gen/doubleclicksearch2/src/lib.rs | 382 +- gen/drive2-cli/Cargo.toml | 30 - gen/drive2-cli/LICENSE.md | 30 - gen/drive2-cli/mkdocs.yml | 75 - gen/drive2-cli/src/cmn.rs | 439 - gen/drive2-cli/src/main.rs | 6319 ---- gen/drive2/Cargo.toml | 2 +- gen/drive2/README.md | 2 +- gen/drive2/src/cmn.rs | 15 +- gen/drive2/src/lib.rs | 1878 +- gen/fitness1-cli/Cargo.toml | 5 +- gen/fitness1-cli/mkdocs.yml | 3 +- gen/fitness1-cli/src/cmn.rs | 95 +- gen/fitness1-cli/src/main.rs | 252 +- gen/fitness1/Cargo.toml | 4 +- gen/fitness1/README.md | 7 +- gen/fitness1/src/cmn.rs | 15 +- gen/fitness1/src/lib.rs | 612 +- gen/freebase1-cli/Cargo.toml | 3 +- gen/freebase1-cli/src/cmn.rs | 95 +- gen/freebase1-cli/src/main.rs | 52 +- gen/freebase1/Cargo.toml | 2 +- gen/freebase1/src/cmn.rs | 15 +- gen/freebase1/src/lib.rs | 32 +- gen/freebase1_sandbox-cli/Cargo.toml | 3 +- gen/freebase1_sandbox-cli/src/cmn.rs | 95 +- gen/freebase1_sandbox-cli/src/main.rs | 52 +- gen/freebase1_sandbox/Cargo.toml | 2 +- gen/freebase1_sandbox/src/cmn.rs | 15 +- gen/freebase1_sandbox/src/lib.rs | 32 +- gen/fusiontables2-cli/Cargo.toml | 5 +- gen/fusiontables2-cli/mkdocs.yml | 2 +- gen/fusiontables2-cli/src/cmn.rs | 95 +- gen/fusiontables2-cli/src/main.rs | 988 +- gen/fusiontables2/Cargo.toml | 4 +- gen/fusiontables2/README.md | 2 +- gen/fusiontables2/src/cmn.rs | 15 +- gen/fusiontables2/src/lib.rs | 874 +- gen/games1-cli/Cargo.toml | 30 - gen/games1-cli/LICENSE.md | 30 - gen/games1-cli/README.md | 4 - gen/games1-cli/mkdocs.yml | 68 - gen/games1-cli/src/cmn.rs | 439 - gen/games1-cli/src/main.rs | 3366 -- gen/games1/Cargo.toml | 4 +- gen/games1/README.md | 2 +- gen/games1/src/cmn.rs | 15 +- gen/games1/src/lib.rs | 1986 +- .../Cargo.toml | 5 +- .../mkdocs.yml | 2 +- .../src/cmn.rs | 95 +- .../src/main.rs | 1059 +- .../Cargo.toml | 4 +- .../README.md | 2 +- .../src/cmn.rs | 15 +- .../src/lib.rs | 374 +- .../Cargo.toml | 5 +- .../mkdocs.yml | 2 +- .../src/cmn.rs | 95 +- .../src/main.rs | 200 +- gen/gamesmanagement1_management/Cargo.toml | 4 +- gen/gamesmanagement1_management/README.md | 2 +- gen/gamesmanagement1_management/src/cmn.rs | 15 +- gen/gamesmanagement1_management/src/lib.rs | 660 +- gen/gan1_beta1-cli/Cargo.toml | 3 +- gen/gan1_beta1-cli/src/cmn.rs | 95 +- gen/gan1_beta1-cli/src/main.rs | 203 +- gen/gan1_beta1/Cargo.toml | 2 +- gen/gan1_beta1/src/cmn.rs | 15 +- gen/gan1_beta1/src/lib.rs | 172 +- gen/genomics1_beta2-cli/Cargo.toml | 3 +- gen/genomics1_beta2-cli/mkdocs.yml | 2 +- gen/genomics1_beta2-cli/src/cmn.rs | 95 +- gen/genomics1_beta2-cli/src/main.rs | 995 +- gen/genomics1_beta2/Cargo.toml | 2 +- gen/genomics1_beta2/README.md | 6 +- gen/genomics1_beta2/src/cmn.rs | 15 +- gen/genomics1_beta2/src/lib.rs | 5248 +-- gen/gmail1-cli/Cargo.toml | 3 +- gen/gmail1-cli/src/cmn.rs | 95 +- gen/gmail1-cli/src/main.rs | 489 +- gen/gmail1/Cargo.toml | 2 +- gen/gmail1/README.md | 2 +- gen/gmail1/src/cmn.rs | 15 +- gen/gmail1/src/lib.rs | 774 +- gen/groupsmigration1-cli/Cargo.toml | 3 +- gen/groupsmigration1-cli/src/cmn.rs | 95 +- gen/groupsmigration1-cli/src/main.rs | 49 +- gen/groupsmigration1/Cargo.toml | 2 +- gen/groupsmigration1/src/cmn.rs | 15 +- gen/groupsmigration1/src/lib.rs | 26 +- gen/groupssettings1-cli/Cargo.toml | 3 +- gen/groupssettings1-cli/src/cmn.rs | 95 +- gen/groupssettings1-cli/src/main.rs | 73 +- gen/groupssettings1/Cargo.toml | 2 +- gen/groupssettings1/README.md | 2 +- gen/groupssettings1/src/cmn.rs | 15 +- gen/groupssettings1/src/lib.rs | 74 +- gen/identitytoolkit3-cli/Cargo.toml | 30 - gen/identitytoolkit3-cli/LICENSE.md | 30 - gen/identitytoolkit3-cli/README.md | 4 - gen/identitytoolkit3-cli/mkdocs.yml | 27 - gen/identitytoolkit3-cli/src/cmn.rs | 439 - gen/identitytoolkit3-cli/src/main.rs | 928 - gen/identitytoolkit3/Cargo.toml | 4 +- gen/identitytoolkit3/README.md | 6 +- gen/identitytoolkit3/src/cmn.rs | 15 +- gen/identitytoolkit3/src/lib.rs | 634 +- gen/licensing1-cli/Cargo.toml | 3 +- gen/licensing1-cli/src/cmn.rs | 95 +- gen/licensing1-cli/src/main.rs | 98 +- gen/licensing1/Cargo.toml | 2 +- gen/licensing1/src/cmn.rs | 15 +- gen/licensing1/src/lib.rs | 168 +- gen/logging1_beta3-cli/Cargo.toml | 29 - gen/logging1_beta3-cli/LICENSE.md | 30 - gen/logging1_beta3-cli/README.md | 4 - gen/logging1_beta3-cli/mkdocs.yml | 31 - gen/logging1_beta3-cli/src/cmn.rs | 439 - gen/logging1_beta3-cli/src/main.rs | 1052 - gen/logging1_beta3/Cargo.toml | 2 +- gen/logging1_beta3/README.md | 2 +- gen/logging1_beta3/src/cmn.rs | 15 +- gen/logging1_beta3/src/lib.rs | 410 +- gen/manager1_beta2-cli/Cargo.toml | 3 +- gen/manager1_beta2-cli/src/cmn.rs | 95 +- gen/manager1_beta2-cli/src/main.rs | 101 +- gen/manager1_beta2/Cargo.toml | 2 +- gen/manager1_beta2/src/cmn.rs | 15 +- gen/manager1_beta2/src/lib.rs | 408 +- gen/mapsengine1-cli/Cargo.toml | 5 +- gen/mapsengine1-cli/mkdocs.yml | 2 +- gen/mapsengine1-cli/src/cmn.rs | 95 +- gen/mapsengine1-cli/src/main.rs | 748 +- gen/mapsengine1/Cargo.toml | 4 +- gen/mapsengine1/README.md | 2 +- gen/mapsengine1/src/cmn.rs | 15 +- gen/mapsengine1/src/lib.rs | 2120 +- gen/mirror1-cli/Cargo.toml | 3 +- gen/mirror1-cli/src/cmn.rs | 95 +- gen/mirror1-cli/src/main.rs | 398 +- gen/mirror1/Cargo.toml | 2 +- gen/mirror1/README.md | 2 +- gen/mirror1/src/cmn.rs | 15 +- gen/mirror1/src/lib.rs | 628 +- gen/oauth2_v2-cli/Cargo.toml | 5 +- gen/oauth2_v2-cli/mkdocs.yml | 2 +- gen/oauth2_v2-cli/src/cmn.rs | 95 +- gen/oauth2_v2-cli/src/main.rs | 67 +- gen/oauth2_v2/Cargo.toml | 4 +- gen/oauth2_v2/README.md | 2 +- gen/oauth2_v2/src/cmn.rs | 15 +- gen/oauth2_v2/src/lib.rs | 100 +- gen/pagespeedonline2-cli/Cargo.toml | 3 +- gen/pagespeedonline2-cli/src/cmn.rs | 95 +- gen/pagespeedonline2-cli/src/main.rs | 49 +- gen/pagespeedonline2/Cargo.toml | 2 +- gen/pagespeedonline2/src/cmn.rs | 15 +- gen/pagespeedonline2/src/lib.rs | 124 +- gen/plus1-cli/Cargo.toml | 5 +- gen/plus1-cli/mkdocs.yml | 2 +- gen/plus1-cli/src/cmn.rs | 95 +- gen/plus1-cli/src/main.rs | 367 +- gen/plus1/Cargo.toml | 4 +- gen/plus1/README.md | 2 +- gen/plus1/src/cmn.rs | 15 +- gen/plus1/src/lib.rs | 794 +- gen/plusdomains1-cli/Cargo.toml | 5 +- gen/plusdomains1-cli/mkdocs.yml | 2 +- gen/plusdomains1-cli/src/cmn.rs | 95 +- gen/plusdomains1-cli/src/main.rs | 459 +- gen/plusdomains1/Cargo.toml | 4 +- gen/plusdomains1/README.md | 2 +- gen/plusdomains1/src/cmn.rs | 15 +- gen/plusdomains1/src/lib.rs | 850 +- gen/prediction1d6-cli/Cargo.toml | 3 +- gen/prediction1d6-cli/src/cmn.rs | 95 +- gen/prediction1d6-cli/src/main.rs | 113 +- gen/prediction1d6/Cargo.toml | 2 +- gen/prediction1d6/README.md | 2 +- gen/prediction1d6/src/cmn.rs | 15 +- gen/prediction1d6/src/lib.rs | 312 +- gen/pubsub1_beta2-cli/Cargo.toml | 3 +- gen/pubsub1_beta2-cli/src/cmn.rs | 95 +- gen/pubsub1_beta2-cli/src/main.rs | 183 +- gen/pubsub1_beta2/Cargo.toml | 2 +- gen/pubsub1_beta2/README.md | 2 +- gen/pubsub1_beta2/src/cmn.rs | 15 +- gen/pubsub1_beta2/src/lib.rs | 356 +- gen/qpxexpress1-cli/Cargo.toml | 3 +- gen/qpxexpress1-cli/src/cmn.rs | 95 +- gen/qpxexpress1-cli/src/main.rs | 101 +- gen/qpxexpress1/Cargo.toml | 2 +- gen/qpxexpress1/README.md | 2 +- gen/qpxexpress1/src/cmn.rs | 15 +- gen/qpxexpress1/src/lib.rs | 274 +- gen/replicapool1_beta2-cli/Cargo.toml | 3 +- gen/replicapool1_beta2-cli/src/cmn.rs | 95 +- gen/replicapool1_beta2-cli/src/main.rs | 169 +- gen/replicapool1_beta2/Cargo.toml | 2 +- gen/replicapool1_beta2/src/cmn.rs | 15 +- gen/replicapool1_beta2/src/lib.rs | 358 +- gen/replicapoolupdater1_beta1-cli/Cargo.toml | 5 +- gen/replicapoolupdater1_beta1-cli/mkdocs.yml | 2 +- gen/replicapoolupdater1_beta1-cli/src/cmn.rs | 95 +- gen/replicapoolupdater1_beta1-cli/src/main.rs | 125 +- gen/replicapoolupdater1_beta1/Cargo.toml | 4 +- gen/replicapoolupdater1_beta1/README.md | 2 +- gen/replicapoolupdater1_beta1/src/cmn.rs | 15 +- gen/replicapoolupdater1_beta1/src/lib.rs | 381 +- gen/reseller1_sandbox-cli/Cargo.toml | 30 - gen/reseller1_sandbox-cli/LICENSE.md | 30 - gen/reseller1_sandbox-cli/README.md | 4 - gen/reseller1_sandbox-cli/mkdocs.yml | 30 - gen/reseller1_sandbox-cli/src/cmn.rs | 439 - gen/reseller1_sandbox-cli/src/main.rs | 1265 - gen/reseller1_sandbox/Cargo.toml | 2 +- gen/reseller1_sandbox/src/cmn.rs | 15 +- gen/reseller1_sandbox/src/lib.rs | 366 +- gen/resourceviews1_beta2-cli/Cargo.toml | 3 +- gen/resourceviews1_beta2-cli/src/cmn.rs | 95 +- gen/resourceviews1_beta2-cli/src/main.rs | 142 +- gen/resourceviews1_beta2/Cargo.toml | 2 +- gen/resourceviews1_beta2/README.md | 2 +- gen/resourceviews1_beta2/src/cmn.rs | 15 +- gen/resourceviews1_beta2/src/lib.rs | 356 +- gen/siteverification1-cli/Cargo.toml | 3 +- gen/siteverification1-cli/src/cmn.rs | 95 +- gen/siteverification1-cli/src/main.rs | 133 +- gen/siteverification1/Cargo.toml | 2 +- gen/siteverification1/README.md | 2 +- gen/siteverification1/src/cmn.rs | 15 +- gen/siteverification1/src/lib.rs | 180 +- gen/spectrum1_explorer-cli/Cargo.toml | 3 +- gen/spectrum1_explorer-cli/src/cmn.rs | 95 +- gen/spectrum1_explorer-cli/src/main.rs | 889 +- gen/spectrum1_explorer/Cargo.toml | 2 +- gen/spectrum1_explorer/README.md | 2 +- gen/spectrum1_explorer/src/cmn.rs | 15 +- gen/spectrum1_explorer/src/lib.rs | 216 +- gen/sqladmin1_beta4-cli/Cargo.toml | 3 +- gen/sqladmin1_beta4-cli/src/cmn.rs | 95 +- gen/sqladmin1_beta4-cli/src/main.rs | 933 +- gen/sqladmin1_beta4/Cargo.toml | 2 +- gen/sqladmin1_beta4/README.md | 2 +- gen/sqladmin1_beta4/src/cmn.rs | 15 +- gen/sqladmin1_beta4/src/lib.rs | 1097 +- gen/storage1-cli/Cargo.toml | 3 +- gen/storage1-cli/mkdocs.yml | 1 + gen/storage1-cli/src/cmn.rs | 95 +- gen/storage1-cli/src/main.rs | 738 +- gen/storage1/Cargo.toml | 2 +- gen/storage1/README.md | 42 +- gen/storage1/src/cmn.rs | 15 +- gen/storage1/src/lib.rs | 3122 +- gen/tagmanager1-cli/Cargo.toml | 30 - gen/tagmanager1-cli/LICENSE.md | 30 - gen/tagmanager1-cli/README.md | 4 - gen/tagmanager1-cli/mkdocs.yml | 62 - gen/tagmanager1-cli/src/cmn.rs | 439 - gen/tagmanager1-cli/src/main.rs | 3483 -- gen/tagmanager1/Cargo.toml | 2 +- gen/tagmanager1/README.md | 2 +- gen/tagmanager1/src/cmn.rs | 15 +- gen/tagmanager1/src/lib.rs | 1118 +- gen/taskqueue1_beta2-cli/Cargo.toml | 30 - gen/taskqueue1_beta2-cli/LICENSE.md | 30 - gen/taskqueue1_beta2-cli/README.md | 4 - gen/taskqueue1_beta2-cli/mkdocs.yml | 24 - gen/taskqueue1_beta2-cli/src/cmn.rs | 439 - gen/taskqueue1_beta2-cli/src/main.rs | 628 - gen/taskqueue1_beta2/Cargo.toml | 2 +- gen/taskqueue1_beta2/src/cmn.rs | 15 +- gen/taskqueue1_beta2/src/lib.rs | 214 +- gen/tasks1-cli/Cargo.toml | 3 +- gen/tasks1-cli/src/cmn.rs | 95 +- gen/tasks1-cli/src/main.rs | 153 +- gen/tasks1/Cargo.toml | 2 +- gen/tasks1/src/cmn.rs | 15 +- gen/tasks1/src/lib.rs | 342 +- gen/translate2-cli/Cargo.toml | 3 +- gen/translate2-cli/src/cmn.rs | 95 +- gen/translate2-cli/src/main.rs | 69 +- gen/translate2/Cargo.toml | 2 +- gen/translate2/src/cmn.rs | 15 +- gen/translate2/src/lib.rs | 26 +- gen/urlshortener1-cli/Cargo.toml | 3 +- gen/urlshortener1-cli/src/cmn.rs | 95 +- gen/urlshortener1-cli/src/main.rs | 141 +- gen/urlshortener1/Cargo.toml | 2 +- gen/urlshortener1/src/cmn.rs | 15 +- gen/urlshortener1/src/lib.rs | 104 +- gen/webfonts1-cli/Cargo.toml | 30 - gen/webfonts1-cli/LICENSE.md | 30 - gen/webfonts1-cli/README.md | 4 - gen/webfonts1-cli/mkdocs.yml | 17 - gen/webfonts1-cli/src/cmn.rs | 439 - gen/webfonts1-cli/src/main.rs | 172 - gen/webfonts1/Cargo.toml | 2 +- gen/webfonts1/src/cmn.rs | 15 +- gen/webfonts1/src/lib.rs | 4 +- gen/webmasters3-cli/Cargo.toml | 3 +- gen/webmasters3-cli/src/cmn.rs | 95 +- gen/webmasters3-cli/src/main.rs | 103 +- gen/webmasters3/Cargo.toml | 2 +- gen/webmasters3/src/cmn.rs | 15 +- gen/webmasters3/src/lib.rs | 324 +- gen/youtube3-cli/Cargo.toml | 5 +- gen/youtube3-cli/mkdocs.yml | 13 +- gen/youtube3-cli/src/cmn.rs | 95 +- gen/youtube3-cli/src/main.rs | 5427 ++- gen/youtube3/README.md | 43 +- gen/youtube3/cargo.toml | 4 +- gen/youtube3/src/cmn.rs | 15 +- gen/youtube3/src/lib.rs | 7255 ++++- gen/youtubeanalytics1-cli/Cargo.toml | 3 +- gen/youtubeanalytics1-cli/src/cmn.rs | 95 +- gen/youtubeanalytics1-cli/src/main.rs | 143 +- gen/youtubeanalytics1/Cargo.toml | 2 +- gen/youtubeanalytics1/src/cmn.rs | 15 +- gen/youtubeanalytics1/src/lib.rs | 280 +- src/mako/cli/docs/commands.md.mako | 1 + 650 files changed, 80776 insertions(+), 88805 deletions(-) delete mode 100644 gen/admin1_directory-cli/Cargo.toml delete mode 100644 gen/admin1_directory-cli/README.md delete mode 100644 gen/admin1_directory-cli/mkdocs.yml delete mode 100644 gen/admin1_directory-cli/src/cmn.rs delete mode 100644 gen/admin1_directory-cli/src/main.rs delete mode 100644 gen/admin1_reports-cli/Cargo.toml delete mode 100644 gen/admin1_reports-cli/mkdocs.yml delete mode 100644 gen/admin1_reports-cli/src/main.rs delete mode 100644 gen/admin2_email_migration-cli/Cargo.toml delete mode 100644 gen/admin2_email_migration-cli/README.md delete mode 100644 gen/admin2_email_migration-cli/mkdocs.yml delete mode 100644 gen/admin2_email_migration-cli/src/cmn.rs delete mode 100644 gen/admin2_email_migration-cli/src/main.rs delete mode 100644 gen/adsensehost4d1-cli/Cargo.toml delete mode 100644 gen/adsensehost4d1-cli/README.md delete mode 100644 gen/adsensehost4d1-cli/mkdocs.yml delete mode 100644 gen/adsensehost4d1-cli/src/main.rs delete mode 100644 gen/audit1-cli/Cargo.toml delete mode 100644 gen/audit1-cli/LICENSE.md delete mode 100644 gen/audit1-cli/README.md delete mode 100644 gen/audit1-cli/mkdocs.yml delete mode 100644 gen/audit1-cli/src/cmn.rs delete mode 100644 gen/audit1-cli/src/main.rs delete mode 100644 gen/coordinate1-cli/Cargo.toml delete mode 100644 gen/coordinate1-cli/LICENSE.md delete mode 100644 gen/coordinate1-cli/README.md delete mode 100644 gen/coordinate1-cli/mkdocs.yml delete mode 100644 gen/coordinate1-cli/src/cmn.rs delete mode 100644 gen/coordinate1-cli/src/main.rs delete mode 100644 gen/customsearch1-cli/Cargo.toml delete mode 100644 gen/customsearch1-cli/LICENSE.md delete mode 100644 gen/customsearch1-cli/README.md delete mode 100644 gen/customsearch1-cli/mkdocs.yml delete mode 100644 gen/customsearch1-cli/src/cmn.rs delete mode 100644 gen/customsearch1-cli/src/main.rs delete mode 100644 gen/dataflow1_b4-cli/Cargo.toml delete mode 100644 gen/dataflow1_b4-cli/LICENSE.md delete mode 100644 gen/dataflow1_b4-cli/README.md delete mode 100644 gen/dataflow1_b4-cli/mkdocs.yml delete mode 100644 gen/dataflow1_b4-cli/src/cmn.rs delete mode 100644 gen/dataflow1_b4-cli/src/main.rs delete mode 100644 gen/dataflow1_b4/Cargo.toml delete mode 100644 gen/dataflow1_b4/LICENSE.md delete mode 100644 gen/dataflow1_b4/README.md delete mode 100644 gen/dataflow1_b4/src/lib.rs delete mode 100644 gen/dfareporting2-cli/LICENSE.md delete mode 100644 gen/dfareporting2-cli/README.md delete mode 100644 gen/dfareporting2-cli/src/cmn.rs delete mode 100644 gen/dfareporting2/LICENSE.md delete mode 100644 gen/dfareporting2/README.md rename gen/{dfareporting2-cli => dfareporting2d1-cli}/Cargo.toml (70%) rename gen/{admin1_directory-cli => dfareporting2d1-cli}/LICENSE.md (100%) rename gen/{admin1_reports-cli => dfareporting2d1-cli}/README.md (52%) rename gen/{dfareporting2-cli => dfareporting2d1-cli}/mkdocs.yml (86%) rename gen/{admin1_reports-cli => dfareporting2d1-cli}/src/cmn.rs (84%) rename gen/{dfareporting2-cli => dfareporting2d1-cli}/src/main.rs (75%) rename gen/{dfareporting2 => dfareporting2d1}/Cargo.toml (81%) rename gen/{admin1_reports-cli => dfareporting2d1}/LICENSE.md (100%) create mode 100644 gen/dfareporting2d1/README.md rename gen/{dataflow1_b4 => dfareporting2d1}/src/cmn.rs (97%) rename gen/{dfareporting2 => dfareporting2d1}/src/lib.rs (81%) rename gen/{dns1_beta1-cli => dns1-cli}/Cargo.toml (71%) rename gen/{admin2_email_migration-cli => dns1-cli}/LICENSE.md (100%) rename gen/{drive2-cli => dns1-cli}/README.md (56%) rename gen/{dns1_beta1-cli => dns1-cli}/mkdocs.yml (85%) rename gen/{adsensehost4d1-cli => dns1-cli}/src/cmn.rs (84%) rename gen/{dns1_beta1-cli => dns1-cli}/src/main.rs (82%) rename gen/{dns1_beta1 => dns1}/Cargo.toml (79%) rename gen/{adsensehost4d1-cli => dns1}/LICENSE.md (100%) rename gen/{dns1_beta1 => dns1}/README.md (66%) rename gen/{dfareporting2 => dns1}/src/cmn.rs (97%) rename gen/{dns1_beta1 => dns1}/src/lib.rs (94%) delete mode 100644 gen/dns1_beta1-cli/LICENSE.md delete mode 100644 gen/dns1_beta1-cli/README.md delete mode 100644 gen/dns1_beta1-cli/src/cmn.rs delete mode 100644 gen/dns1_beta1/LICENSE.md delete mode 100644 gen/dns1_beta1/src/cmn.rs delete mode 100644 gen/drive2-cli/Cargo.toml delete mode 100644 gen/drive2-cli/LICENSE.md delete mode 100644 gen/drive2-cli/mkdocs.yml delete mode 100644 gen/drive2-cli/src/cmn.rs delete mode 100644 gen/drive2-cli/src/main.rs delete mode 100644 gen/games1-cli/Cargo.toml delete mode 100644 gen/games1-cli/LICENSE.md delete mode 100644 gen/games1-cli/README.md delete mode 100644 gen/games1-cli/mkdocs.yml delete mode 100644 gen/games1-cli/src/cmn.rs delete mode 100644 gen/games1-cli/src/main.rs delete mode 100644 gen/identitytoolkit3-cli/Cargo.toml delete mode 100644 gen/identitytoolkit3-cli/LICENSE.md delete mode 100644 gen/identitytoolkit3-cli/README.md delete mode 100644 gen/identitytoolkit3-cli/mkdocs.yml delete mode 100644 gen/identitytoolkit3-cli/src/cmn.rs delete mode 100644 gen/identitytoolkit3-cli/src/main.rs delete mode 100644 gen/logging1_beta3-cli/Cargo.toml delete mode 100644 gen/logging1_beta3-cli/LICENSE.md delete mode 100644 gen/logging1_beta3-cli/README.md delete mode 100644 gen/logging1_beta3-cli/mkdocs.yml delete mode 100644 gen/logging1_beta3-cli/src/cmn.rs delete mode 100644 gen/logging1_beta3-cli/src/main.rs delete mode 100644 gen/reseller1_sandbox-cli/Cargo.toml delete mode 100644 gen/reseller1_sandbox-cli/LICENSE.md delete mode 100644 gen/reseller1_sandbox-cli/README.md delete mode 100644 gen/reseller1_sandbox-cli/mkdocs.yml delete mode 100644 gen/reseller1_sandbox-cli/src/cmn.rs delete mode 100644 gen/reseller1_sandbox-cli/src/main.rs delete mode 100644 gen/tagmanager1-cli/Cargo.toml delete mode 100644 gen/tagmanager1-cli/LICENSE.md delete mode 100644 gen/tagmanager1-cli/README.md delete mode 100644 gen/tagmanager1-cli/mkdocs.yml delete mode 100644 gen/tagmanager1-cli/src/cmn.rs delete mode 100644 gen/tagmanager1-cli/src/main.rs delete mode 100644 gen/taskqueue1_beta2-cli/Cargo.toml delete mode 100644 gen/taskqueue1_beta2-cli/LICENSE.md delete mode 100644 gen/taskqueue1_beta2-cli/README.md delete mode 100644 gen/taskqueue1_beta2-cli/mkdocs.yml delete mode 100644 gen/taskqueue1_beta2-cli/src/cmn.rs delete mode 100644 gen/taskqueue1_beta2-cli/src/main.rs delete mode 100644 gen/webfonts1-cli/Cargo.toml delete mode 100644 gen/webfonts1-cli/LICENSE.md delete mode 100644 gen/webfonts1-cli/README.md delete mode 100644 gen/webfonts1-cli/mkdocs.yml delete mode 100644 gen/webfonts1-cli/src/cmn.rs delete mode 100644 gen/webfonts1-cli/src/main.rs diff --git a/etc/api/adexchangebuyer/v1.2/adexchangebuyer-api.json b/etc/api/adexchangebuyer/v1.2/adexchangebuyer-api.json index 2038c5f6f7..20cdf13597 100644 --- a/etc/api/adexchangebuyer/v1.2/adexchangebuyer-api.json +++ b/etc/api/adexchangebuyer/v1.2/adexchangebuyer-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/m3L9QaogF7YfclMw_cAMw6VI3oY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/wrqAKwp6S3TrJmyaUelgRJAKaL0\"", "discoveryVersion": "v1", "id": "adexchangebuyer:v1.2", "name": "adexchangebuyer", "canonicalName": "Ad Exchange Buyer", "version": "v1.2", - "revision": "20150323", + "revision": "20150326", "title": "Ad Exchange Buyer API", "description": "Accesses your bidding-account information, submits creatives for validation, finds available direct deals, and retrieves performance reports.", "ownerDomain": "google.com", @@ -270,7 +270,7 @@ }, "filteringReasons": { "type": "object", - "description": "The filtering reasons for the creative. If this feature is not enabled, please ask your technical account manager. Read-only. This field should not be set in requests.", + "description": "The filtering reasons for the creative. Read-only. This field should not be set in requests.", "properties": { "date": { "type": "string", diff --git a/etc/api/adexchangebuyer/v1.3/adexchangebuyer-api.json b/etc/api/adexchangebuyer/v1.3/adexchangebuyer-api.json index 76ea730e9a..434369f3f8 100644 --- a/etc/api/adexchangebuyer/v1.3/adexchangebuyer-api.json +++ b/etc/api/adexchangebuyer/v1.3/adexchangebuyer-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/zTbb6II-FHDYAyPsMzEo2tOkubw\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/LngzzVwqv1YJhBSD4vnWK91Oc64\"", "discoveryVersion": "v1", "id": "adexchangebuyer:v1.3", "name": "adexchangebuyer", "canonicalName": "Ad Exchange Buyer", "version": "v1.3", - "revision": "20150323", + "revision": "20150326", "title": "Ad Exchange Buyer API", "description": "Accesses your bidding-account information, submits creatives for validation, finds available direct deals, and retrieves performance reports.", "ownerDomain": "google.com", @@ -352,7 +352,7 @@ }, "filteringReasons": { "type": "object", - "description": "The filtering reasons for the creative. If this feature is not enabled, please ask your technical account manager. Read-only. This field should not be set in requests.", + "description": "The filtering reasons for the creative. Read-only. This field should not be set in requests.", "properties": { "date": { "type": "string", diff --git a/etc/api/admin/directory_v1/admin-api.json b/etc/api/admin/directory_v1/admin-api.json index 97aa92f2f3..f4b49d1b3c 100644 --- a/etc/api/admin/directory_v1/admin-api.json +++ b/etc/api/admin/directory_v1/admin-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/FINMPppbAsSW7hhRV2k9bEsVkrk\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/Gkp35yY2tnMjjfSgryNCrENSB-w\"", "discoveryVersion": "v1", "id": "admin:directory_v1", "name": "admin", "canonicalName": "directory", "version": "directory_v1", - "revision": "20150309", + "revision": "20150314", "title": "Admin Directory API", "description": "The Admin SDK Directory API lets you view and manage enterprise resources such as users and groups, administrative notifications, security features, and more.", "ownerDomain": "google.com", @@ -321,6 +321,10 @@ } } }, + "annotatedAssetId": { + "type": "string", + "description": "AssetId specified during enrollment or through later annotation" + }, "annotatedLocation": { "type": "string", "description": "Address or location of the device as noted by the administrator" diff --git a/etc/api/adsensehost/v4.1/adsensehost-api.json b/etc/api/adsensehost/v4.1/adsensehost-api.json index ff25822067..6fc53e8011 100644 --- a/etc/api/adsensehost/v4.1/adsensehost-api.json +++ b/etc/api/adsensehost/v4.1/adsensehost-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/tnO9YyBqerhkMo1uQ_2xl4ZaWkc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/n8NTNQVEaYwqoUTL8SFLpUB6Wtk\"", "discoveryVersion": "v1", "id": "adsensehost:v4.1", "name": "adsensehost", "canonicalName": "AdSense Host", "version": "v4.1", - "revision": "20150326", + "revision": "20150307", "title": "AdSense Host API", "description": "Gives AdSense Hosts access to report generation, ad code generation, and publisher management capabilities.", "ownerDomain": "google.com", diff --git a/etc/api/analytics/v2.4/analytics-api.json b/etc/api/analytics/v2.4/analytics-api.json index 7bd47810d8..4716d39fd2 100644 --- a/etc/api/analytics/v2.4/analytics-api.json +++ b/etc/api/analytics/v2.4/analytics-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/IldvChjq6UkiEW0nig_gOjP89aY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/jnLvY1FFNrvhkzc3-yHcZWw_dyc\"", "discoveryVersion": "v1", "id": "analytics:v2.4", "name": "analytics", "version": "v2.4", - "revision": "20150308", + "revision": "20150305", "title": "Google Analytics API", "description": "View and manage your Google Analytics data", "ownerDomain": "google.com", diff --git a/etc/api/analytics/v3/analytics-api.json b/etc/api/analytics/v3/analytics-api.json index 47a70936b0..4b151ceb87 100644 --- a/etc/api/analytics/v3/analytics-api.json +++ b/etc/api/analytics/v3/analytics-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/6NlFUYEBMf81bxiwpXwPhu5e1RQ\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/pk8iT1cgG258NxPsYV-x-iX1AL8\"", "discoveryVersion": "v1", "id": "analytics:v3", "name": "analytics", "version": "v3", - "revision": "20150308", + "revision": "20150305", "title": "Google Analytics API", "description": "View and manage your Google Analytics data", "ownerDomain": "google.com", diff --git a/etc/api/androidpublisher/v1.1/androidpublisher-api.json b/etc/api/androidpublisher/v1.1/androidpublisher-api.json index 59d8f39d43..372070ccf3 100644 --- a/etc/api/androidpublisher/v1.1/androidpublisher-api.json +++ b/etc/api/androidpublisher/v1.1/androidpublisher-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/woz1_DF58GWBfB5hB96ty6PLWFA\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/yLZNoMooQ7qHvZwtvucNfre7PCU\"", "discoveryVersion": "v1", "id": "androidpublisher:v1.1", "name": "androidpublisher", @@ -71,7 +71,7 @@ "oauth2": { "scopes": { "https://www.googleapis.com/auth/androidpublisher": { - "description": "View and manage your Google Play Android Developer account" + "description": "View and manage your Google Play Developer account" } } } diff --git a/etc/api/androidpublisher/v1/androidpublisher-api.json b/etc/api/androidpublisher/v1/androidpublisher-api.json index c6adb26f22..d0d65ec89e 100644 --- a/etc/api/androidpublisher/v1/androidpublisher-api.json +++ b/etc/api/androidpublisher/v1/androidpublisher-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/pN4g0JBnUUfVdUX2qQiF-rIjqpY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/JGynskXPDYAm7HfLDYPma5VcVjE\"", "discoveryVersion": "v1", "id": "androidpublisher:v1", "name": "androidpublisher", @@ -71,7 +71,7 @@ "oauth2": { "scopes": { "https://www.googleapis.com/auth/androidpublisher": { - "description": "View and manage your Google Play Android Developer account" + "description": "View and manage your Google Play Developer account" } } } diff --git a/etc/api/androidpublisher/v2/androidpublisher-api.json b/etc/api/androidpublisher/v2/androidpublisher-api.json index 03b8f1d7ff..a51a77022a 100644 --- a/etc/api/androidpublisher/v2/androidpublisher-api.json +++ b/etc/api/androidpublisher/v2/androidpublisher-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/ucFo1l8fmB-ZOvUDZMuH1NM6pOg\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/2DGQXV9vEvRmzTOqKw6AgrR-Dxw\"", "discoveryVersion": "v1", "id": "androidpublisher:v2", "name": "androidpublisher", @@ -71,7 +71,7 @@ "oauth2": { "scopes": { "https://www.googleapis.com/auth/androidpublisher": { - "description": "View and manage your Google Play Android Developer account" + "description": "View and manage your Google Play Developer account" } } } diff --git a/etc/api/api-list.yaml b/etc/api/api-list.yaml index cda4e96959..2086221af5 100644 --- a/etc/api/api-list.yaml +++ b/etc/api/api-list.yaml @@ -62,11 +62,11 @@ api: deploymentmanager: - v2beta1 dfareporting: - - v2.0 + - v2.1 discovery: - v1 dns: - - v1beta1 + - v1 doubleclickbidmanager: - v1 doubleclicksearch: diff --git a/etc/api/appstate/v1/appstate-api.json b/etc/api/appstate/v1/appstate-api.json index 12696c6896..f8b11a17c1 100644 --- a/etc/api/appstate/v1/appstate-api.json +++ b/etc/api/appstate/v1/appstate-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/l72trJKpRo_9jBaEIh6zAECyXZk\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/_qtMBNYmtGLL9lEXbS-_U7qtvOE\"", "discoveryVersion": "v1", "id": "appstate:v1", "name": "appstate", "canonicalName": "App State", "version": "v1", - "revision": "20150326", + "revision": "20150414", "title": "Google App State API", "description": "The Google App State API.", "ownerDomain": "google.com", diff --git a/etc/api/audit/v1/audit-api.json b/etc/api/audit/v1/audit-api.json index 4b43e7896d..2dffc82c12 100644 --- a/etc/api/audit/v1/audit-api.json +++ b/etc/api/audit/v1/audit-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/WETM6oPOB_u6tVJCuBP1DDIWlEg\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/qDki177mae-tdDHfIJUXH1TuTZo\"", "discoveryVersion": "v1", "id": "audit:v1", "name": "audit", "version": "v1", - "revision": "20130108", + "revision": "20150419", "title": "Enterprise Audit API", "description": "Lets you access user activities in your enterprise made through various applications.", "ownerDomain": "google.com", diff --git a/etc/api/bigquery/v2/bigquery-api.json b/etc/api/bigquery/v2/bigquery-api.json index fd072438d9..0414ecef4d 100644 --- a/etc/api/bigquery/v2/bigquery-api.json +++ b/etc/api/bigquery/v2/bigquery-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/KlquM6UqjmIyuGctKF7ppu43Avk\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/R2tvUOg0npxomcc8XogN9tN818k\"", "discoveryVersion": "v1", "id": "bigquery:v2", "name": "bigquery", @@ -14,7 +14,7 @@ "x16": "https://www.google.com/images/icons/product/search-16.gif", "x32": "https://www.google.com/images/icons/product/search-32.gif" }, - "documentationLink": "https://developers.google.com/bigquery/docs/overview", + "documentationLink": "https://cloud.google.com/bigquery/", "protocol": "rest", "baseUrl": "https://www.googleapis.com/bigquery/v2/", "basePath": "/bigquery/v2/", @@ -562,7 +562,7 @@ }, "projectionFields": { "type": "array", - "description": "[Experimental] Names(case-sensitive) of properties to keep when importing data. If this is populated, only the specified properties will be imported for each entity. Currently, this is only supported for DATASTORE_BACKUP imports and only top level properties are supported. If any specified property is not found in the Datastore 'Kind' being imported, that is an error. Note: This feature is experimental and can change in the future.", + "description": "[Experimental] If sourceFormat is set to \"DATASTORE_BACKUP\", indicates which entity properties to load into BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level properties. If no properties are specified, BigQuery loads all properties. If any named property isn't found in the Cloud Datastore backup, an invalid error is returned in the job result.", "items": { "type": "string" } @@ -627,7 +627,7 @@ }, "flattenResults": { "type": "boolean", - "description": "[Experimental] Flattens all nested and repeated fields in the query results. The default value is true. allowLargeResults must be true if this is set to false." + "description": "[Optional] Flattens all nested and repeated fields in the query results. The default value is true. allowLargeResults must be true if this is set to false." }, "preserveNulls": { "type": "boolean", @@ -1498,7 +1498,7 @@ "id": "bigquery.datasets.list", "path": "projects/{projectId}/datasets", "httpMethod": "GET", - "description": "Lists all the datasets in the specified project to which the caller has read access; however, a project owner can list (but not necessarily get) all datasets in his project.", + "description": "Lists all datasets in the specified project to which you have been granted the READER dataset role.", "parameters": { "all": { "type": "boolean", @@ -1610,7 +1610,7 @@ "id": "bigquery.jobs.get", "path": "projects/{projectId}/jobs/{jobId}", "httpMethod": "GET", - "description": "Retrieves the specified job by ID.", + "description": "Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role.", "parameters": { "jobId": { "type": "string", @@ -1695,7 +1695,7 @@ "id": "bigquery.jobs.insert", "path": "projects/{projectId}/jobs", "httpMethod": "POST", - "description": "Starts a new asynchronous job.", + "description": "Starts a new asynchronous job. Requires the Can View project role.", "parameters": { "projectId": { "type": "string", @@ -1741,7 +1741,7 @@ "id": "bigquery.jobs.list", "path": "projects/{projectId}/jobs", "httpMethod": "GET", - "description": "Lists all the Jobs in the specified project that were started by the user. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created.", + "description": "Lists all jobs that you started in the specified project. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created. Requires the Can View project role, or the Is Owner project role if you set the allUsers property.", "parameters": { "allUsers": { "type": "boolean", @@ -1841,7 +1841,7 @@ "id": "bigquery.projects.list", "path": "projects", "httpMethod": "GET", - "description": "Lists the projects to which you have at least read access.", + "description": "Lists all projects to which you have been granted any project role.", "parameters": { "maxResults": { "type": "integer", @@ -1871,7 +1871,7 @@ "id": "bigquery.tabledata.insertAll", "path": "projects/{projectId}/datasets/{datasetId}/tables/{tableId}/insertAll", "httpMethod": "POST", - "description": "Streams data into BigQuery one record at a time without needing to run a load job.", + "description": "Streams data into BigQuery one record at a time without needing to run a load job. Requires the WRITER dataset role.", "parameters": { "datasetId": { "type": "string", @@ -1913,7 +1913,7 @@ "id": "bigquery.tabledata.list", "path": "projects/{projectId}/datasets/{datasetId}/tables/{tableId}/data", "httpMethod": "GET", - "description": "Retrieves table data from a specified set of rows.", + "description": "Retrieves table data from a specified set of rows. Requires the READER dataset role.", "parameters": { "datasetId": { "type": "string", @@ -2079,7 +2079,7 @@ "id": "bigquery.tables.list", "path": "projects/{projectId}/datasets/{datasetId}/tables", "httpMethod": "GET", - "description": "Lists all tables in the specified dataset.", + "description": "Lists all tables in the specified dataset. Requires the READER dataset role.", "parameters": { "datasetId": { "type": "string", diff --git a/etc/api/blogger/v2/blogger-api.json b/etc/api/blogger/v2/blogger-api.json index ef9a6c2bfb..55c623ec4d 100644 --- a/etc/api/blogger/v2/blogger-api.json +++ b/etc/api/blogger/v2/blogger-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/XzL6uOznnhS35LBYxSIEEnBsJ1o\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/bBeihkUTVNLguM-RJHso_Z4vNao\"", "discoveryVersion": "v1", "id": "blogger:v2", "name": "blogger", "version": "v2", - "revision": "20150208", + "revision": "20150422", "title": "Blogger API", "description": "API for access to the data within Blogger.", "ownerDomain": "google.com", diff --git a/etc/api/blogger/v3/blogger-api.json b/etc/api/blogger/v3/blogger-api.json index 7f6549bebc..069814beb3 100644 --- a/etc/api/blogger/v3/blogger-api.json +++ b/etc/api/blogger/v3/blogger-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/IrFCn8z3q4ulYVZWC1SJkXJKYC0\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/ZRgj7Ah7gwQETAdvqLpx-xGEmV8\"", "discoveryVersion": "v1", "id": "blogger:v3", "name": "blogger", "version": "v3", - "revision": "20150208", + "revision": "20150422", "title": "Blogger API", "description": "API for access to the data within Blogger.", "ownerDomain": "google.com", @@ -360,6 +360,10 @@ "id": "CommentList", "type": "object", "properties": { + "etag": { + "type": "string", + "description": "Etag of the response." + }, "items": { "type": "array", "description": "The List of Comments for a Post.", @@ -473,6 +477,10 @@ "id": "PageList", "type": "object", "properties": { + "etag": { + "type": "string", + "description": "Etag of the response." + }, "items": { "type": "array", "description": "The list of Pages for a Blog.", @@ -692,6 +700,10 @@ "id": "PostList", "type": "object", "properties": { + "etag": { + "type": "string", + "description": "Etag of the response." + }, "items": { "type": "array", "description": "The list of Posts for this Blog.", diff --git a/etc/api/books/v1/books-api.json b/etc/api/books/v1/books-api.json index 3ccd50121d..f8038a0c90 100644 --- a/etc/api/books/v1/books-api.json +++ b/etc/api/books/v1/books-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/7vCHfrhi9Lj_cY5xxg_5Db6xPtw\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/RU3_yBWk7Dll2fVe-S46ywC_3gs\"", "discoveryVersion": "v1", "id": "books:v1", "name": "books", "version": "v1", - "revision": "20150309", + "revision": "20150401", "title": "Books API", "description": "Lets you search for books and manage your Google Books library.", "ownerDomain": "google.com", @@ -1727,6 +1727,9 @@ "type": "string", "description": "The main category to which this volume belongs. It will be the category from the categories list returned below that has the highest weight." }, + "maturityRating": { + "type": "string" + }, "pageCount": { "type": "integer", "description": "Total number of pages as per publisher metadata.", @@ -2775,7 +2778,7 @@ "id": "books.myconfig.updateUserSettings", "path": "myconfig/updateUserSettings", "httpMethod": "POST", - "description": "Sets the settings for the user. Unspecified sub-objects will retain the existing value.", + "description": "Sets the settings for the user. If a sub-object is specified, it will overwrite the existing sub-object stored in the server. Unspecified sub-objects will retain the existing value.", "request": { "$ref": "Usersettings" }, diff --git a/etc/api/calendar/v3/calendar-api.json b/etc/api/calendar/v3/calendar-api.json index 3eb6f355a7..5826513ccf 100644 --- a/etc/api/calendar/v3/calendar-api.json +++ b/etc/api/calendar/v3/calendar-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/0tpC9BbaQPK_TZmlZK5cHsIr_JY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/snCOExYvhrzEZTGzdubZtafuHVU\"", "discoveryVersion": "v1", "id": "calendar:v3", "name": "calendar", "version": "v3", - "revision": "20150303", + "revision": "20150326", "title": "Calendar API", "description": "Lets you manipulate events and other calendar data.", "ownerDomain": "google.com", diff --git a/etc/api/cloudmonitoring/v2beta2/cloudmonitoring-api.json b/etc/api/cloudmonitoring/v2beta2/cloudmonitoring-api.json index 24b816ad29..5bf5388b85 100644 --- a/etc/api/cloudmonitoring/v2beta2/cloudmonitoring-api.json +++ b/etc/api/cloudmonitoring/v2beta2/cloudmonitoring-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/3DSYNWNR337DSanxbXP8iK4KQaY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/8AX4EEpwBs_EPri68uJBfOfq5Bo\"", "discoveryVersion": "v1", "id": "cloudmonitoring:v2beta2", "name": "cloudmonitoring", "canonicalName": "Cloud Monitoring", "version": "v2beta2", - "revision": "20150303", + "revision": "20150401", "title": "Cloud Monitoring API", "description": "API for accessing Google Cloud and API monitoring data.", "ownerDomain": "google.com", @@ -266,11 +266,11 @@ "properties": { "metricType": { "type": "string", - "description": "The method of collecting data for the metric." + "description": "The method of collecting data for the metric. See Metric types." }, "valueType": { "type": "string", - "description": "The type of data that is written to a timeseries point for this metric." + "description": "The data type of of individual points in the metric's time series. See Metric value types." } } }, diff --git a/etc/api/cloudsearch/v1/cloudsearch-api.json b/etc/api/cloudsearch/v1/cloudsearch-api.json index ca04bf7bba..81b5583187 100644 --- a/etc/api/cloudsearch/v1/cloudsearch-api.json +++ b/etc/api/cloudsearch/v1/cloudsearch-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/nEzuRsBqgiDxr-ibn0WHLMhdIu8\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/zg78C4sqdSofxjEUeedn97IFYfM\"", "discoveryVersion": "v1", "id": "cloudsearch:v1", "name": "cloudsearch", "version": "v1", - "revision": "20150309", + "revision": "20150416", "title": "Google Cloud Search API", "description": "The Google Cloud Search API defines an application interface to index documents that contain structured data and to search those indexes. It supports full text search.", "ownerDomain": "google.com", @@ -33,7 +33,8 @@ "default": "json", "enumDescriptions": [ "Responses with Content-Type of application/json", - "Media download with context dependend Content-Type" + "Media download with context-dependent Content-Type", + "Responses with Content-Type of application/x-protobuf" ], "location": "query" }, @@ -88,585 +89,5 @@ ], "location": "query" } - }, - "auth": { - "oauth2": { - "scopes": { - "https://www.googleapis.com/auth/cloud-platform": { - "description": "View and manage your data across Google Cloud Platform services" - }, - "https://www.googleapis.com/auth/cloudsearch": { - "description": "FOR TESTING ONLY" - }, - "https://www.googleapis.com/auth/userinfo.email": { - "description": "View your email address" - } - } - } - }, - "schemas": { - "Document": { - "id": "Document", - "type": "object", - "description": "The message representing a document resource.", - "properties": { - "docId": { - "type": "string", - "description": "The unique identifier of the document. It must contain only visible, printable ASCII characters (ASCII codes 33 through 126 inclusive) and be no longer than 500 characters. It cannot begin with an exclamation point ('!'), and it can't begin and end with double underscores (\"__\"). If missing, it is automatically assigned for the document." - }, - "rank": { - "type": "integer", - "description": "A positive integer which determines the default ordering of documents returned from a search. The rank can be set explicitly when the document is created. It is a bad idea to assign the same rank to many documents, and the same rank should never be assigned to more than 10,000 documents. By default (when it is not specified or set to 0), it is set at the time the document is created to the number of seconds since January 1, 2011. The rank can be used in field_expressions, order_by or return_fields in a search request, where it is referenced as `_rank`.", - "format": "int32" - }, - "fields": { - "type": "object", - "description": "The list of fields in the document. It cannot be the empty list. Each field has a name and a list of values. The field name is unique to a document and is case sensitive. The name can only contain ASCII characters. It must start with a letter and can contain letters, digits, or underscore. It cannot be longer than 500 characters and cannot be the empty string. A field can have multiple values with same or different types, however, it cannot have multiple Timestamp or number values.", - "additionalProperties": { - "$ref": "FieldValueList" - } - } - } - }, - "FieldValueList": { - "id": "FieldValueList", - "type": "object", - "description": "The values of a document field under the same field name.", - "properties": { - "values": { - "type": "array", - "description": "The list of typed values.", - "items": { - "$ref": "FieldValue" - } - } - } - }, - "FieldValue": { - "id": "FieldValue", - "type": "object", - "description": "The value of a document field and associated metadata. Exactly one of the value fields may be set.", - "properties": { - "stringValue": { - "type": "string", - "description": "The value of a string-valued field." - }, - "timestampValue": { - "type": "string", - "description": "The value of a timestamp-valued field." - }, - "numberValue": { - "type": "number", - "description": "The value of a number-valued field.", - "format": "double" - }, - "geoValue": { - "type": "string", - "description": "The value of a GEO-valued field, represented in string with any of the listed [ways of writing coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ways_of_writing_coordinates)" - }, - "stringFormat": { - "type": "string", - "description": "The format of a string value. By default, the string format is `DEFAULT`, where a format will be automatically detected.", - "enum": [ - "DEFAULT", - "ATOM", - "TEXT", - "HTML" - ] - }, - "lang": { - "type": "string", - "description": "The language of a string value. If given, the language must be a valid `ISO 639-1` code." - } - } - }, - "Empty": { - "id": "Empty", - "type": "object", - "description": "A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }" - }, - "ListDocumentsResponse": { - "id": "ListDocumentsResponse", - "type": "object", - "description": "A response returned from a listing documents request.", - "properties": { - "documents": { - "type": "array", - "description": "The list of documents.", - "items": { - "$ref": "Document" - } - }, - "nextPageToken": { - "type": "string", - "description": "If there are more results, retrieve them by invoking list documents call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set." - } - } - }, - "ListIndexesResponse": { - "id": "ListIndexesResponse", - "type": "object", - "description": "A response returned from a listing indexes request.", - "properties": { - "indexes": { - "type": "array", - "description": "The information about available indexes.", - "items": { - "$ref": "IndexInfo" - } - }, - "nextPageToken": { - "type": "string", - "description": "If there are more results, retrieve them by invoking list indexes call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set." - } - } - }, - "IndexInfo": { - "id": "IndexInfo", - "type": "object", - "description": "Information about an index.", - "properties": { - "projectId": { - "type": "string", - "description": "The project associated with the index. It cannot be the empty string." - }, - "indexId": { - "type": "string", - "description": "The index identifier. It cannot be the empty string. It must contain only visible, printable ASCII characters (ASCII codes 33 through 126 inclusive) and be no longer than 100 characters. It cannot begin with an exclamation point ('!'), and it can't begin and end with double underscores (\"__\")." - }, - "indexedField": { - "$ref": "FieldNames", - "description": "Names of indexed fields." - } - } - }, - "FieldNames": { - "id": "FieldNames", - "type": "object", - "description": "Names of indexed fields.", - "properties": { - "textFields": { - "type": "array", - "description": "The names of fields in which TEXT values are stored.", - "items": { - "type": "string" - } - }, - "htmlFields": { - "type": "array", - "description": "The names of fields in which HTML values are stored.", - "items": { - "type": "string" - } - }, - "atomFields": { - "type": "array", - "description": "The names of fields in which ATOM values are stored.", - "items": { - "type": "string" - } - }, - "dateFields": { - "type": "array", - "description": "The names of fields in which DATE values are stored.", - "items": { - "type": "string" - } - }, - "numberFields": { - "type": "array", - "description": "The names of fields in which NUMBER values are stored.", - "items": { - "type": "string" - } - }, - "geoFields": { - "type": "array", - "description": "The names of fields in which GEO values are stored.", - "items": { - "type": "string" - } - } - } - }, - "SearchResponse": { - "id": "SearchResponse", - "type": "object", - "description": "A response returned from a search request.", - "properties": { - "results": { - "type": "array", - "description": "The list of documents that match the search query.", - "items": { - "$ref": "SearchResult" - } - }, - "matchedCount": { - "type": "string", - "description": "The number of documents that match the query. It is greater than or equal to the number of documents actually returned. This is an approximation and not an exact count unless it is less than or equal to `matchedCountAccuracy` in search parameter.", - "format": "int64" - } - } - }, - "SearchResult": { - "id": "SearchResult", - "type": "object", - "description": "A document returned in a SearchResponse.", - "properties": { - "docId": { - "type": "string", - "description": "The unique identifier of the document." - }, - "fields": { - "type": "object", - "description": "The list of fields in the result. Each field is either from the stored document, the built-in fields (`_rank`, the document rank, and `_score` if scoring is enabled), or computed from any extra `fieldExpressions` defined in the request. For example, if a request contains a `fieldExpressions` named `\"TotalPrice\"` and expressed as `\"Price + Tax\"`, the result will have a field whose name is `\"TotalPrice\"` and whose value is set to the computed sum of the value of field `\"Price\"` and the value of field `\"Tax\"`. If a request contains a `fieldExpressions` named `\"snippet\"` and expressed as `\"snippet(\\\"good times\\\", content)\"`, the result will have a field whose name is `\"snippet\"` and whose value contains a snippet of text from field `\"content\"` matching the query \"good times\".", - "additionalProperties": { - "$ref": "FieldValueList" - } - }, - "nextPageToken": { - "type": "string", - "description": "If there are more results, retrieve them by invoking search call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set." - } - } - } - }, - "resources": { - "projects": { - "resources": { - "indexes": { - "methods": { - "list": { - "id": "cloudsearch.projects.indexes.list", - "path": "v1/projects/{projectId}/indexes", - "httpMethod": "GET", - "description": "Lists search indexes belonging to the specified project.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project from which to retrieve indexes. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexNamePrefix": { - "type": "string", - "description": "The prefix of the index name. It is used to list all indexes with names that have this prefix.", - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of indexes to return per page. If not specified, 100 indexes are returned per page.", - "format": "int32", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "A `nextPageToken` returned from previous list indexes call as the starting point for this call. If not specified, list indexes from the beginning.", - "location": "query" - }, - "view": { - "type": "string", - "description": "Specifies which parts of the IndexInfo resource is returned in the response. If not specified, `ID_ONLY` is used.", - "enum": [ - "INDEX_VIEW_UNSPECIFIED", - "ID_ONLY", - "FULL" - ], - "location": "query" - } - }, - "parameterOrder": [ - "projectId", - "indexNamePrefix", - "pageSize", - "pageToken", - "view" - ], - "response": { - "$ref": "ListIndexesResponse" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - }, - "search": { - "id": "cloudsearch.projects.indexes.search", - "path": "v1/projects/{projectId}/indexes/{indexId}/search", - "httpMethod": "GET", - "description": "Lists the documents in the named index that match the query.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project associated with the index for searching document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexId": { - "type": "string", - "description": "The index to search. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "query": { - "type": "string", - "description": "The query string in search query syntax. If the query is missing or empty, all documents are returned.", - "location": "query" - }, - "fieldExpressions": { - "type": "string", - "description": "Customized expressions used in `orderBy` or `returnFields`. The expression can contain fields in `Document`, the built-in fields ( `_rank`, the document rank, and `_score` if scoring is enabled) and fields defined in `fieldExpressions`. Each field expression is represented in a json object with the following fields: * `name`: the name of the field expression in string. * `expression`: the expression to be computed. It can be a combination of supported functions encoded in string. Expressions involving number fields can use the arithmetical operators (`+`, `-`, `*`, `/`) and the built-in numeric functions (`max`, `min`, `pow`, `count`, `log`, `abs`). Expressions involving geopoint fields can use the `geopoint` and `distance` functions. Expressions for text and html fields can use the `snippet` function. For example: ``` fieldExpressions={name: \"TotalPrice\", expression: \"(Price+Tax)\"} ``` ``` fieldExpressions={name: \"snippet\", expression: \"snippet('good times', content)\"} ``` The field expression names can be used in `orderBy` and `returnFields` after they are defined in `fieldExpressions`.", - "repeated": true, - "location": "query" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of search results to return per page. Searches perform best when the `pageSize` is kept as small as possible. If not specified, 10 results are returned per page.", - "format": "int32", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "A `nextPageToken` returned from previous Search call as the starting point for this call. Pagination tokens provide better performance and consistency than offsets, and they cannot be used in combination with offsets.", - "location": "query" - }, - "offset": { - "type": "integer", - "description": "Offset is used to move to an arbitrary result, independent of the previous results. Offsets are inefficient when compared to `pageToken`. `pageToken` and `offset` cannot be both set. The default value of `offset` is 0.", - "format": "int32", - "location": "query" - }, - "matchedCountAccuracy": { - "type": "integer", - "description": "Minimum accuracy requirement for `matchedCount` in search response. If specified, `matchedCount` will be accurate up to at least that number. For example, when set to 100, any `matchedCount \u003c= 100` is accurate. This option may add considerable latency/expense. By default (when it is not specified or set to 0), the accuracy is the same as `pageSize`.", - "format": "int32", - "location": "query" - }, - "orderBy": { - "type": "string", - "description": "Comma-separated list of fields for sorting on the search result, including fields from `Document`, the built-in fields (`_rank` and `_score`), and fields defined in `fieldExpressions`. For example: `orderBy=\"foo,bar\"`. The default sorting order is ascending. To specify descending order for a field, a suffix `\" desc\"` should be appended to the field name. For example: `orderBy=\"foo desc,bar\"`. The default value for text sort is the empty string, and the default value for numeric sort is 0. If not specified, the search results are automatically sorted by descending `_rank`. Sorting by ascending `_rank` is not allowed.", - "location": "query" - }, - "scorer": { - "type": "string", - "description": "The scoring function to invoke on a search result for this query. If `scorer` is not set, scoring is disabled and `_score` is 0 for all documents in the search result. To enable document relevancy score based on term frequency, set `\"scorer=generic\"`.", - "location": "query" - }, - "scorerSize": { - "type": "integer", - "description": "Maximum number of top retrieved results to score. It is valid only when `scorer` is set. If not specified, 100 retrieved results are scored.", - "format": "int32", - "location": "query" - }, - "returnFields": { - "type": "string", - "description": "List of fields to return in `SearchResult` objects. It can be fields from `Document`, the built-in fields `_rank` and `_score`, and fields defined in `fieldExpressions`. Use `\"*\"` to return all fields from `Document`.", - "repeated": true, - "location": "query" - } - }, - "parameterOrder": [ - "projectId", - "indexId", - "query", - "fieldExpressions", - "pageSize", - "pageToken", - "offset", - "matchedCountAccuracy", - "orderBy", - "scorer", - "scorerSize", - "returnFields" - ], - "response": { - "$ref": "SearchResponse" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - } - }, - "resources": { - "documents": { - "methods": { - "create": { - "id": "cloudsearch.projects.indexes.documents.create", - "path": "v1/projects/{projectId}/indexes/{indexId}/documents", - "httpMethod": "POST", - "description": "Inserts a document for indexing or updates an indexed document. The returned document contains only the ID of the new document. When `docId` is absent from the document, it is provided by the server.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project associated with the index for adding document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexId": { - "type": "string", - "description": "The index to add document to. It cannot be the empty string.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "projectId", - "indexId" - ], - "request": { - "$ref": "Document" - }, - "response": { - "$ref": "Document" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - }, - "delete": { - "id": "cloudsearch.projects.indexes.documents.delete", - "path": "v1/projects/{projectId}/indexes/{indexId}/documents/{docId}", - "httpMethod": "DELETE", - "description": "Deletes a document from an index.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project associated with the index for deleting document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexId": { - "type": "string", - "description": "The index from which to delete the document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "docId": { - "type": "string", - "description": "The document to be deleted. It cannot be the empty string.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "projectId", - "indexId", - "docId" - ], - "response": { - "$ref": "Empty" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - }, - "get": { - "id": "cloudsearch.projects.indexes.documents.get", - "path": "v1/projects/{projectId}/indexes/{indexId}/documents/{docId}", - "httpMethod": "GET", - "description": "Retrieves a document from an index.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project associated with the index for retrieving the document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexId": { - "type": "string", - "description": "The index from which to retrieve the document. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "docId": { - "type": "string", - "description": "The identifier of the document to retrieve. It cannot be the empty string.", - "required": true, - "location": "path" - } - }, - "parameterOrder": [ - "projectId", - "indexId", - "docId" - ], - "response": { - "$ref": "Document" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - }, - "list": { - "id": "cloudsearch.projects.indexes.documents.list", - "path": "v1/projects/{projectId}/indexes/{indexId}/documents", - "httpMethod": "GET", - "description": "Lists documents in the specified search index. Intended for batch processing.", - "parameters": { - "projectId": { - "type": "string", - "description": "The project associated with the index for listing documents. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "indexId": { - "type": "string", - "description": "The index from which to list the documents. It cannot be the empty string.", - "required": true, - "location": "path" - }, - "pageSize": { - "type": "integer", - "description": "The maximum number of documents to return per page. If not specified, 100 documents are returned per page.", - "format": "int32", - "location": "query" - }, - "pageToken": { - "type": "string", - "description": "A `nextPageToken` returned from previous list documents call as the starting point for this call. If not specified, list documents from the beginning.", - "location": "query" - }, - "view": { - "type": "string", - "description": "Specifies which part of the document resource is returned in the response. If not specified, `ID_ONLY` is used.", - "enum": [ - "DOCUMENT_VIEW_UNSPECIFIED", - "ID_ONLY", - "FULL" - ], - "location": "query" - } - }, - "parameterOrder": [ - "projectId", - "indexId", - "pageSize", - "pageToken", - "view" - ], - "response": { - "$ref": "ListDocumentsResponse" - }, - "scopes": [ - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudsearch", - "https://www.googleapis.com/auth/userinfo.email" - ] - } - } - } - } - } - } - } } } diff --git a/etc/api/compute/v1/compute-api.json b/etc/api/compute/v1/compute-api.json index 152281a3d7..85eb6174d4 100644 --- a/etc/api/compute/v1/compute-api.json +++ b/etc/api/compute/v1/compute-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/X7hvmvZAuE2GX5lBTJUD_xWfVrI\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/SRyMqDO5Lt1H_OK2ek0Fc_aeb5M\"", "discoveryVersion": "v1", "id": "compute:v1", "name": "compute", @@ -2968,7 +2968,9 @@ "TARGET_HTTP_PROXIES", "TARGET_INSTANCES", "TARGET_POOLS", - "URL_MAPS" + "TARGET_VPN_GATEWAYS", + "URL_MAPS", + "VPN_TUNNELS" ], "enumDescriptions": [ "", @@ -2989,6 +2991,8 @@ "", "", "", + "", + "", "" ] }, @@ -7552,6 +7556,15 @@ "pattern": "[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?", "location": "path" }, + "port": { + "type": "integer", + "description": "Which COM port to retrieve data from.", + "default": "1", + "format": "int32", + "minimum": "1", + "maximum": "4", + "location": "query" + }, "project": { "type": "string", "description": "Project ID for this request.", diff --git a/etc/api/container/v1beta1/container-api.json b/etc/api/container/v1beta1/container-api.json index f6a76e6063..e1ded0e36c 100644 --- a/etc/api/container/v1beta1/container-api.json +++ b/etc/api/container/v1beta1/container-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/A-uTeP-eqK6ANjBJOJiUSQV5WY8\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/dYpTeptRRQe2JpT9NpqLcHD0A_0\"", "discoveryVersion": "v1", "id": "container:v1beta1", "name": "container", "version": "v1beta1", - "revision": "20150318", + "revision": "20150420", "title": "Google Container Engine API", "description": "The Google Container Engine API is used for building and managing container based applications, powered by the open source Kubernetes technology.", "ownerDomain": "google.com", @@ -86,7 +86,7 @@ }, "containerIpv4Cidr": { "type": "string", - "description": "[Output only] The IP addresses of the container pods in this cluster, in CIDR notation (e.g. 1.2.3.4/29)." + "description": "The IP addresses of the container pods in this cluster, in CIDR notation (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block in 10.0.0.0/8 or 172.16.0.0/12." }, "creationTimestamp": { "type": "string", @@ -106,7 +106,7 @@ }, "masterAuth": { "$ref": "MasterAuth", - "description": "The HTTP basic authentication information for accessing the master. Because the master endpoint is open to the internet, you should create a strong password." + "description": "The authentication information for accessing the master." }, "name": { "type": "string", @@ -229,14 +229,19 @@ "MasterAuth": { "id": "MasterAuth", "type": "object", + "description": "The authentication information for accessing the master. Authentication is either done using HTTP basic authentication or using a bearer token.", "properties": { + "bearerToken": { + "type": "string", + "description": "The token used to authenticate API requests to the master. The token is be included in an HTTP Authorization Header included in all requests to the master endpoint. The format of the header is: \"Authorization: Bearer \"." + }, "password": { "type": "string", - "description": "The password to use when accessing the Kubernetes master endpoint." + "description": "The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint. Because the master endpoint is open to the internet, you should create a strong password." }, "user": { "type": "string", - "description": "The username to use when accessing the Kubernetes master endpoint." + "description": "The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint." } } }, @@ -335,6 +340,21 @@ } } } + }, + "Token": { + "id": "Token", + "type": "object", + "properties": { + "accessToken": { + "type": "string", + "description": "The OAuth2 access token" + }, + "expiryTimeSeconds": { + "type": "string", + "description": "The expiration time of the token in seconds since the unix epoch.", + "format": "int64" + } + } } }, "resources": { @@ -607,6 +627,52 @@ ] } } + }, + "tokens": { + "methods": { + "get": { + "id": "container.projects.zones.tokens.get", + "path": "{masterProjectId}/zones/{zoneId}/tokens/{projectNumber}/{clusterName}", + "httpMethod": "GET", + "description": "Gets a compute-rw scoped OAuth2 access token for\n. Authentication is performed to ensure that the caller is a member of and that the request is coming from the expected master VM for the specified cluster. See go/gke-cross-project-auth for more details.", + "parameters": { + "clusterName": { + "type": "string", + "description": "The name of the specified cluster.", + "required": true, + "location": "path" + }, + "masterProjectId": { + "type": "string", + "description": "The hosted master project from which this request is coming.", + "required": true, + "location": "path" + }, + "projectNumber": { + "type": "string", + "description": "The project number for which the access token is being requested.", + "required": true, + "format": "int64", + "location": "path" + }, + "zoneId": { + "type": "string", + "description": "The zone of the specified cluster.", + "required": true, + "location": "path" + } + }, + "parameterOrder": [ + "masterProjectId", + "zoneId", + "projectNumber", + "clusterName" + ], + "response": { + "$ref": "Token" + } + } + } } } } diff --git a/etc/api/content/v2/content-api.json b/etc/api/content/v2/content-api.json index 61b4f7c5ab..60e732c6a8 100644 --- a/etc/api/content/v2/content-api.json +++ b/etc/api/content/v2/content-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/Jg5IFKTqCcIBJROG8QNmsXQ1iso\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/sWwx6biSrC_gtsZDUBqZWGBMUuA\"", "discoveryVersion": "v1", "id": "content:v2", "name": "content", "canonicalName": "Shopping Content", "version": "v2", - "revision": "20150317", + "revision": "20150421", "title": "Content API for Shopping", "description": "Manage product items, inventory, and Merchant Center accounts for Google Shopping.", "ownerDomain": "google.com", @@ -88,7 +88,7 @@ }, "adwordsLinks": { "type": "array", - "description": "List of linked AdWords accounts.", + "description": "List of linked AdWords accounts, active or pending approval. To create a new link request, add a new link with status active to the list. It will remain is state pending until approved or rejected in the AdWords interface. To delete an active link or to cancel a link request, remove it from the list.", "items": { "$ref": "AccountAdwordsLink" } @@ -150,7 +150,7 @@ }, "status": { "type": "string", - "description": "Status of the link between this Merchant Center account and the AdWords account." + "description": "Status of the link between this Merchant Center account and the AdWords account. Upon retrieval, it represents the actual status of the link and can be either active if it was approved in Google AdWords or pending if it's pending approval. Upon insertion, it represents the intended status of the link. Re-uploading a link with status active when it's still pending or with status pending when it's already active will have no effect: the status will remain unchanged. Re-uploading a link with deprecated status inactive is equivalent to not submitting the link at all and will delete the link if it was active or cancel the link request if it was pending." } } }, @@ -1302,6 +1302,10 @@ "description": "Identifies what kind of resource this is. Value: the fixed string \"content#datafeedStatus\".", "default": "content#datafeedStatus" }, + "lastUploadDate": { + "type": "string", + "description": "The last date at which the feed was uploaded." + }, "processingStatus": { "type": "string", "description": "The processing status of the feed." @@ -2911,6 +2915,13 @@ "path": "accountshipping/batch", "httpMethod": "POST", "description": "Retrieves and updates the shipping settings of multiple accounts in a single request.", + "parameters": { + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + } + }, "request": { "$ref": "AccountshippingCustomBatchRequest" }, @@ -3001,6 +3012,11 @@ "format": "uint64", "location": "path" }, + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + }, "merchantId": { "type": "string", "description": "The ID of the managing account.", @@ -3036,6 +3052,11 @@ "format": "uint64", "location": "path" }, + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + }, "merchantId": { "type": "string", "description": "The ID of the managing account.", @@ -3152,6 +3173,13 @@ "path": "accounttax/batch", "httpMethod": "POST", "description": "Retrieves and updates tax settings of multiple accounts in a single request.", + "parameters": { + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + } + }, "request": { "$ref": "AccounttaxCustomBatchRequest" }, @@ -3242,6 +3270,11 @@ "format": "uint64", "location": "path" }, + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + }, "merchantId": { "type": "string", "description": "The ID of the managing account.", @@ -3277,6 +3310,11 @@ "format": "uint64", "location": "path" }, + "dryRun": { + "type": "boolean", + "description": "Flag to run the request in dry-run mode.", + "location": "query" + }, "merchantId": { "type": "string", "description": "The ID of the managing account.", diff --git a/etc/api/dataflow/v1beta3/dataflow-api.json b/etc/api/dataflow/v1beta3/dataflow-api.json index 19822d8d65..b7edb63b99 100644 --- a/etc/api/dataflow/v1beta3/dataflow-api.json +++ b/etc/api/dataflow/v1beta3/dataflow-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/KNSekumf7PpoDBHVIPOg6YU25sY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/FPRgkYm-RZQh1gGnAPYf9mcPy44\"", "discoveryVersion": "v1", "id": "dataflow:v1beta3", "name": "dataflow", "version": "v1beta3", - "revision": "20150401", + "revision": "20150322", "title": "Google Dataflow API", "description": "Google Dataflow API.", "ownerDomain": "google.com", diff --git a/etc/api/datastore/v1beta1/datastore-api.json b/etc/api/datastore/v1beta1/datastore-api.json index ad3c5d8e64..1ba259d19e 100644 --- a/etc/api/datastore/v1beta1/datastore-api.json +++ b/etc/api/datastore/v1beta1/datastore-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/8xS90Igj1Zi_dhxWkhTiyEbzjmc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/fIJ3DBpWQxusVwOa-ZxrsUl27A4\"", "discoveryVersion": "v1", "id": "datastore:v1beta1", "name": "datastore", "version": "v1beta1", - "revision": "20140916", + "revision": "20150402", "title": "Google Cloud Datastore API", "description": "API for accessing Google Cloud Datastore.", "ownerDomain": "google.com", @@ -737,7 +737,7 @@ }, "blobValue": { "type": "string", - "description": "A blob value. May be a maximum of 1,000,000 bytes.", + "description": "A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes.", "format": "byte" }, "booleanValue": { @@ -778,7 +778,7 @@ }, "stringValue": { "type": "string", - "description": "A UTF-8 encoded string value." + "description": "A UTF-8 encoded string value. When indexed is true, may have at most 500 characters." } } } diff --git a/etc/api/datastore/v1beta2/datastore-api.json b/etc/api/datastore/v1beta2/datastore-api.json index b293043921..55388fe589 100644 --- a/etc/api/datastore/v1beta2/datastore-api.json +++ b/etc/api/datastore/v1beta2/datastore-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/flAQ_osq7Vj8ZKDYJi6-tpiBvoo\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/JTCpJ6erGSGSQjeOlJBcixKgvo8\"", "discoveryVersion": "v1", "id": "datastore:v1beta2", "name": "datastore", "version": "v1beta2", - "revision": "20140916", + "revision": "20150402", "title": "Google Cloud Datastore API", "description": "API for accessing Google Cloud Datastore.", "ownerDomain": "google.com", @@ -490,7 +490,7 @@ }, "blobValue": { "type": "string", - "description": "A blob value. May be a maximum of 1,000,000 bytes.", + "description": "A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes.", "format": "byte" }, "booleanValue": { @@ -526,7 +526,7 @@ }, "listValue": { "type": "array", - "description": "A list value. Cannot contain another list value. Cannot also have a meaning and indexing set.", + "description": "A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed.", "items": { "$ref": "Value" } @@ -538,7 +538,7 @@ }, "stringValue": { "type": "string", - "description": "A UTF-8 encoded string value." + "description": "A UTF-8 encoded string value. When indexed is true, may have at most 500 characters." } } }, @@ -845,7 +845,7 @@ }, "blobValue": { "type": "string", - "description": "A blob value. May be a maximum of 1,000,000 bytes.", + "description": "A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes.", "format": "byte" }, "booleanValue": { @@ -881,7 +881,7 @@ }, "listValue": { "type": "array", - "description": "A list value. Cannot contain another list value. Cannot also have a meaning and indexing set.", + "description": "A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed.", "items": { "$ref": "Value" } @@ -893,7 +893,7 @@ }, "stringValue": { "type": "string", - "description": "A UTF-8 encoded string value." + "description": "A UTF-8 encoded string value. When indexed is true, may have at most 500 characters." } } } diff --git a/etc/api/deploymentmanager/v2beta1/deploymentmanager-api.json b/etc/api/deploymentmanager/v2beta1/deploymentmanager-api.json index 6a548ffe66..13af32817b 100644 --- a/etc/api/deploymentmanager/v2beta1/deploymentmanager-api.json +++ b/etc/api/deploymentmanager/v2beta1/deploymentmanager-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/3SdBuBlKXFafgHZPjx-jN_ADZpg\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/hE1oPYTxWhviFb0v73gueyAW5mA\"", "discoveryVersion": "v1", "id": "deploymentmanager:v2beta1", "name": "deploymentmanager", "version": "v2beta1", - "revision": "20150303", + "revision": "20150415", "title": "Google Cloud Deployment Manager API V2", "description": "The Deployment Manager API allows users to declaratively configure, deploy and run complex solutions on the Google Cloud Platform.", "ownerDomain": "google.com", diff --git a/etc/api/dns/v1beta1/dns-api.json b/etc/api/dns/v1beta1/dns-api.json index 55b7785382..c2495cb64e 100644 --- a/etc/api/dns/v1beta1/dns-api.json +++ b/etc/api/dns/v1beta1/dns-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/wU8NjG2rANeT6LROBN3mCaSHZ_8\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/oh0OKkMoXiShh-fNWjMyGYxRkos\"", "discoveryVersion": "v1", "id": "dns:v1beta1", "name": "dns", "version": "v1beta1", - "revision": "20150114", + "revision": "20150218", "title": "Google Cloud DNS API", "description": "The Google Cloud DNS API provides services for configuring and serving authoritative DNS records.", "ownerDomain": "google.com", @@ -116,7 +116,7 @@ }, "status": { "type": "string", - "description": "Status of the operation. Can be one of the following: \"PENDING\" or \"DONE\" (output only)." + "description": "Status of the operation (output only)." } } }, @@ -292,7 +292,7 @@ }, "rrdatas": { "type": "array", - "description": "As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)", + "description": "As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1).", "items": { "type": "string" } @@ -304,7 +304,7 @@ }, "type": { "type": "string", - "description": "One of A, AAAA, SOA, MX, NS, TXT" + "description": "The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on." } } }, diff --git a/etc/api/drive/v2/drive-api.json b/etc/api/drive/v2/drive-api.json index 7d53ba1c09..d8ef297d47 100644 --- a/etc/api/drive/v2/drive-api.json +++ b/etc/api/drive/v2/drive-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/yUsYaOTyEAvpk-uZ9U5lffkz2VU\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/q7G5QdguNPp3b-d0oF62ZLMOZNU\"", "discoveryVersion": "v1", "id": "drive:v2", "name": "drive", @@ -81,6 +81,9 @@ "https://www.googleapis.com/auth/drive.file": { "description": "View and manage Google Drive files that you have opened or created with this app" }, + "https://www.googleapis.com/auth/drive.metadata": { + "description": "View and manage metadata of files in your Google Drive" + }, "https://www.googleapis.com/auth/drive.metadata.readonly": { "description": "View metadata for files in your Google Drive" }, @@ -1749,6 +1752,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -1781,6 +1785,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -1844,6 +1849,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -1894,6 +1900,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ], @@ -1949,6 +1956,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ], @@ -1972,6 +1980,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -2038,6 +2047,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -2111,6 +2121,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -2450,15 +2461,10 @@ "parameters": { "acknowledgeAbuse": { "type": "boolean", - "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. Ignored unless alt=media is specified.", + "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files.", "default": "false", "location": "query" }, - "alt": { - "type": "string", - "description": "Specifies the type of resource representation to return. The default is 'json' to return file metadata. Specifying 'media' will cause the file content to be returned.", - "location": "query" - }, "fileId": { "type": "string", "description": "The ID for the file in question.", @@ -2501,6 +2507,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ], @@ -2657,6 +2664,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -2755,6 +2763,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.scripts" ] }, @@ -2781,7 +2790,8 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", - "https://www.googleapis.com/auth/drive.file" + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata" ] }, "trash": { @@ -2930,6 +2940,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.scripts" ], "supportsMediaUpload": true, @@ -2958,15 +2969,10 @@ "parameters": { "acknowledgeAbuse": { "type": "boolean", - "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files. Ignored unless alt=media is specified.", + "description": "Whether the user is acknowledging the risk of downloading known malware or other abusive files.", "default": "false", "location": "query" }, - "alt": { - "type": "string", - "description": "Specifies the type of resource representation to return. The default is 'json' to return file metadata. Specifying 'media' will cause the file content to be returned.", - "location": "query" - }, "fileId": { "type": "string", "description": "The ID for the file in question.", @@ -3013,6 +3019,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ], @@ -3081,6 +3088,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3136,6 +3144,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3201,6 +3210,7 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3229,6 +3239,7 @@ "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.apps.readonly", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3293,6 +3304,7 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3413,7 +3425,8 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata" ] }, "get": { @@ -3452,6 +3465,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3481,7 +3495,8 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata" ] }, "list": { @@ -3507,6 +3522,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -3549,7 +3565,8 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata" ] }, "update": { @@ -3590,7 +3607,8 @@ "scopes": [ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", - "https://www.googleapis.com/auth/drive.file" + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata" ] } } @@ -3985,6 +4003,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] @@ -4012,6 +4031,7 @@ "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.appdata", "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.metadata", "https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive.readonly" ] diff --git a/etc/api/fitness/v1/fitness-api.json b/etc/api/fitness/v1/fitness-api.json index c5c4f587b0..c4b596b095 100644 --- a/etc/api/fitness/v1/fitness-api.json +++ b/etc/api/fitness/v1/fitness-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/lDyElxcTuD_AINzagoHaFK_1_Y4\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/NViEYVhdyE08LWyL01EX31ABjdw\"", "discoveryVersion": "v1", "id": "fitness:v1", "name": "fitness", "version": "v1", - "revision": "20150222", + "revision": "20150326", "title": "Fitness", "description": "Google Fit API", "ownerDomain": "google.com", @@ -299,10 +299,18 @@ "type": "string", "description": "The different supported formats for each field in a data type.", "enum": [ + "floatList", "floatPoint", - "integer" + "integer", + "integerList", + "map", + "string" ], "enumDescriptions": [ + "", + "", + "", + "", "", "" ], @@ -495,6 +503,11 @@ "type": "object", "description": "Sessions contain metadata, such as a user-friendly name and time interval information.", "properties": { + "activeTimeMillis": { + "type": "string", + "description": "Session active time. While start_time_millis and end_time_millis define the full session time, the active time can be shorter and specified by active_time_millis. If the inactive time during the session is known, it should also be inserted via a com.google.activity.segment data point with a STILL activity value", + "format": "int64" + }, "activityType": { "type": "integer", "description": "The type of activity this session represents.", @@ -614,6 +627,38 @@ "https://www.googleapis.com/auth/fitness.location.write" ] }, + "delete": { + "id": "fitness.users.dataSources.delete", + "path": "{userId}/dataSources/{dataSourceId}", + "httpMethod": "DELETE", + "description": "Delete the data source if there are no datapoints associated with it", + "parameters": { + "dataSourceId": { + "type": "string", + "description": "The data stream ID of the data source to delete.", + "required": true, + "location": "path" + }, + "userId": { + "type": "string", + "description": "Retrieve a data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time.", + "required": true, + "location": "path" + } + }, + "parameterOrder": [ + "userId", + "dataSourceId" + ], + "response": { + "$ref": "DataSource" + }, + "scopes": [ + "https://www.googleapis.com/auth/fitness.activity.write", + "https://www.googleapis.com/auth/fitness.body.write", + "https://www.googleapis.com/auth/fitness.location.write" + ] + }, "get": { "id": "fitness.users.dataSources.get", "path": "{userId}/dataSources/{dataSourceId}", diff --git a/etc/api/fusiontables/v1/fusiontables-api.json b/etc/api/fusiontables/v1/fusiontables-api.json index 70a5c6381b..636ebf1e8c 100644 --- a/etc/api/fusiontables/v1/fusiontables-api.json +++ b/etc/api/fusiontables/v1/fusiontables-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/_HDQvvrmU1Cf0bBIzjf-H39NJ10\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/4HCFw9IZNfeLuwpeJU6_2IK7soQ\"", "discoveryVersion": "v1", "id": "fusiontables:v1", "name": "fusiontables", "version": "v1", - "revision": "20150226", + "revision": "20150326", "title": "Fusion Tables API", "description": "API for working with Fusion Tables data.", "ownerDomain": "google.com", diff --git a/etc/api/fusiontables/v2/fusiontables-api.json b/etc/api/fusiontables/v2/fusiontables-api.json index 0f6452c346..a731939c24 100644 --- a/etc/api/fusiontables/v2/fusiontables-api.json +++ b/etc/api/fusiontables/v2/fusiontables-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/zzkCy2O-Agowk5lRoMuWDbJW1wc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/dI_tOjeJOWF2ORhLQyVd-42H-68\"", "discoveryVersion": "v1", "id": "fusiontables:v2", "name": "fusiontables", "version": "v2", - "revision": "20150226", + "revision": "20150326", "title": "Fusion Tables API", "description": "API for working with Fusion Tables data.", "ownerDomain": "google.com", diff --git a/etc/api/games/v1/games-api.json b/etc/api/games/v1/games-api.json index c7ab017b01..de55bb4d47 100644 --- a/etc/api/games/v1/games-api.json +++ b/etc/api/games/v1/games-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/1Sien7FsUWQik8Zkpqt7CxSFDCo\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/6wWOyzUyIV1QXGfj7Laljr6yta8\"", "discoveryVersion": "v1", "id": "games:v1", "name": "games", "canonicalName": "Games", "version": "v1", - "revision": "20150325", + "revision": "20150413", "title": "Google Play Game Services API", "description": "The API for Google Play Game Services.", "ownerDomain": "google.com", diff --git a/etc/api/gamesconfiguration/v1configuration/gamesconfiguration-api.json b/etc/api/gamesconfiguration/v1configuration/gamesconfiguration-api.json index bb90c0c258..b243283899 100644 --- a/etc/api/gamesconfiguration/v1configuration/gamesconfiguration-api.json +++ b/etc/api/gamesconfiguration/v1configuration/gamesconfiguration-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/47HlVPVwrRZ1Vj_DsTzZ93ugWO8\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/1lytpOAcJYjccK3uufWMlKFi1ZU\"", "discoveryVersion": "v1", "id": "gamesConfiguration:v1configuration", "name": "gamesConfiguration", "canonicalName": "Games Configuration", "version": "v1configuration", - "revision": "20150325", + "revision": "20150413", "title": "Google Play Game Services Publishing API", "description": "The Publishing API for Google Play Game Services.", "ownerDomain": "google.com", @@ -71,7 +71,7 @@ "oauth2": { "scopes": { "https://www.googleapis.com/auth/androidpublisher": { - "description": "View and manage your Google Play Android Developer account" + "description": "View and manage your Google Play Developer account" } } } diff --git a/etc/api/gamesmanagement/v1management/gamesmanagement-api.json b/etc/api/gamesmanagement/v1management/gamesmanagement-api.json index d608e2e88d..df5f39ce22 100644 --- a/etc/api/gamesmanagement/v1management/gamesmanagement-api.json +++ b/etc/api/gamesmanagement/v1management/gamesmanagement-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/YvQmKUorpJAo-VniLfUYF6KVx8c\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/arP5fSrBqJ1jS7apXYHDTKjArfA\"", "discoveryVersion": "v1", "id": "gamesManagement:v1management", "name": "gamesManagement", "canonicalName": "Games Management", "version": "v1management", - "revision": "20150325", + "revision": "20150413", "title": "Google Play Game Services Management API", "description": "The Management API for Google Play Game Services.", "ownerDomain": "google.com", diff --git a/etc/api/genomics/v1beta2/genomics-api.json b/etc/api/genomics/v1beta2/genomics-api.json index 27f8e1b497..b27bb326e6 100644 --- a/etc/api/genomics/v1beta2/genomics-api.json +++ b/etc/api/genomics/v1beta2/genomics-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/zxM6l4gLCm-vFIvi5lr-kFXGmmI\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/j8Y-s44WXRWtA7sjAxaOKh9K17Q\"", "discoveryVersion": "v1", "id": "genomics:v1beta2", "name": "genomics", @@ -428,6 +428,7 @@ "CLIP_SOFT", "DELETE", "INSERT", + "OPERATION_UNSPECIFIED", "PAD", "SEQUENCE_MATCH", "SEQUENCE_MISMATCH", @@ -442,6 +443,7 @@ "", "", "", + "", "" ] }, @@ -1196,7 +1198,7 @@ }, "alignment": { "$ref": "LinearAlignment", - "description": "The linear alignment for this alignment record. This field will be null if the read is unmapped." + "description": "The linear alignment for this alignment record. This field will be unset if the read is unmapped." }, "duplicateFragment": { "type": "boolean", @@ -1232,7 +1234,7 @@ }, "nextMatePosition": { "$ref": "Position", - "description": "The mapping of the primary alignment of the (readNumber+1)%numberReads read in the fragment. It replaces mate position and mate strand in SAM." + "description": "The position of the primary alignment of the (readNumber+1)%numberReads read in the fragment. It replaces mate position and mate strand in SAM. This field will be unset if that read is unmapped or if the fragment only has a single read." }, "numberReads": { "type": "integer", @@ -1639,7 +1641,7 @@ }, "pageSize": { "type": "integer", - "description": "The maximum number of call sets to return.", + "description": "The maximum number of call sets to return. If unspecified, defaults to 1000.", "format": "int32" }, "pageToken": { @@ -2011,17 +2013,17 @@ }, "end": { "type": "string", - "description": "Required. The end of the window (0-based, exclusive) for which overlapping variants should be returned.", + "description": "The end of the window, 0-based exclusive. If unspecified or 0, defaults to the length of the reference.", "format": "int64" }, "maxCalls": { "type": "integer", - "description": "The maximum number of calls to return. However, at least one variant will always be returned, even if it has more calls than this limit.", + "description": "The maximum number of calls to return. However, at least one variant will always be returned, even if it has more calls than this limit. If unspecified, defaults to 5000.", "format": "int32" }, "pageSize": { "type": "integer", - "description": "The maximum number of variants to return.", + "description": "The maximum number of variants to return. If unspecified, defaults to 5000.", "format": "int32" }, "pageToken": { @@ -2034,7 +2036,7 @@ }, "start": { "type": "string", - "description": "Required. The beginning of the window (0-based, inclusive) for which overlapping variants should be returned.", + "description": "The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. If unspecified, defaults to 0.", "format": "int64" }, "variantName": { @@ -2068,37 +2070,41 @@ } } }, - "StreamVariantsRequest": { - "id": "StreamVariantsRequest", + "StreamReadsRequest": { + "id": "StreamReadsRequest", "type": "object", - "description": "The stream variants request.", "properties": { - "callSetIds": { + "end": { + "type": "string", + "description": "The end position of the range on the reference, 0-based exclusive. If specified, referenceName must also be specified.", + "format": "int64" + }, + "readGroupSetIds": { "type": "array", - "description": "Only return variant calls which belong to call sets with these ids. Leaving this blank returns all variant calls.", + "description": "The ID of the read groups set within which to search for reads. Exactly one ID must be provided.", "items": { "type": "string" } }, - "end": { - "type": "string", - "description": "The end of the window (0-based, exclusive) for which overlapping variants should be returned.", - "format": "int64" - }, "referenceName": { "type": "string", - "description": "Required. Only return variants in this reference sequence." + "description": "The reference sequence name, for example chr1, 1, or chrX. If set to *, only unmapped reads are returned." }, "start": { "type": "string", - "description": "The beginning of the window (0-based, inclusive) for which overlapping variants should be returned.", + "description": "The start position of the range on the reference, 0-based inclusive. If specified, referenceName must also be specified.", "format": "int64" - }, - "variantSetIds": { + } + } + }, + "StreamReadsResponse": { + "id": "StreamReadsResponse", + "type": "object", + "properties": { + "alignments": { "type": "array", - "description": "Exactly one variant set ID must be provided. Only variants from this variant set will be returned.", "items": { - "type": "string" + "$ref": "Read" } } } @@ -3489,18 +3495,18 @@ } } }, - "streamingVariantStore": { + "streamingReadstore": { "methods": { - "streamvariants": { - "id": "genomics.streamingVariantStore.streamvariants", - "path": "streamingVariantStore/streamvariants", + "streamreads": { + "id": "genomics.streamingReadstore.streamreads", + "path": "streamingReadstore/streamreads", "httpMethod": "POST", - "description": "Returns a stream of all the variants matching the search request, ordered by reference name, position, and ID.", + "description": "Gets a stream of reads for one or more read group sets. Reads search operates over a genomic coordinate space of reference sequence & position defined over the reference sequences to which the requested read group sets are aligned.\n\nIf a target positional range is specified, all reads whose alignment to the reference genome overlap the range are returned.\n\nAll reads returned are ordered by genomic coordinate (reference sequence & position). Reads with equivalent genomic coordinates are returned in a deterministic order.", "request": { - "$ref": "StreamVariantsRequest" + "$ref": "StreamReadsRequest" }, "response": { - "$ref": "Variant" + "$ref": "StreamReadsResponse" } } } diff --git a/etc/api/identitytoolkit/v3/identitytoolkit-api.json b/etc/api/identitytoolkit/v3/identitytoolkit-api.json index 0a4e326bf1..9930131bc1 100644 --- a/etc/api/identitytoolkit/v3/identitytoolkit-api.json +++ b/etc/api/identitytoolkit/v3/identitytoolkit-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/jfVz2w61e7LPgd-72fW_8rrOqOc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/c9gT3rNuoajJVcPy4DAj8Wu9bSM\"", "discoveryVersion": "v1", "id": "identitytoolkit:v3", "name": "identitytoolkit", "canonicalName": "Identity Toolkit", "version": "v3", - "revision": "20141009", + "revision": "20150406", "title": "Google Identity Toolkit API", "description": "Help the third party sites to implement federated login.", "ownerDomain": "google.com", @@ -170,6 +170,26 @@ } } }, + "GetRecaptchaParamResponse": { + "id": "GetRecaptchaParamResponse", + "type": "object", + "description": "Response of getting recaptcha param.", + "properties": { + "kind": { + "type": "string", + "description": "The fixed string \"identitytoolkit#GetRecaptchaParamResponse\".", + "default": "identitytoolkit#GetRecaptchaParamResponse" + }, + "recaptchaSiteKey": { + "type": "string", + "description": "Site key registered at recaptcha." + }, + "recaptchaStoken": { + "type": "string", + "description": "The stoken field for the recaptcha widget, used to request captcha challenge." + } + } + }, "IdentitytoolkitRelyingpartyCreateAuthUriRequest": { "id": "IdentitytoolkitRelyingpartyCreateAuthUriRequest", "type": "object", @@ -195,6 +215,14 @@ "type": "string", "description": "The email or federated ID of the user." }, + "oauthConsumerKey": { + "type": "string", + "description": "The developer's consumer key for OpenId OAuth Extension" + }, + "oauthScope": { + "type": "string", + "description": "Additional oauth scopes, beyond the basid user profile, that the user would be prompted to grant" + }, "openidRealm": { "type": "string", "description": "Optional realm for OpenID protocol. The sub string \"scheme://domain:port\" of the param \"continueUri\" is used if this is not set." @@ -400,6 +428,10 @@ "requestUri": { "type": "string", "description": "The URI to which the IDP redirects the user back. It may contain federated login result params added by the IDP." + }, + "returnRefreshToken": { + "type": "boolean", + "description": "Whether to return refresh tokens." } } }, @@ -719,6 +751,19 @@ "type": "string", "description": "The nick name of the user." }, + "oauthAccessToken": { + "type": "string", + "description": "The OAuth2 access token." + }, + "oauthAuthorizationCode": { + "type": "string", + "description": "The OAuth2 authorization code." + }, + "oauthExpireIn": { + "type": "integer", + "description": "The lifetime in seconds of the OAuth2 access token.", + "format": "int32" + }, "oauthRequestToken": { "type": "string", "description": "The user approved request token for the OpenID OAuth extension." @@ -861,6 +906,15 @@ "$ref": "IdentitytoolkitRelyingpartyGetPublicKeysResponse" } }, + "getRecaptchaParam": { + "id": "identitytoolkit.relyingparty.getRecaptchaParam", + "path": "getRecaptchaParam", + "httpMethod": "GET", + "description": "Get recaptcha secure param.", + "response": { + "$ref": "GetRecaptchaParamResponse" + } + }, "resetPassword": { "id": "identitytoolkit.relyingparty.resetPassword", "path": "resetPassword", diff --git a/etc/api/mapsengine/exp2/mapsengine-api.json b/etc/api/mapsengine/exp2/mapsengine-api.json index 8b409cd10c..f5c9efee47 100644 --- a/etc/api/mapsengine/exp2/mapsengine-api.json +++ b/etc/api/mapsengine/exp2/mapsengine-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/_yXcj6wu30wUQF66rzR3e0Lw5jc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/XhF2xx0Lfoiz5ESiVXN4QpScCGc\"", "discoveryVersion": "v1", "id": "mapsengine:exp2", "name": "mapsengine", "canonicalName": "Maps Engine", "version": "exp2", - "revision": "20150225", + "revision": "20150414", "title": "Google Maps Engine API", "description": "The Google Maps Engine API allows developers to store and query geospatial vector and raster data.", "ownerDomain": "google.com", diff --git a/etc/api/mapsengine/v1/mapsengine-api.json b/etc/api/mapsengine/v1/mapsengine-api.json index 598e7d7fd7..664b8754be 100644 --- a/etc/api/mapsengine/v1/mapsengine-api.json +++ b/etc/api/mapsengine/v1/mapsengine-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/Vg8aif6zALdzKwx32KoUR-kzgwE\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/kLKyGogYDuC1m34RldogSlxPPMQ\"", "discoveryVersion": "v1", "id": "mapsengine:v1", "name": "mapsengine", "canonicalName": "Maps Engine", "version": "v1", - "revision": "20150225", + "revision": "20150414", "title": "Google Maps Engine API", "description": "The Google Maps Engine API allows developers to store and query geospatial vector and raster data.", "ownerDomain": "google.com", diff --git a/etc/api/oauth2/v1/oauth2-api.json b/etc/api/oauth2/v1/oauth2-api.json index c9c17a31ff..fb0a63fd7e 100644 --- a/etc/api/oauth2/v1/oauth2-api.json +++ b/etc/api/oauth2/v1/oauth2-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/LR-zAnrp1OXQoSngPoN-9yJ62_I\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/x2QBsuiKT4nkMzUF8gequOfNOyQ\"", "discoveryVersion": "v1", "id": "oauth2:v1", "name": "oauth2", "version": "v1", - "revision": "20150319", + "revision": "20150416", "title": "Google OAuth2 API", "description": "Lets you access OAuth2 protocol related APIs.", "ownerDomain": "google.com", diff --git a/etc/api/oauth2/v2/oauth2-api.json b/etc/api/oauth2/v2/oauth2-api.json index 1b59fae260..499d6259e9 100644 --- a/etc/api/oauth2/v2/oauth2-api.json +++ b/etc/api/oauth2/v2/oauth2-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/I-Kz7nVLqL3C3aFzaPv8bMiNptU\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/vIZCM-aeEhcCtmulcHwknl3f2rE\"", "discoveryVersion": "v1", "id": "oauth2:v2", "name": "oauth2", "version": "v2", - "revision": "20150319", + "revision": "20150416", "title": "Google OAuth2 API", "description": "Lets you access OAuth2 protocol related APIs.", "ownerDomain": "google.com", diff --git a/etc/api/plus/v1/plus-api.json b/etc/api/plus/v1/plus-api.json index 86a7cb18c5..a8ef170480 100644 --- a/etc/api/plus/v1/plus-api.json +++ b/etc/api/plus/v1/plus-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/X3g01vIYMSy71JQPvoKwBNQycIw\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/ORNICSF2Z1YjV7yMXdU4V945lGo\"", "discoveryVersion": "v1", "id": "plus:v1", "name": "plus", "version": "v1", - "revision": "20150326", + "revision": "20150303", "title": "Google+ API", "description": "The Google+ API enables developers to build on top of the Google+ platform.", "ownerDomain": "google.com", diff --git a/etc/api/plusdomains/v1/plusdomains-api.json b/etc/api/plusdomains/v1/plusdomains-api.json index 8250f4da30..e9aee4fda5 100644 --- a/etc/api/plusdomains/v1/plusdomains-api.json +++ b/etc/api/plusdomains/v1/plusdomains-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/j03oJNhPCD-NQKGeJbeDIUyfCn0\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/pzJb3bipFURG3pTFQAI_x_KdTEY\"", "discoveryVersion": "v1", "id": "plusDomains:v1", "name": "plusDomains", "version": "v1", - "revision": "20150326", + "revision": "20150303", "title": "Google+ Domains API", "description": "The Google+ API enables developers to build on top of the Google+ platform.", "ownerDomain": "google.com", diff --git a/etc/api/pubsub/v1beta1/pubsub-api.json b/etc/api/pubsub/v1beta1/pubsub-api.json index 37e000ca9f..c03aca2ccf 100644 --- a/etc/api/pubsub/v1beta1/pubsub-api.json +++ b/etc/api/pubsub/v1beta1/pubsub-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/LbBwzYbVBam1gVQEBSCOUlfciRc\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/ZlS39JHAlE8Q0nTYVAdz5dw63po\"", "discoveryVersion": "v1", "id": "pubsub:v1beta1", "name": "pubsub", "version": "v1beta1", - "revision": "20141112", + "revision": "20150223", "title": "Google Cloud Pub/Sub API", "description": "Provides reliable, many-to-many, asynchronous messaging between applications.", "ownerDomain": "google.com", @@ -163,7 +163,7 @@ "properties": { "ackDeadlineSeconds": { "type": "integer", - "description": "The new Ack deadline. Must be \u003e= 0.", + "description": "The new ack deadline with respect to the time this request was sent to the Pub/Sub system. Must be \u003e= 0. For example, if the value is 10, the new ack deadline will expire 10 seconds after the ModifyAckDeadline call was made. Specifying zero may immediately make the message available for another pull request.", "format": "int32" }, "ackId": { @@ -585,7 +585,7 @@ "id": "pubsub.topics.delete", "path": "topics/{+topic}", "httpMethod": "DELETE", - "description": "Deletes the topic with the given name. All subscriptions to this topic are also deleted. Returns NOT_FOUND if the topic does not exist. After a topic is deleted, a new topic may be created with the same name.", + "description": "Deletes the topic with the given name. Returns NOT_FOUND if the topic does not exist. After a topic is deleted, a new topic may be created with the same name.", "parameters": { "topic": { "type": "string", diff --git a/etc/api/replicapoolupdater/v1beta1/replicapoolupdater-api.json b/etc/api/replicapoolupdater/v1beta1/replicapoolupdater-api.json index 9c0098eede..96b9c320f3 100644 --- a/etc/api/replicapoolupdater/v1beta1/replicapoolupdater-api.json +++ b/etc/api/replicapoolupdater/v1beta1/replicapoolupdater-api.json @@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/IuZy-huEI4odldDxlxCkfd4i7iE\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/VmJ_vmyXHKjcZlOaFyHKHkKE8I0\"", "discoveryVersion": "v1", "id": "replicapoolupdater:v1beta1", "name": "replicapoolupdater", "version": "v1beta1", - "revision": "20150129", + "revision": "20150326", "title": "Google Compute Engine Instance Group Updater API", "description": "The Google Compute Engine Instance Group Updater API provides services for updating groups of Compute Engine Instances.", "ownerDomain": "google.com", @@ -106,7 +106,7 @@ }, "location": { "type": "string", - "description": "[Output Only] Indicates the field in the request which caused the error. This property is optional." + "description": "[Output Only] Indicates the field in the request that caused the error. This property is optional." }, "message": { "type": "string", @@ -164,7 +164,7 @@ }, "creationTimestamp": { "type": "string", - "description": "[Output Only] Creation timestamp in RFC3339 text format (output only)." + "description": "[Output Only] Creation timestamp in RFC3339 text format." }, "endTime": { "type": "string" @@ -185,7 +185,7 @@ }, "location": { "type": "string", - "description": "[Output Only] Indicates the field in the request which caused the error. This property is optional." + "description": "[Output Only] Indicates the field in the request that caused the error. This property is optional." }, "message": { "type": "string", @@ -219,7 +219,7 @@ }, "name": { "type": "string", - "description": "[Output Only] Name of the resource (output only)." + "description": "[Output Only] Name of the resource." }, "operationType": { "type": "string" @@ -230,7 +230,7 @@ }, "region": { "type": "string", - "description": "[Output Only] URL of the region where the operation resides (output only)." + "description": "[Output Only] URL of the region where the operation resides." }, "selfLink": { "type": "string", @@ -255,7 +255,7 @@ }, "targetLink": { "type": "string", - "description": "[Output Only] URL of the resource the operation is mutating (output only)." + "description": "[Output Only] URL of the resource the operation is mutating." }, "user": { "type": "string" @@ -295,7 +295,7 @@ }, "zone": { "type": "string", - "description": "[Output Only] URL of the zone where the operation resides (output only)." + "description": "[Output Only] URL of the zone where the operation resides." } } }, @@ -306,7 +306,7 @@ "properties": { "actionType": { "type": "string", - "description": "Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups and explicit lists of instances." + "description": "Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups." }, "creationTimestamp": { "type": "string", @@ -318,7 +318,7 @@ }, "error": { "type": "object", - "description": "[Output Only] Errors that occurred during rolling update.", + "description": "[Output Only] Errors that occurred during the rolling update.", "properties": { "errors": { "type": "array", @@ -332,7 +332,7 @@ }, "location": { "type": "string", - "description": "[Output Only] Indicates the field in the request which caused the error. This property is optional." + "description": "[Output Only] Indicates the field in the request that caused the error. This property is optional." }, "message": { "type": "string", @@ -349,23 +349,16 @@ }, "instanceGroup": { "type": "string", - "description": "Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set." + "description": "Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager and instanceGroup must be set." }, "instanceGroupManager": { "type": "string", - "description": "Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set." + "description": "Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager and instanceGroup must be set." }, "instanceTemplate": { "type": "string", "description": "Fully-qualified URL of an instance template to apply." }, - "instances": { - "type": "array", - "description": "List of fully-qualified URLs of instances to be updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set.", - "items": { - "type": "string" - } - }, "kind": { "type": "string", "description": "[Output Only] Type of the resource.", @@ -377,32 +370,27 @@ "properties": { "autoPauseAfterInstances": { "type": "integer", - "description": "Number of instances updated before the update gets automatically paused.", + "description": "Number of instances to update before the updater pauses the rolling update.", "format": "int32" }, "instanceStartupTimeoutSec": { "type": "integer", - "description": "Maximum amount of time we will wait after finishing all steps until we receive HEALTHY state for instance. If this deadline is exceeded instance update is considered as failed.", + "description": "The maximum amount of time that the updater waits for a HEALTHY state after all of the update steps are complete. If the HEALTHY state is not received before the deadline, the instance update is considered a failure.", "format": "int32" }, "maxNumConcurrentInstances": { "type": "integer", - "description": "Maximum number of instances that can be updated simultaneously (concurrently). An update of an instance starts when the instance is about to be restarted and finishes after the instance has been restarted and the sleep period (defined by sleepAfterInstanceRestartSec) has passed.", + "description": "The maximum number of instances that can be updated simultaneously. An instance update is considered complete only after the instance is restarted and initialized.", "format": "int32" }, "maxNumFailedInstances": { "type": "integer", - "description": "Maximum number of instance updates that can fail without failing the group update. Instance update is considered failed if any of it's update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if after finishing all update actions this instance is in UNHEALTHY state.", + "description": "The maximum number of instance updates that can fail before the group update is considered a failure. An instance update is considered failed if any of its update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if the instance is in an UNHEALTHY state after it finishes all of the update actions.", "format": "int32" }, "minInstanceUpdateTimeSec": { "type": "integer", - "description": "Specifies minimum amount of time we will spend on updating single instance, measuring at the start of the first update action (e.g. Recreate call on Instance Group Manager or Stop call on Instance resource). If actual instance update takes less time we will simply sleep before proceeding with next instance.", - "format": "int32" - }, - "sleepAfterInstanceRestartSec": { - "type": "integer", - "description": "Time period after the instance has been restarted but before marking the update of this instance as done. This field is deprecated and ignored by Rolling Updater.", + "description": "The minimum amount of time that the updater spends to update each instance. Update time is the time it takes to complete all update actions (e.g. Stop call on Instance resource in Rolling Reboot), reboot, and initialize. If the instance update finishes early, the updater pauses for the remainder of the time before it starts the next instance update.", "format": "int32" } } @@ -588,7 +576,7 @@ }, "instanceGroupManager": { "type": "string", - "description": "The name of the instance group manager used for filtering.", + "description": "The name of the instance group manager. Use this parameter to return only updates to instances that are part of a specific instance group.", "location": "query" }, "maxResults": { diff --git a/etc/api/sqladmin/v1beta4/sqladmin-api.json b/etc/api/sqladmin/v1beta4/sqladmin-api.json index 07cd49a716..96b7f05419 100644 --- a/etc/api/sqladmin/v1beta4/sqladmin-api.json +++ b/etc/api/sqladmin/v1beta4/sqladmin-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/VRpa8Bw34Om-F9MZNGivJ1l0EOs\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/meEPSemq72cDd2uWQHra_UPM5hU\"", "discoveryVersion": "v1", "id": "sqladmin:v1beta4", "name": "sqladmin", @@ -802,17 +802,7 @@ "format": "date-time" }, "error": { - "type": "object", - "description": "If errors occurred during processing of this operation, this field will be populated.", - "properties": { - "errors": { - "type": "array", - "description": "The list of errors encountered while processing this operation.", - "items": { - "$ref": "OperationError" - } - } - } + "$ref": "OperationErrors" }, "exportContext": { "$ref": "ExportContext", @@ -891,6 +881,25 @@ } } }, + "OperationErrors": { + "id": "OperationErrors", + "type": "object", + "description": "Database instance operation errors list wrapper.", + "properties": { + "errors": { + "type": "array", + "description": "The list of errors encountered while processing this operation.", + "items": { + "$ref": "OperationError" + } + }, + "kind": { + "type": "string", + "description": "This is always sql#operationErrors.", + "default": "sql#operationErrors" + } + } + }, "OperationsListResponse": { "id": "OperationsListResponse", "type": "object", @@ -926,7 +935,7 @@ }, "mysqlReplicaConfiguration": { "$ref": "MySqlReplicaConfiguration", - "description": "MySQL specific configuration when replicating from a MySQL on-premises master." + "description": "MySQL specific configuration when replicating from a MySQL on-premises master. Replication configuration information such as the username, password, certificates, and keys are not stored in the instance metadata. The configuration information is used only to set up the replication connection and is stored by MySQL in a file named master.info in the data directory." } } }, @@ -973,7 +982,8 @@ "description": "The daily backup configuration for the instance." }, "crashSafeReplicationEnabled": { - "type": "boolean" + "type": "boolean", + "description": "Configuration specific to read replica instances. Indicates whether database flags for crash-safe replication are enabled." }, "databaseFlags": { "type": "array", diff --git a/etc/api/storage/v1/storage-api.json b/etc/api/storage/v1/storage-api.json index 15abcc6541..380a51f606 100644 --- a/etc/api/storage/v1/storage-api.json +++ b/etc/api/storage/v1/storage-api.json @@ -1,6 +1,6 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/3q_iADjFHt1rgbaFlWGflHM37mg\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/-eHE4ygU6pB-Rytn-s2uFnfwHbs\"", "discoveryVersion": "v1", "id": "storage:v1", "name": "storage", @@ -778,6 +778,35 @@ } } } + }, + "RewriteResponse": { + "id": "RewriteResponse", + "type": "object", + "description": "A Rewrite response.", + "properties": { + "done": { + "type": "boolean" + }, + "kind": { + "type": "string", + "description": "The kind of item this is.", + "default": "storage#rewriteResponse" + }, + "objectSize": { + "type": "string", + "format": "uint64" + }, + "resource": { + "$ref": "Object" + }, + "rewriteToken": { + "type": "string" + }, + "totalBytesRewritten": { + "type": "string", + "format": "uint64" + } + } } }, "resources": { @@ -1872,21 +1901,6 @@ ], "location": "query" }, - "encryptionAlgorithm": { - "type": "string", - "description": "Specifies the encryption algorithm that was used to encrypt the object, if any. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "Provides a base64-encoded 256-bit key that was used to encrypt the object, if any. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "ifGenerationMatch": { "type": "string", "description": "Makes the operation conditional on whether the object's current generation matches the given value.", @@ -1956,21 +1970,6 @@ ], "location": "query" }, - "encryptionAlgorithm": { - "type": "string", - "description": "Specifies the encryption algorithm that was used to encrypt the object, if any. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "Provides a base64-encoded 256-bit key that was used to encrypt the object, if any. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "ifGenerationMatch": { "type": "string", "description": "Makes the operation conditional on whether the destination object's current generation matches the given value.", @@ -2141,21 +2140,6 @@ "required": true, "location": "path" }, - "encryptionAlgorithm": { - "type": "string", - "description": "Specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "Provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "generation": { "type": "string", "description": "If present, selects a specific revision of this object (as opposed to the latest version, the default).", @@ -2238,21 +2222,6 @@ "description": "If set, sets the contentEncoding property of the final object to this value. Setting this parameter is equivalent to setting the contentEncoding metadata property. This can be useful when uploading an object with uploadType=media to indicate the encoding of the content being uploaded.", "location": "query" }, - "encryptionAlgorithm": { - "type": "string", - "description": "Specifies the encryption algorithm that would be used to encrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "Provides a base64-encoded 256-bit key to encrypt the object. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "ifGenerationMatch": { "type": "string", "description": "Makes the operation conditional on whether the object's current generation matches the given value.", @@ -2368,7 +2337,7 @@ }, "maxResults": { "type": "integer", - "description": "Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested.", + "description": "Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. The default value of this parameter is 1,000 items.", "format": "uint32", "minimum": "0", "location": "query" @@ -2398,7 +2367,7 @@ }, "versions": { "type": "boolean", - "description": "If true, lists all versions of a file as distinct results.", + "description": "If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning.", "location": "query" } }, @@ -2428,21 +2397,6 @@ "required": true, "location": "path" }, - "encryptionAlgorithm": { - "type": "string", - "description": "For downloading encrypted objects, specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "For downloading encrypted objects, provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "For downloading encrypted objects, provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "generation": { "type": "string", "description": "If present, selects a specific revision of this object (as opposed to the latest version, the default).", @@ -2530,6 +2484,154 @@ "https://www.googleapis.com/auth/devstorage.read_write" ] }, + "rewrite": { + "id": "storage.objects.rewrite", + "path": "b/{sourceBucket}/o/{sourceObject}/rewriteTo/b/{destinationBucket}/o/{destinationObject}", + "httpMethod": "POST", + "description": "Rewrites a source object to a destination object. Optionally overrides metadata.", + "parameters": { + "destinationBucket": { + "type": "string", + "description": "Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.", + "required": true, + "location": "path" + }, + "destinationObject": { + "type": "string", + "description": "Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.", + "required": true, + "location": "path" + }, + "destinationPredefinedAcl": { + "type": "string", + "description": "Apply a predefined set of access controls to the destination object.", + "enum": [ + "authenticatedRead", + "bucketOwnerFullControl", + "bucketOwnerRead", + "private", + "projectPrivate", + "publicRead" + ], + "enumDescriptions": [ + "Object owner gets OWNER access, and allAuthenticatedUsers get READER access.", + "Object owner gets OWNER access, and project team owners get OWNER access.", + "Object owner gets OWNER access, and project team owners get READER access.", + "Object owner gets OWNER access.", + "Object owner gets OWNER access, and project team members get access according to their roles.", + "Object owner gets OWNER access, and allUsers get READER access." + ], + "location": "query" + }, + "ifGenerationMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the destination object's current generation matches the given value.", + "format": "int64", + "location": "query" + }, + "ifGenerationNotMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the destination object's current generation does not match the given value.", + "format": "int64", + "location": "query" + }, + "ifMetagenerationMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the destination object's current metageneration matches the given value.", + "format": "int64", + "location": "query" + }, + "ifMetagenerationNotMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the destination object's current metageneration does not match the given value.", + "format": "int64", + "location": "query" + }, + "ifSourceGenerationMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the source object's generation matches the given value.", + "format": "int64", + "location": "query" + }, + "ifSourceGenerationNotMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the source object's generation does not match the given value.", + "format": "int64", + "location": "query" + }, + "ifSourceMetagenerationMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the source object's current metageneration matches the given value.", + "format": "int64", + "location": "query" + }, + "ifSourceMetagenerationNotMatch": { + "type": "string", + "description": "Makes the operation conditional on whether the source object's current metageneration does not match the given value.", + "format": "int64", + "location": "query" + }, + "maxBytesRewrittenPerCall": { + "type": "string", + "description": "The maximum number of bytes that will be rewritten per Rewrite request. Most callers shouldn't need to specify this parameter - it is primarily in place to support testing. If specified the value must be an integral multiple of 1 MiB (1048576). Also, this only applies to requests where the source and destination span locations and/or storage classes. Finally, this value must not change across Rewrite calls else you'll get an error that the rewrite token is invalid.", + "format": "int64", + "location": "query" + }, + "projection": { + "type": "string", + "description": "Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.", + "enum": [ + "full", + "noAcl" + ], + "enumDescriptions": [ + "Include all properties.", + "Omit the acl property." + ], + "location": "query" + }, + "rewriteToken": { + "type": "string", + "description": "Include this field (from the previous Rewrite response) on each Rewrite request after the first one, until the Rewrite response 'done' flag is true. Calls that provide a rewriteToken can omit all other request fields, but if included those fields must match the values provided in the first rewrite request.", + "location": "query" + }, + "sourceBucket": { + "type": "string", + "description": "Name of the bucket in which to find the source object.", + "required": true, + "location": "path" + }, + "sourceGeneration": { + "type": "string", + "description": "If present, selects a specific revision of the source object (as opposed to the latest version, the default).", + "format": "int64", + "location": "query" + }, + "sourceObject": { + "type": "string", + "description": "Name of the source object.", + "required": true, + "location": "path" + } + }, + "parameterOrder": [ + "sourceBucket", + "sourceObject", + "destinationBucket", + "destinationObject" + ], + "request": { + "$ref": "Object" + }, + "response": { + "$ref": "RewriteResponse" + }, + "scopes": [ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/devstorage.full_control", + "https://www.googleapis.com/auth/devstorage.read_write" + ] + }, "update": { "id": "storage.objects.update", "path": "b/{bucket}/o/{object}", @@ -2542,21 +2644,6 @@ "required": true, "location": "path" }, - "encryptionAlgorithm": { - "type": "string", - "description": "For downloading encrypted objects, specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKey": { - "type": "string", - "description": "For downloading encrypted objects, provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, - "encryptionKeyHash": { - "type": "string", - "description": "For downloading encrypted objects, provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together.", - "location": "query" - }, "generation": { "type": "string", "description": "If present, selects a specific revision of this object (as opposed to the latest version, the default).", @@ -2664,7 +2751,7 @@ }, "maxResults": { "type": "integer", - "description": "Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested.", + "description": "Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. The default value of this parameter is 1,000 items.", "format": "uint32", "minimum": "0", "location": "query" @@ -2694,7 +2781,7 @@ }, "versions": { "type": "boolean", - "description": "If true, lists all versions of a file as distinct results.", + "description": "If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning.", "location": "query" } }, diff --git a/etc/api/youtube/v3/youtube-api.json b/etc/api/youtube/v3/youtube-api.json index 6a77247746..dfc7c66539 100644 --- a/etc/api/youtube/v3/youtube-api.json +++ b/etc/api/youtube/v3/youtube-api.json @@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/KXsApYF7ntO41AJammD4suORnPk\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/OsP2PPptQx1WtXrtO4-nK7efx8Q\"", "discoveryVersion": "v1", "id": "youtube:v3", "name": "youtube", "canonicalName": "YouTube", "version": "v3", - "revision": "20150327", + "revision": "20150414", "title": "YouTube Data API", "description": "Programmatic access to YouTube features.", "ownerDomain": "google.com", @@ -974,6 +974,15 @@ } } }, + "ChannelId": { + "id": "ChannelId", + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, "ChannelListResponse": { "id": "ChannelListResponse", "type": "object", @@ -1029,7 +1038,7 @@ }, "title": { "type": "string", - "description": "The localized strings for channel's title, read-only." + "description": "The localized strings for channel's title." } } }, @@ -1065,6 +1074,10 @@ "snippet": { "$ref": "ChannelSectionSnippet", "description": "The snippet object contains basic details about the channel section, such as its type, style and title." + }, + "targeting": { + "$ref": "ChannelSectionTargeting", + "description": "The targeting object contains basic targeting settings about the channel section." } } }, @@ -1214,11 +1227,43 @@ } } }, + "ChannelSectionTargeting": { + "id": "ChannelSectionTargeting", + "type": "object", + "description": "ChannelSection targeting setting.", + "properties": { + "countries": { + "type": "array", + "description": "The country the channel section is targeting.", + "items": { + "type": "string" + } + }, + "languages": { + "type": "array", + "description": "The language the channel section is targeting.", + "items": { + "type": "string" + } + }, + "regions": { + "type": "array", + "description": "The region the channel section is targeting.", + "items": { + "type": "string" + } + } + } + }, "ChannelSettings": { "id": "ChannelSettings", "type": "object", "description": "Branding properties for the channel view.", "properties": { + "country": { + "type": "string", + "description": "The country of the channel." + }, "defaultLanguage": { "type": "string" }, @@ -1280,6 +1325,10 @@ "type": "object", "description": "Basic details about a channel, including title, description and thumbnails.", "properties": { + "country": { + "type": "string", + "description": "The country of the channel." + }, "defaultLanguage": { "type": "string", "description": "The language of the channel's default title and description." @@ -1393,6 +1442,282 @@ } } }, + "Comment": { + "id": "Comment", + "type": "object", + "description": "A comment represents a single YouTube comment.", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "id": { + "type": "string", + "description": "The ID that YouTube uses to uniquely identify the comment." + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#comment\".", + "default": "youtube#comment" + }, + "snippet": { + "$ref": "CommentSnippet", + "description": "The snippet object contains basic details about the comment." + } + } + }, + "CommentListResponse": { + "id": "CommentListResponse", + "type": "object", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "eventId": { + "type": "string", + "description": "Serialized EventId of the request which produced this response." + }, + "items": { + "type": "array", + "description": "A list of comments that match the request criteria.", + "items": { + "$ref": "Comment" + } + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#commentListResponse\".", + "default": "youtube#commentListResponse" + }, + "nextPageToken": { + "type": "string", + "description": "The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set." + }, + "pageInfo": { + "$ref": "PageInfo" + }, + "tokenPagination": { + "$ref": "TokenPagination" + }, + "visitorId": { + "type": "string", + "description": "The visitorId identifies the visitor." + } + } + }, + "CommentSnippet": { + "id": "CommentSnippet", + "type": "object", + "description": "Basic details about a comment, such as its author and text.", + "properties": { + "authorChannelId": { + "$ref": "ChannelId", + "description": "The id of the author's YouTube channel, if any." + }, + "authorChannelUrl": { + "type": "string", + "description": "Link to the author's YouTube channel, if any." + }, + "authorDisplayName": { + "type": "string", + "description": "The name of the user who posted the comment." + }, + "authorGoogleplusProfileUrl": { + "type": "string", + "description": "Link to the author's Google+ profile, if any." + }, + "authorProfileImageUrl": { + "type": "string", + "description": "The URL for the avatar of the user who posted the comment." + }, + "canRate": { + "type": "boolean", + "description": "Whether the current viewer can rate this comment." + }, + "channelId": { + "type": "string", + "description": "The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel." + }, + "likeCount": { + "type": "integer", + "description": "The total number of likes this comment has received.", + "format": "uint32" + }, + "moderationStatus": { + "type": "string", + "description": "The comment's moderation status. Will not be set if the comments were requested through the id filter.", + "enum": [ + "heldForReview", + "likelySpam", + "published", + "rejected" + ], + "enumDescriptions": [ + "", + "", + "", + "" + ] + }, + "parentId": { + "type": "string", + "description": "The unique id of the parent comment, only set for replies." + }, + "publishedAt": { + "type": "string", + "description": "The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.", + "format": "date-time" + }, + "textDisplay": { + "type": "string", + "description": "The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc." + }, + "textOriginal": { + "type": "string", + "description": "The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author." + }, + "updatedAt": { + "type": "string", + "description": "The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.", + "format": "date-time" + }, + "videoId": { + "type": "string", + "description": "The ID of the video the comment refers to, if any." + }, + "viewerRating": { + "type": "string", + "description": "The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.", + "enum": [ + "dislike", + "like", + "none", + "unspecified" + ], + "enumDescriptions": [ + "", + "", + "", + "" + ] + } + } + }, + "CommentThread": { + "id": "CommentThread", + "type": "object", + "description": "A comment thread represents information that applies to a top level comment and all its replies. It can also include the top level comment itself and some of the replies.", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "id": { + "type": "string", + "description": "The ID that YouTube uses to uniquely identify the comment thread." + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#commentThread\".", + "default": "youtube#commentThread" + }, + "replies": { + "$ref": "CommentThreadReplies", + "description": "The replies object contains a limited number of replies (if any) to the top level comment found in the snippet." + }, + "snippet": { + "$ref": "CommentThreadSnippet", + "description": "The snippet object contains basic details about the comment thread and also the top level comment." + } + } + }, + "CommentThreadListResponse": { + "id": "CommentThreadListResponse", + "type": "object", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "eventId": { + "type": "string", + "description": "Serialized EventId of the request which produced this response." + }, + "items": { + "type": "array", + "description": "A list of comment threads that match the request criteria.", + "items": { + "$ref": "CommentThread" + } + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#commentThreadListResponse\".", + "default": "youtube#commentThreadListResponse" + }, + "nextPageToken": { + "type": "string", + "description": "The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set." + }, + "pageInfo": { + "$ref": "PageInfo" + }, + "tokenPagination": { + "$ref": "TokenPagination" + }, + "visitorId": { + "type": "string", + "description": "The visitorId identifies the visitor." + } + } + }, + "CommentThreadReplies": { + "id": "CommentThreadReplies", + "type": "object", + "description": "Comments written in (direct or indirect) reply to the top level comment.", + "properties": { + "comments": { + "type": "array", + "description": "A limited number of replies. Unless the number of replies returned equals total_reply_count in the snippet the returned replies are only a subset of the total number of replies.", + "items": { + "$ref": "Comment" + } + } + } + }, + "CommentThreadSnippet": { + "id": "CommentThreadSnippet", + "type": "object", + "description": "Basic details about a comment thread.", + "properties": { + "canReply": { + "type": "boolean", + "description": "Whether the current viewer of the thread can reply to it. This is viewer specific - other viewers may see a different value for this field." + }, + "channelId": { + "type": "string", + "description": "The YouTube channel the comments in the thread refer to or the channel with the video the comments refer to. If video_id isn't set the comments refer to the channel itself." + }, + "isPublic": { + "type": "boolean", + "description": "Whether the thread (and therefore all its comments) is visible to all YouTube users." + }, + "topLevelComment": { + "$ref": "Comment", + "description": "The top level comment of this thread." + }, + "totalReplyCount": { + "type": "integer", + "description": "The total number of replies (not including the top level comment).", + "format": "uint32" + }, + "videoId": { + "type": "string", + "description": "The ID of the video the comments refer to, if any. No video_id implies a channel discussion comment." + } + } + }, "ContentRating": { "id": "ContentRating", "type": "object", @@ -3430,6 +3755,10 @@ "id": "LiveBroadcastStatus", "type": "object", "properties": { + "isDefaultBroadcast": { + "type": "boolean", + "description": "Whether or not this broadcast is the default broadcast" + }, "lifeCycleStatus": { "type": "string", "description": "The broadcast's status. The status can be updated using the API's liveBroadcasts.transition method.", @@ -3644,6 +3973,9 @@ "type": "object", "description": "Brief description of the live stream status.", "properties": { + "isDefaultStream": { + "type": "boolean" + }, "streamStatus": { "type": "string", "enum": [ @@ -4667,6 +4999,127 @@ } } }, + "VideoAbuseReport": { + "id": "VideoAbuseReport", + "type": "object", + "properties": { + "comments": { + "type": "string", + "description": "Additional comments regarding the abuse report." + }, + "language": { + "type": "string", + "description": "The language that the content was viewed in." + }, + "reasonId": { + "type": "string", + "description": "The high-level, or primary, reason that the content is abusive. The value is an abuse report reason ID." + }, + "secondaryReasonId": { + "type": "string", + "description": "The specific, or secondary, reason that this content is abusive (if available). The value is an abuse report reason ID that is a valid secondary reason for the primary reason." + }, + "videoId": { + "type": "string", + "description": "The ID that YouTube uses to uniquely identify the video." + } + } + }, + "VideoAbuseReportReason": { + "id": "VideoAbuseReportReason", + "type": "object", + "description": "A videoAbuseReportReason resource identifies a reason that a video could be reported as abusive. Video abuse report reasons are used with video.ReportAbuse.", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "id": { + "type": "string", + "description": "The ID of this abuse report reason." + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#videoAbuseReportReason\".", + "default": "youtube#videoAbuseReportReason" + }, + "snippet": { + "$ref": "VideoAbuseReportReasonSnippet", + "description": "The snippet object contains basic details about the abuse report reason." + } + } + }, + "VideoAbuseReportReasonId": { + "id": "VideoAbuseReportReasonId", + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "VideoAbuseReportReasonListResponse": { + "id": "VideoAbuseReportReasonListResponse", + "type": "object", + "properties": { + "etag": { + "type": "string", + "description": "Etag of this resource." + }, + "eventId": { + "type": "string", + "description": "Serialized EventId of the request which produced this response." + }, + "items": { + "type": "array", + "description": "A list of valid abuse reasons that are used with video.ReportAbuse.", + "items": { + "$ref": "VideoAbuseReportReason" + } + }, + "kind": { + "type": "string", + "description": "Identifies what kind of resource this is. Value: the fixed string \"youtube#videoAbuseReportReasonListResponse\".", + "default": "youtube#videoAbuseReportReasonListResponse" + }, + "visitorId": { + "type": "string", + "description": "The visitorId identifies the visitor." + } + } + }, + "VideoAbuseReportReasonSnippet": { + "id": "VideoAbuseReportReasonSnippet", + "type": "object", + "description": "Basic details about a video category, such as its localized title.", + "properties": { + "label": { + "type": "string", + "description": "The localized label belonging to this abuse report reason." + }, + "secondaryReasons": { + "type": "array", + "description": "The secondary reasons associated with this reason, if any are available. (There might be 0 or more.)", + "items": { + "$ref": "VideoAbuseReportSecondaryReason" + } + } + } + }, + "VideoAbuseReportSecondaryReason": { + "id": "VideoAbuseReportSecondaryReason", + "type": "object", + "properties": { + "id": { + "$ref": "VideoAbuseReportReasonId", + "description": "The ID of this abuse report secondary reason." + }, + "label": { + "type": "string", + "description": "The localized label for this abuse report secondary reason." + } + } + }, "VideoAgeGating": { "id": "VideoAgeGating", "type": "object", @@ -5981,7 +6434,7 @@ }, "part": { "type": "string", - "description": "The part parameter specifies the caption resource parts that the API response will include.", + "description": "The part parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet.", "required": true, "location": "query" }, @@ -6384,6 +6837,360 @@ } } }, + "commentThreads": { + "methods": { + "insert": { + "id": "youtube.commentThreads.insert", + "path": "commentThreads", + "httpMethod": "POST", + "description": "Creates a new comment thread and top level comment.", + "parameters": { + "part": { + "type": "string", + "description": "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.\n\nThe part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be set.", + "required": true, + "location": "query" + }, + "shareOnGooglePlus": { + "type": "boolean", + "description": "The shareOnGooglePlus determines whether this thread should also be posted on Google+.", + "default": "false", + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "request": { + "$ref": "CommentThread" + }, + "response": { + "$ref": "CommentThread" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "list": { + "id": "youtube.commentThreads.list", + "path": "commentThreads", + "httpMethod": "GET", + "description": "Returns a list of comment threads that match the API request parameters.", + "parameters": { + "allThreadsRelatedToChannelId": { + "type": "string", + "description": "The allThreadsRelatedToChannelId parameter instructs the API to return the comment threads of all videos of the channel and the channel comments as well.", + "location": "query" + }, + "channelId": { + "type": "string", + "description": "The channelId parameter instructs the API to return the comment threads for all the channel comments (not including comments left on videos).", + "location": "query" + }, + "id": { + "type": "string", + "description": "The id parameter specifies a comma-separated list of comment thread IDs for the resources that should be retrieved.", + "location": "query" + }, + "maxResults": { + "type": "integer", + "description": "The maxResults parameter specifies the maximum number of items that should be returned in the result set.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "default": "20", + "format": "uint32", + "minimum": "1", + "maximum": "100", + "location": "query" + }, + "moderationStatus": { + "type": "string", + "description": "Set this parameter to limit the returned comment threads to a particular moderation state.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "default": "published", + "enum": [ + "heldForReview", + "likelySpam", + "published" + ], + "enumDescriptions": [ + "Returns only comment threads awaiting review by a moderator.", + "Returns only comment threads classified as likely being spam.", + "Returns only published comment threads." + ], + "location": "query" + }, + "pageToken": { + "type": "string", + "description": "The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "location": "query" + }, + "part": { + "type": "string", + "description": "The part parameter specifies the commentThread resource parts that the API response will include. Supported values are id, snippet and replies.", + "required": true, + "location": "query" + }, + "searchTerms": { + "type": "string", + "description": "The searchTerms parameter instructs the API to limit the returned comments to those which contain the specified search terms.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "location": "query" + }, + "textFormat": { + "type": "string", + "description": "Set this parameter's value to html or plainText to instruct the API to return the comments left by users in html formatted or in plain text.", + "default": "FORMAT_HTML", + "enum": [ + "html", + "plainText" + ], + "enumDescriptions": [ + "Returns the comments in HTML format.", + "Returns the comments in plain text format." + ], + "location": "query" + }, + "videoId": { + "type": "string", + "description": "The videoId parameter instructs the API to return the comment threads for the video specified by the video id.", + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "response": { + "$ref": "CommentThreadListResponse" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "update": { + "id": "youtube.commentThreads.update", + "path": "commentThreads", + "httpMethod": "PUT", + "description": "Modifies an existing comment.", + "parameters": { + "part": { + "type": "string", + "description": "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.\n\nThe part names that you can include in the parameter value are id, snippet and replies. However only snippet contains properties that can be updated.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "request": { + "$ref": "CommentThread" + }, + "response": { + "$ref": "CommentThread" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + } + } + }, + "comments": { + "methods": { + "delete": { + "id": "youtube.comments.delete", + "path": "comments", + "httpMethod": "DELETE", + "description": "Deletes a comment.", + "parameters": { + "id": { + "type": "string", + "description": "The id parameter specifies the comment ID for the resource that should be deleted.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "id" + ], + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "insert": { + "id": "youtube.comments.insert", + "path": "comments", + "httpMethod": "POST", + "description": "Creates a new comment.\n\nNote: to create a top level comment it is also necessary to create a comment thread. Both are accomplished through the commentThreads resource.", + "parameters": { + "part": { + "type": "string", + "description": "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.\n\nThe part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be set.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "request": { + "$ref": "Comment" + }, + "response": { + "$ref": "Comment" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "list": { + "id": "youtube.comments.list", + "path": "comments", + "httpMethod": "GET", + "description": "Returns a list of comments that match the API request parameters.", + "parameters": { + "id": { + "type": "string", + "description": "The id parameter specifies a comma-separated list of comment IDs for the resources that should be retrieved.", + "location": "query" + }, + "maxResults": { + "type": "integer", + "description": "The maxResults parameter specifies the maximum number of items that should be returned in the result set.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "default": "20", + "format": "uint32", + "minimum": "1", + "maximum": "100", + "location": "query" + }, + "pageToken": { + "type": "string", + "description": "The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.\n\nNote: This parameter is not supported for use in conjunction with the id parameter.", + "location": "query" + }, + "parentId": { + "type": "string", + "description": "The parentId parameter specifies the ID of the comment for which replies should be retrieved.\n\nNote: Currently YouTube features only one level of replies (ie replies to top level comments). However replies to replies may be supported in the future.", + "location": "query" + }, + "part": { + "type": "string", + "description": "The part parameter specifies the comment resource parts that the API response will include. Supported values are id and snippet.", + "required": true, + "location": "query" + }, + "textFormat": { + "type": "string", + "description": "Set this parameter's value to html or plainText to instruct the API to return the comments left by users formatted as HTML or as plain text.", + "default": "FORMAT_HTML", + "enum": [ + "html", + "plainText" + ], + "enumDescriptions": [ + "Returns the comments in HTML format.", + "Returns the comments in plain text format." + ], + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "response": { + "$ref": "CommentListResponse" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "markAsSpam": { + "id": "youtube.comments.markAsSpam", + "path": "comments/markAsSpam", + "httpMethod": "POST", + "description": "Expresses the caller's opinion that a comment is spam.", + "parameters": { + "id": { + "type": "string", + "description": "The id parameter specifies a comma-separated list of IDs of comments which should get flagged as spam.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "id" + ], + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "setModerationStatus": { + "id": "youtube.comments.setModerationStatus", + "path": "comments/setModerationStatus", + "httpMethod": "POST", + "description": "Sets the moderation status of one or more comments.", + "parameters": { + "banAuthor": { + "type": "boolean", + "description": "The banAuthor paramter, if set to true, adds the author of the comment to the ban list. This means all future comments of the author will autmomatically be rejected.\n\nNote: This parameter is only valid in combination with moderationStatus 'rejected'.", + "default": "false", + "location": "query" + }, + "id": { + "type": "string", + "description": "The id parameter specifies a comma-separated list of IDs of comments whose moderation status should be updated.", + "required": true, + "location": "query" + }, + "moderationStatus": { + "type": "string", + "description": "Determines the new moderation status of the specified comments.", + "required": true, + "enum": [ + "heldForReview", + "published", + "rejected" + ], + "enumDescriptions": [ + "Marks a comment as awaiting review by a moderator.", + "Clears a comment for public display.", + "Rejects a comment as not fit for display.\n\nNote: currently there is no way to list or otherwise discover a rejected comment. However it is possible to change its moderation status as long as its ID is still known.\n\nNote: Currently, if you reject a comment you effectively also hide all its replies as there is no longer any way to discover them. This may change in the future." + ], + "location": "query" + } + }, + "parameterOrder": [ + "id", + "moderationStatus" + ], + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + }, + "update": { + "id": "youtube.comments.update", + "path": "comments", + "httpMethod": "PUT", + "description": "Modifies an existing comment.", + "parameters": { + "part": { + "type": "string", + "description": "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.\n\nThe part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be updated.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "request": { + "$ref": "Comment" + }, + "response": { + "$ref": "Comment" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube.force-ssl" + ] + } + } + }, "guideCategories": { "methods": { "list": { @@ -7846,6 +8653,41 @@ } } }, + "videoAbuseReportReasons": { + "methods": { + "list": { + "id": "youtube.videoAbuseReportReasons.list", + "path": "videoAbuseReportReasons", + "httpMethod": "GET", + "description": "Returns a list of abuse reasons that can be used for reporting abusive videos.", + "parameters": { + "hl": { + "type": "string", + "description": "The hl parameter specifies the language that should be used for text values in the API response.", + "default": "en_US", + "location": "query" + }, + "part": { + "type": "string", + "description": "The part parameter specifies the videoCategory resource parts that the API response will include. Supported values are id and snippet.", + "required": true, + "location": "query" + } + }, + "parameterOrder": [ + "part" + ], + "response": { + "$ref": "VideoAbuseReportReasonListResponse" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube", + "https://www.googleapis.com/auth/youtube.force-ssl", + "https://www.googleapis.com/auth/youtube.readonly" + ] + } + } + }, "videoCategories": { "methods": { "list": { @@ -8163,6 +9005,27 @@ "https://www.googleapis.com/auth/youtubepartner" ] }, + "reportAbuse": { + "id": "youtube.videos.reportAbuse", + "path": "videos/reportAbuse", + "httpMethod": "POST", + "description": "Report abuse for a video.", + "parameters": { + "onBehalfOfContentOwner": { + "type": "string", + "description": "Note: This parameter is intended exclusively for YouTube content partners.\n\nThe onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.", + "location": "query" + } + }, + "request": { + "$ref": "VideoAbuseReport" + }, + "scopes": [ + "https://www.googleapis.com/auth/youtube", + "https://www.googleapis.com/auth/youtube.force-ssl", + "https://www.googleapis.com/auth/youtubepartner" + ] + }, "update": { "id": "youtube.videos.update", "path": "videos", diff --git a/gen/adexchangebuyer1d3-cli/Cargo.toml b/gen/adexchangebuyer1d3-cli/Cargo.toml index dcef81951a..57c9ab0108 100644 --- a/gen/adexchangebuyer1d3-cli/Cargo.toml +++ b/gen/adexchangebuyer1d3-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-adexchangebuyer1d3-cli" -version = "0.0.1+20150323" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/ad-exchange/buyer-rest" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/adexchangebuyer1d3-cli/mkdocs.yml b/gen/adexchangebuyer1d3-cli/mkdocs.yml index a7c8e97e51..f104b54d9a 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+20150323 +site_name: Ad Exchange Buyer v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/adexchangebuyer1d3-cli/src/cmn.rs +++ b/gen/adexchangebuyer1d3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/adexchangebuyer1d3-cli/src/main.rs b/gen/adexchangebuyer1d3-cli/src/main.rs index 163d251dfb..b8727b852b 100644 --- a/gen/adexchangebuyer1d3-cli/src/main.rs +++ b/gen/adexchangebuyer1d3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -52,6 +53,12 @@ Configuration: 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. "); mod cmn; @@ -76,7 +83,7 @@ impl Engine { let id: i32 = arg_from_str(&self.opt.arg_id, err, "", "integer"); let mut call = self.hub.accounts().get(id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -108,8 +115,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -120,7 +126,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -152,8 +158,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -162,11 +167,11 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -186,9 +191,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -231,8 +237,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -241,11 +246,11 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -265,9 +270,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -310,8 +316,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -323,7 +328,7 @@ impl Engine { let account_id: i32 = arg_from_str(&self.opt.arg_account_id, err, "", "integer"); let mut call = self.hub.billing_info().get(account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -355,8 +360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -367,7 +371,7 @@ impl Engine { -> Option { let mut call = self.hub.billing_info().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -399,8 +403,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -411,7 +414,7 @@ impl Engine { -> Option { let mut call = self.hub.budget().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -443,8 +446,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -453,10 +455,10 @@ impl Engine { fn _budget_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Budget = Default::default(); + let mut request = api::Budget::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -476,9 +478,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -518,8 +521,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -528,10 +530,10 @@ impl Engine { fn _budget_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Budget = Default::default(); + let mut request = api::Budget::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -551,9 +553,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -593,8 +596,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -606,7 +608,7 @@ impl Engine { let account_id: i32 = arg_from_str(&self.opt.arg_account_id, err, "", "integer"); let mut call = self.hub.creatives().get(account_id, &self.opt.arg_buyer_creative_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -638,8 +640,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -648,10 +649,10 @@ impl Engine { fn _creatives_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Creative = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -671,9 +672,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -686,9 +688,9 @@ impl Engine { match &field_name.to_string()[..] { "product-categories" => { if request.product_categories.is_none() { - request.product_categories = Some(Default::default()); + request.product_categories = Some(Default::default()); } - request.product_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "product-categories", "integer")); + request.product_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "product-categories", "integer")); }, "status" => { request.status = Some(value.unwrap_or("").to_string()); @@ -707,15 +709,15 @@ impl Engine { }, "attribute" => { if request.attribute.is_none() { - request.attribute = Some(Default::default()); + request.attribute = Some(Default::default()); } - request.attribute.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "attribute", "integer")); + request.attribute.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "attribute", "integer")); }, "restricted-categories" => { if request.restricted_categories.is_none() { - request.restricted_categories = Some(Default::default()); + request.restricted_categories = Some(Default::default()); } - request.restricted_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "restricted-categories", "integer")); + request.restricted_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "restricted-categories", "integer")); }, "height" => { request.height = Some(arg_from_str(value.unwrap_or("-0"), err, "height", "integer")); @@ -728,35 +730,35 @@ impl Engine { }, "advertiser-id" => { if request.advertiser_id.is_none() { - request.advertiser_id = Some(Default::default()); + request.advertiser_id = Some(Default::default()); } - request.advertiser_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.advertiser_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "buyer-creative-id" => { request.buyer_creative_id = Some(value.unwrap_or("").to_string()); }, "click-through-url" => { if request.click_through_url.is_none() { - request.click_through_url = Some(Default::default()); + request.click_through_url = Some(Default::default()); } - request.click_through_url.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.click_through_url.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "vendor-type" => { if request.vendor_type.is_none() { - request.vendor_type = Some(Default::default()); + request.vendor_type = Some(Default::default()); } - request.vendor_type.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "vendor-type", "integer")); + request.vendor_type.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "vendor-type", "integer")); }, "filtering-reasons.date" => { request_filtering_reasons_init(&mut request); - request.filtering_reasons.as_mut().unwrap().date = value.unwrap_or("").to_string(); + request.filtering_reasons.as_mut().unwrap().date = Some(value.unwrap_or("").to_string()); }, "sensitive-categories" => { request_filtering_reasons_init(&mut request); if request.sensitive_categories.is_none() { - request.sensitive_categories = Some(Default::default()); + request.sensitive_categories = Some(Default::default()); } - request.sensitive_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "sensitive-categories", "integer")); + request.sensitive_categories.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "sensitive-categories", "integer")); }, "account-id" => { request_filtering_reasons_init(&mut request); @@ -779,8 +781,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -791,7 +792,7 @@ impl Engine { -> Option { let mut call = self.hub.creatives().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "status-filter" => { call = call.status_filter(value.unwrap_or("")); @@ -838,8 +839,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -850,7 +850,7 @@ impl Engine { -> Option { let mut call = self.hub.direct_deals().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -882,8 +882,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -894,7 +893,7 @@ impl Engine { -> Option { let mut call = self.hub.direct_deals().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -926,8 +925,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -938,7 +936,7 @@ impl Engine { -> Option { let mut call = self.hub.performance_report().list(&self.opt.arg_account_id, &self.opt.arg_end_date_time, &self.opt.arg_start_date_time); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -976,8 +974,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -988,7 +985,7 @@ impl Engine { -> Option { let mut call = self.hub.pretargeting_config().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1019,7 +1016,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1030,7 +1026,7 @@ impl Engine { -> Option { let mut call = self.hub.pretargeting_config().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1062,8 +1058,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1072,10 +1067,10 @@ impl Engine { fn _pretargeting_config_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::PretargetingConfig = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1095,9 +1090,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1107,9 +1103,9 @@ impl Engine { }, "languages" => { if request.languages.is_none() { - request.languages = Some(Default::default()); + request.languages = Some(Default::default()); } - request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1119,93 +1115,93 @@ impl Engine { }, "excluded-geo-criteria-ids" => { if request.excluded_geo_criteria_ids.is_none() { - request.excluded_geo_criteria_ids = Some(Default::default()); + request.excluded_geo_criteria_ids = Some(Default::default()); } - request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "user-lists" => { if request.user_lists.is_none() { - request.user_lists = Some(Default::default()); + request.user_lists = Some(Default::default()); } - request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-verticals" => { if request.excluded_verticals.is_none() { - request.excluded_verticals = Some(Default::default()); + request.excluded_verticals = Some(Default::default()); } - request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "vendor-types" => { if request.vendor_types.is_none() { - request.vendor_types = Some(Default::default()); + request.vendor_types = Some(Default::default()); } - request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-content-labels" => { if request.excluded_content_labels.is_none() { - request.excluded_content_labels = Some(Default::default()); + request.excluded_content_labels = Some(Default::default()); } - request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "verticals" => { if request.verticals.is_none() { - request.verticals = Some(Default::default()); + request.verticals = Some(Default::default()); } - request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "platforms" => { if request.platforms.is_none() { - request.platforms = Some(Default::default()); + request.platforms = Some(Default::default()); } - request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-devices" => { if request.mobile_devices.is_none() { - request.mobile_devices = Some(Default::default()); + request.mobile_devices = Some(Default::default()); } - request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creative-type" => { if request.creative_type.is_none() { - request.creative_type = Some(Default::default()); + request.creative_type = Some(Default::default()); } - request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "geo-criteria-ids" => { if request.geo_criteria_ids.is_none() { - request.geo_criteria_ids = Some(Default::default()); + request.geo_criteria_ids = Some(Default::default()); } - request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-operating-system-versions" => { if request.mobile_operating_system_versions.is_none() { - request.mobile_operating_system_versions = Some(Default::default()); + request.mobile_operating_system_versions = Some(Default::default()); } - request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-carriers" => { if request.mobile_carriers.is_none() { - request.mobile_carriers = Some(Default::default()); + request.mobile_carriers = Some(Default::default()); } - request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "config-id" => { request.config_id = Some(value.unwrap_or("").to_string()); }, "excluded-user-lists" => { if request.excluded_user_lists.is_none() { - request.excluded_user_lists = Some(Default::default()); + request.excluded_user_lists = Some(Default::default()); } - request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "is-active" => { request.is_active = Some(arg_from_str(value.unwrap_or("false"), err, "is-active", "boolean")); }, "supported-creative-attributes" => { if request.supported_creative_attributes.is_none() { - request.supported_creative_attributes = Some(Default::default()); + request.supported_creative_attributes = Some(Default::default()); } - request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1224,8 +1220,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1236,7 +1231,7 @@ impl Engine { -> Option { let mut call = self.hub.pretargeting_config().list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1268,8 +1263,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1278,10 +1272,10 @@ impl Engine { fn _pretargeting_config_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::PretargetingConfig = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1301,9 +1295,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1313,9 +1308,9 @@ impl Engine { }, "languages" => { if request.languages.is_none() { - request.languages = Some(Default::default()); + request.languages = Some(Default::default()); } - request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1325,93 +1320,93 @@ impl Engine { }, "excluded-geo-criteria-ids" => { if request.excluded_geo_criteria_ids.is_none() { - request.excluded_geo_criteria_ids = Some(Default::default()); + request.excluded_geo_criteria_ids = Some(Default::default()); } - request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "user-lists" => { if request.user_lists.is_none() { - request.user_lists = Some(Default::default()); + request.user_lists = Some(Default::default()); } - request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-verticals" => { if request.excluded_verticals.is_none() { - request.excluded_verticals = Some(Default::default()); + request.excluded_verticals = Some(Default::default()); } - request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "vendor-types" => { if request.vendor_types.is_none() { - request.vendor_types = Some(Default::default()); + request.vendor_types = Some(Default::default()); } - request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-content-labels" => { if request.excluded_content_labels.is_none() { - request.excluded_content_labels = Some(Default::default()); + request.excluded_content_labels = Some(Default::default()); } - request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "verticals" => { if request.verticals.is_none() { - request.verticals = Some(Default::default()); + request.verticals = Some(Default::default()); } - request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "platforms" => { if request.platforms.is_none() { - request.platforms = Some(Default::default()); + request.platforms = Some(Default::default()); } - request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-devices" => { if request.mobile_devices.is_none() { - request.mobile_devices = Some(Default::default()); + request.mobile_devices = Some(Default::default()); } - request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creative-type" => { if request.creative_type.is_none() { - request.creative_type = Some(Default::default()); + request.creative_type = Some(Default::default()); } - request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "geo-criteria-ids" => { if request.geo_criteria_ids.is_none() { - request.geo_criteria_ids = Some(Default::default()); + request.geo_criteria_ids = Some(Default::default()); } - request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-operating-system-versions" => { if request.mobile_operating_system_versions.is_none() { - request.mobile_operating_system_versions = Some(Default::default()); + request.mobile_operating_system_versions = Some(Default::default()); } - request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-carriers" => { if request.mobile_carriers.is_none() { - request.mobile_carriers = Some(Default::default()); + request.mobile_carriers = Some(Default::default()); } - request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "config-id" => { request.config_id = Some(value.unwrap_or("").to_string()); }, "excluded-user-lists" => { if request.excluded_user_lists.is_none() { - request.excluded_user_lists = Some(Default::default()); + request.excluded_user_lists = Some(Default::default()); } - request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "is-active" => { request.is_active = Some(arg_from_str(value.unwrap_or("false"), err, "is-active", "boolean")); }, "supported-creative-attributes" => { if request.supported_creative_attributes.is_none() { - request.supported_creative_attributes = Some(Default::default()); + request.supported_creative_attributes = Some(Default::default()); } - request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1430,8 +1425,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1440,10 +1434,10 @@ impl Engine { fn _pretargeting_config_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::PretargetingConfig = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1463,9 +1457,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1475,9 +1470,9 @@ impl Engine { }, "languages" => { if request.languages.is_none() { - request.languages = Some(Default::default()); + request.languages = Some(Default::default()); } - request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1487,93 +1482,93 @@ impl Engine { }, "excluded-geo-criteria-ids" => { if request.excluded_geo_criteria_ids.is_none() { - request.excluded_geo_criteria_ids = Some(Default::default()); + request.excluded_geo_criteria_ids = Some(Default::default()); } - request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "user-lists" => { if request.user_lists.is_none() { - request.user_lists = Some(Default::default()); + request.user_lists = Some(Default::default()); } - request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-verticals" => { if request.excluded_verticals.is_none() { - request.excluded_verticals = Some(Default::default()); + request.excluded_verticals = Some(Default::default()); } - request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "vendor-types" => { if request.vendor_types.is_none() { - request.vendor_types = Some(Default::default()); + request.vendor_types = Some(Default::default()); } - request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.vendor_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "excluded-content-labels" => { if request.excluded_content_labels.is_none() { - request.excluded_content_labels = Some(Default::default()); + request.excluded_content_labels = Some(Default::default()); } - request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_content_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "verticals" => { if request.verticals.is_none() { - request.verticals = Some(Default::default()); + request.verticals = Some(Default::default()); } - request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.verticals.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "platforms" => { if request.platforms.is_none() { - request.platforms = Some(Default::default()); + request.platforms = Some(Default::default()); } - request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.platforms.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-devices" => { if request.mobile_devices.is_none() { - request.mobile_devices = Some(Default::default()); + request.mobile_devices = Some(Default::default()); } - request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_devices.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creative-type" => { if request.creative_type.is_none() { - request.creative_type = Some(Default::default()); + request.creative_type = Some(Default::default()); } - request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_type.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "geo-criteria-ids" => { if request.geo_criteria_ids.is_none() { - request.geo_criteria_ids = Some(Default::default()); + request.geo_criteria_ids = Some(Default::default()); } - request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.geo_criteria_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-operating-system-versions" => { if request.mobile_operating_system_versions.is_none() { - request.mobile_operating_system_versions = Some(Default::default()); + request.mobile_operating_system_versions = Some(Default::default()); } - request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_operating_system_versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mobile-carriers" => { if request.mobile_carriers.is_none() { - request.mobile_carriers = Some(Default::default()); + request.mobile_carriers = Some(Default::default()); } - request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.mobile_carriers.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "config-id" => { request.config_id = Some(value.unwrap_or("").to_string()); }, "excluded-user-lists" => { if request.excluded_user_lists.is_none() { - request.excluded_user_lists = Some(Default::default()); + request.excluded_user_lists = Some(Default::default()); } - request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.excluded_user_lists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "is-active" => { request.is_active = Some(arg_from_str(value.unwrap_or("false"), err, "is-active", "boolean")); }, "supported-creative-attributes" => { if request.supported_creative_attributes.is_none() { - request.supported_creative_attributes = Some(Default::default()); + request.supported_creative_attributes = Some(Default::default()); } - request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.supported_creative_attributes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1592,8 +1587,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1617,7 +1611,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_billing_info { + } + else if self.opt.cmd_billing_info { if self.opt.cmd_get { call_result = self._billing_info_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1625,7 +1620,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_budget { + } + else if self.opt.cmd_budget { if self.opt.cmd_get { call_result = self._budget_get(dry_run, &mut err); } else if self.opt.cmd_patch { @@ -1635,7 +1631,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_creatives { + } + else if self.opt.cmd_creatives { if self.opt.cmd_get { call_result = self._creatives_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -1645,7 +1642,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_direct_deals { + } + else if self.opt.cmd_direct_deals { if self.opt.cmd_get { call_result = self._direct_deals_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1653,13 +1651,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_performance_report { + } + else if self.opt.cmd_performance_report { if self.opt.cmd_list { call_result = self._performance_report_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_pretargeting_config { + } + else if self.opt.cmd_pretargeting_config { if self.opt.cmd_delete { call_result = self._pretargeting_config_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -1695,21 +1695,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "adexchangebuyer1d3-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "adexchangebuyer1d3-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "adexchangebuyer1d3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "adexchangebuyer1d3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AdExchangeBuyer::new(hyper::Client::new(), auth), + hub: api::AdExchangeBuyer::new(client, auth), }; match engine._doit(true) { @@ -1729,12 +1745,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/adexchangebuyer1d3/Cargo.toml b/gen/adexchangebuyer1d3/Cargo.toml index 8a9bd9012c..723a218acd 100644 --- a/gen/adexchangebuyer1d3/Cargo.toml +++ b/gen/adexchangebuyer1d3/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-adexchangebuyer1d3" -version = "0.1.5+20150323" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/ad-exchange/buyer-rest" diff --git a/gen/adexchangebuyer1d3/README.md b/gen/adexchangebuyer1d3/README.md index 16e67277fe..10cc0b9bf1 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+20150323*, where *20150323* 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.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*. 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). @@ -108,7 +108,7 @@ let mut hub = AdExchangeBuyer::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: PretargetingConfig = Default::default(); +let mut req = PretargetingConfig::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/adexchangebuyer1d3/src/cmn.rs b/gen/adexchangebuyer1d3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/adexchangebuyer1d3/src/cmn.rs +++ b/gen/adexchangebuyer1d3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/adexchangebuyer1d3/src/lib.rs b/gen/adexchangebuyer1d3/src/lib.rs index df728f13d9..8ef6652864 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+20150323*, where *20150323* 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.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*. //! //! 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). @@ -109,7 +109,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: PretargetingConfig = Default::default(); +//! let mut req = PretargetingConfig::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -284,7 +284,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PretargetingConfig = Default::default(); +/// let mut req = PretargetingConfig::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -372,10 +372,10 @@ impl<'a, C, A> AdExchangeBuyer #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PretargetingConfigExcludedPlacements { /// The value of the placement. Interpretation depends on the placement type, e.g. URL for a site placement, channel name for a channel placement, app id for a mobile app placement. - pub token: String, + pub token: Option, /// The type of the placement. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for PretargetingConfigExcludedPlacements {} @@ -389,9 +389,9 @@ impl Part for PretargetingConfigExcludedPlacements {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeDisapprovalReasons { /// The categorized reason for disapproval. - pub reason: String, + pub reason: Option, /// Additional details about the reason for disapproval. - pub details: Vec, + pub details: Option>, } impl NestedType for CreativeDisapprovalReasons {} @@ -453,24 +453,24 @@ impl ResponseResult for Account {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PretargetingConfigList { /// A list of pretargeting configs - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for PretargetingConfigList {} -/// The filtering reasons for the creative. If this feature is not enabled, please ask your technical account manager. Read-only. This field should not be set in requests. +/// The filtering reasons for the creative. Read-only. This field should not be set in requests. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeFilteringReasons { /// The date in ISO 8601 format for the data. The data is collected from 00:00:00 to 23:59:59 in PST. - pub date: String, + pub date: Option, /// The filtering reasons. - pub reasons: Vec, + pub reasons: Option>, } impl NestedType for CreativeFilteringReasons {} @@ -489,16 +489,16 @@ impl Part for CreativeFilteringReasons {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BillingInfo { /// Resource type. - pub kind: String, + pub kind: Option, /// A list of adgroup IDs associated with this particular account. These IDs may show up as part of a realtime bidding BidRequest, which indicates a bid request for this account. #[serde(rename="billingId")] - pub billing_id: Vec, + pub billing_id: Option>, /// Account id. #[serde(rename="accountId")] - pub account_id: i32, + pub account_id: Option, /// Account name. #[serde(rename="accountName")] - pub account_name: String, + pub account_name: Option, } impl ResponseResult for BillingInfo {} @@ -516,10 +516,10 @@ impl ResponseResult for BillingInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectDealsList { /// Resource type. - pub kind: String, + pub kind: Option, /// A list of direct deals relevant for your account. #[serde(rename="directDeals")] - pub direct_deals: Vec, + pub direct_deals: Option>, } impl ResponseResult for DirectDealsList {} @@ -537,9 +537,9 @@ impl ResponseResult for DirectDealsList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountsList { /// A list of accounts. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for AccountsList {} @@ -558,11 +558,11 @@ impl ResponseResult for AccountsList {} pub struct CreativesList { /// Continuation token used to page through creatives. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of creatives. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for CreativesList {} @@ -661,7 +661,7 @@ pub struct Creative { /// All vendor types for the ads that may be shown from this snippet. #[serde(rename="vendorType")] pub vendor_type: Option>, - /// The filtering reasons for the creative. If this feature is not enabled, please ask your technical account manager. Read-only. This field should not be set in requests. + /// The filtering reasons for the creative. Read-only. This field should not be set in requests. #[serde(rename="filteringReasons")] pub filtering_reasons: Option, /// The reasons for disapproval, if any. Note that not all disapproval reasons may be categorized, so it is possible for the creative to have a status of DISAPPROVED with an empty list for disapproval_reasons. In this case, please reach out to your TAM to help debug the issue. Read-only. This field should not be set in requests. @@ -689,10 +689,10 @@ impl ResponseResult for Creative {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PerformanceReportList { /// Resource type. - pub kind: String, + pub kind: Option, /// A list of performance reports relevant for the account. #[serde(rename="performanceReport")] - pub performance_report: Vec, + pub performance_report: Option>, } impl ResponseResult for PerformanceReportList {} @@ -706,10 +706,10 @@ impl ResponseResult for PerformanceReportList {} pub struct CreativeFilteringReasonsReasons { /// The number of times the creative was filtered for the status. The count is aggregated across all publishers on the exchange. #[serde(rename="filteringCount")] - pub filtering_count: i64, + pub filtering_count: Option, /// The filtering status code. Please refer to the creative-status-codes.txt file for different statuses. #[serde(rename="filteringStatus")] - pub filtering_status: i32, + pub filtering_status: Option, } impl NestedType for CreativeFilteringReasonsReasons {} @@ -723,10 +723,10 @@ impl Part for CreativeFilteringReasonsReasons {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PretargetingConfigPlacements { /// The value of the placement. Interpretation depends on the placement type, e.g. URL for a site placement, channel name for a channel placement, app id for a mobile app placement. - pub token: String, + pub token: Option, /// The type of the placement. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for PretargetingConfigPlacements {} @@ -740,9 +740,9 @@ impl Part for PretargetingConfigPlacements {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PretargetingConfigDimensions { /// Width in pixels. - pub width: String, + pub width: Option, /// Height in pixels. - pub height: String, + pub height: Option, } impl NestedType for PretargetingConfigDimensions {} @@ -757,49 +757,49 @@ impl Part for PretargetingConfigDimensions {} pub struct PerformanceReport { /// Average QPS for cookie matcher operations. #[serde(rename="cookieMatcherStatusRate")] - pub cookie_matcher_status_rate: Vec, + pub cookie_matcher_status_rate: Option>, /// Rate of various prefiltering statuses per match. Please refer to the callout-status-codes.txt file for different statuses. #[serde(rename="calloutStatusRate")] - pub callout_status_rate: Vec, + pub callout_status_rate: Option>, /// Average QPS for hosted match operations. #[serde(rename="hostedMatchStatusRate")] - pub hosted_match_status_rate: Vec, + pub hosted_match_status_rate: Option>, /// The unix timestamp of the starting time of this performance data. - pub timestamp: String, + pub timestamp: Option, /// The 50th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report. #[serde(rename="latency50thPercentile")] - pub latency50th_percentile: f64, + pub latency50th_percentile: Option, /// The 85th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report. #[serde(rename="latency85thPercentile")] - pub latency85th_percentile: f64, + pub latency85th_percentile: Option, /// Average QPS for pixel match responses from clients. #[serde(rename="pixelMatchResponses")] - pub pixel_match_responses: f64, + pub pixel_match_responses: Option, /// Rate of ads with a given status. Please refer to the creative-status-codes.txt file for different statuses. #[serde(rename="creativeStatusRate")] - pub creative_status_rate: Vec, + pub creative_status_rate: Option>, /// The 95th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report. #[serde(rename="latency95thPercentile")] - pub latency95th_percentile: f64, + pub latency95th_percentile: Option, /// Rate of various quota account statuses per quota check. #[serde(rename="noQuotaInRegion")] - pub no_quota_in_region: f64, + pub no_quota_in_region: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// The trading location of this data. - pub region: String, + pub region: Option, /// The configured quota limits for this account. #[serde(rename="quotaConfiguredLimit")] - pub quota_configured_limit: f64, + pub quota_configured_limit: Option, /// Rate of various quota account statuses per quota check. #[serde(rename="outOfQuota")] - pub out_of_quota: f64, + pub out_of_quota: Option, /// The throttled quota limits for this account. #[serde(rename="quotaThrottledLimit")] - pub quota_throttled_limit: f64, + pub quota_throttled_limit: Option, /// Average QPS for pixel match requests from clients. #[serde(rename="pixelMatchRequests")] - pub pixel_match_requests: f64, + pub pixel_match_requests: Option, } impl Part for PerformanceReport {} @@ -812,9 +812,9 @@ impl Part for PerformanceReport {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeCorrections { /// The type of correction that was applied to the creative. - pub reason: String, + pub reason: Option, /// Additional details about the correction. - pub details: Vec, + pub details: Option>, } impl NestedType for CreativeCorrections {} @@ -833,9 +833,9 @@ impl Part for CreativeCorrections {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BillingInfoList { /// A list of billing info relevant for your account. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for BillingInfoList {} @@ -854,37 +854,37 @@ impl ResponseResult for BillingInfoList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectDeal { /// The name of the advertiser this deal is for. - pub advertiser: String, + pub advertiser: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// Deal name. - pub name: String, + pub name: Option, /// The currency code that applies to the fixed_cpm value. If not set then assumed to be USD. #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, /// The account id of the buyer this deal is for. #[serde(rename="accountId")] - pub account_id: i32, + pub account_id: Option, /// The fixed price for this direct deal. In cpm micros of currency according to currency_code. If set, then this deal is eligible for the fixed price tier of buying (highest priority, pay exactly the configured fixed price). #[serde(rename="fixedCpm")] - pub fixed_cpm: String, + pub fixed_cpm: Option, /// Start time for when this deal becomes active. If not set then this deal is active immediately upon creation. In seconds since the epoch. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option, /// If true, the publisher has opted to have their blocks ignored when a creative is bid with for this deal. #[serde(rename="publisherBlocksOverriden")] - pub publisher_blocks_overriden: bool, + pub publisher_blocks_overriden: Option, /// End time for when this deal stops being active. If not set then this deal is valid until manually disabled by the publisher. In seconds since the epoch. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// The name of the publisher offering this direct deal. #[serde(rename="sellerNetwork")] - pub seller_network: String, + pub seller_network: Option, /// Deal id. - pub id: String, + pub id: Option, /// The minimum price for this direct deal. In cpm micros of currency according to currency_code. If set, then this deal is eligible for the private exchange tier of buying (below fixed price priority, run as a second price auction). #[serde(rename="privateExchangeMinCpm")] - pub private_exchange_min_cpm: String, + pub private_exchange_min_cpm: Option, } impl Resource for DirectDeal {} @@ -981,16 +981,16 @@ impl ResponseResult for PretargetingConfig {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountBidderLocation { /// The URL to which the Ad Exchange will send bid requests. - pub url: String, + pub url: Option, /// The geographical region the Ad Exchange should send requests from. Only used by some quota systems, but always setting the value is recommended. Allowed values: /// - ASIA /// - EUROPE /// - US_EAST /// - US_WEST - pub region: String, + pub region: Option, /// The maximum queries per second the Ad Exchange will send. #[serde(rename="maximumQps")] - pub maximum_qps: i32, + pub maximum_qps: Option, } impl NestedType for AccountBidderLocation {} @@ -1781,16 +1781,20 @@ impl<'a, C, A> BillingInfoGetCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1985,16 +1989,20 @@ impl<'a, C, A> BillingInfoListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2179,16 +2187,20 @@ impl<'a, C, A> DirectDealListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2399,16 +2411,20 @@ impl<'a, C, A> DirectDealGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2548,7 +2564,7 @@ impl<'a, C, A> DirectDealGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Budget = Default::default(); +/// let mut req = Budget::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2642,16 +2658,20 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2814,7 +2834,7 @@ impl<'a, C, A> BudgetPatchCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Budget = Default::default(); +/// let mut req = Budget::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2908,16 +2928,20 @@ impl<'a, C, A> BudgetUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3163,16 +3187,20 @@ impl<'a, C, A> BudgetGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3322,7 +3350,7 @@ impl<'a, C, A> BudgetGetCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Creative = Default::default(); +/// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3388,16 +3416,20 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3628,16 +3660,20 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3887,16 +3923,20 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4046,7 +4086,7 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4138,16 +4178,20 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4300,7 +4344,7 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4392,16 +4436,20 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4609,16 +4657,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4829,16 +4881,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5049,16 +5105,20 @@ impl<'a, C, A> PerformanceReportListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5314,16 +5374,20 @@ impl<'a, C, A> PretargetingConfigDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5463,7 +5527,7 @@ impl<'a, C, A> PretargetingConfigDeleteCall<'a, C, A> where C: BorrowMut PretargetingConfigPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5812,16 +5880,20 @@ impl<'a, C, A> PretargetingConfigGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5971,7 +6043,7 @@ impl<'a, C, A> PretargetingConfigGetCall<'a, C, A> where C: BorrowMut PretargetingConfigInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6306,16 +6382,20 @@ impl<'a, C, A> PretargetingConfigListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6455,7 +6535,7 @@ impl<'a, C, A> PretargetingConfigListCall<'a, C, A> where C: BorrowMut PretargetingConfigUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/adexchangeseller2-cli/Cargo.toml b/gen/adexchangeseller2-cli/Cargo.toml index 45464eb358..7dcf38dbb0 100644 --- a/gen/adexchangeseller2-cli/Cargo.toml +++ b/gen/adexchangeseller2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-adexchangeseller2-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/ad-exchange/seller-rest/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/adexchangeseller2-cli/src/cmn.rs b/gen/adexchangeseller2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/adexchangeseller2-cli/src/cmn.rs +++ b/gen/adexchangeseller2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/adexchangeseller2-cli/src/main.rs b/gen/adexchangeseller2-cli/src/main.rs index 7ed33e071d..673318ec92 100644 --- a/gen/adexchangeseller2-cli/src/main.rs +++ b/gen/adexchangeseller2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -45,6 +46,12 @@ Configuration: 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. "); mod cmn; @@ -68,7 +75,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adclients_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -106,8 +113,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -118,7 +124,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().alerts_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "locale" => { call = call.locale(value.unwrap_or("")); @@ -153,8 +159,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -165,7 +170,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().customchannels_get(&self.opt.arg_account_id, &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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -197,8 +202,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -209,7 +213,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().customchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -247,8 +251,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -259,7 +262,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().get(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -291,8 +294,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -303,7 +305,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -341,8 +343,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -353,7 +354,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().metadata_dimensions_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -385,8 +386,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -397,7 +397,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().metadata_metrics_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -429,8 +429,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -441,7 +440,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().preferreddeals_get(&self.opt.arg_account_id, &self.opt.arg_deal_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -473,8 +472,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -485,7 +483,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().preferreddeals_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -517,8 +515,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -530,7 +527,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.accounts().reports_generate(&self.opt.arg_account_id, &self.opt.arg_start_date, &self.opt.arg_end_date); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -586,9 +583,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -602,7 +598,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().reports_saved_generate(&self.opt.arg_account_id, &self.opt.arg_saved_report_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -643,8 +639,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -655,7 +650,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().reports_saved_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -693,8 +688,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -705,7 +699,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().urlchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -743,8 +737,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -808,21 +801,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "adexchangeseller2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "adexchangeseller2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "adexchangeseller2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "adexchangeseller2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AdExchangeSeller::new(hyper::Client::new(), auth), + hub: api::AdExchangeSeller::new(client, auth), }; match engine._doit(true) { @@ -842,12 +851,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/adexchangeseller2/Cargo.toml b/gen/adexchangeseller2/Cargo.toml index 6df6535826..42ecaeed11 100644 --- a/gen/adexchangeseller2/Cargo.toml +++ b/gen/adexchangeseller2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-adexchangeseller2" version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/ad-exchange/seller-rest/" diff --git a/gen/adexchangeseller2/src/cmn.rs b/gen/adexchangeseller2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/adexchangeseller2/src/cmn.rs +++ b/gen/adexchangeseller2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/adexchangeseller2/src/lib.rs b/gen/adexchangeseller2/src/lib.rs index 60e49a4ac9..a8ab98234c 100644 --- a/gen/adexchangeseller2/src/lib.rs +++ b/gen/adexchangeseller2/src/lib.rs @@ -368,13 +368,13 @@ impl<'a, C, A> AdExchangeSeller pub struct UrlChannels { /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The URL channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#urlChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for UrlChannels {} @@ -405,11 +405,11 @@ impl ResponseResult for UrlChannels {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Account { /// Kind of resource this is, in this case adexchangeseller#account. - pub kind: String, + pub kind: Option, /// Unique identifier of this account. - pub id: String, + pub id: Option, /// Name of this account. - pub name: String, + pub name: Option, } impl Resource for Account {} @@ -429,13 +429,13 @@ impl ResponseResult for Account {} pub struct CustomChannels { /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The custom channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#customChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for CustomChannels {} @@ -453,9 +453,9 @@ impl ResponseResult for CustomChannels {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Alerts { /// The alerts returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#alerts. - pub kind: String, + pub kind: Option, } impl ResponseResult for Alerts {} @@ -468,11 +468,11 @@ impl ResponseResult for Alerts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SavedReport { /// Kind of resource this is, in this case adexchangeseller#savedReport. - pub kind: String, + pub kind: Option, /// Unique identifier of this saved report. - pub id: String, + pub id: Option, /// This saved report's name. - pub name: String, + pub name: Option, } impl Part for SavedReport {} @@ -486,17 +486,17 @@ impl Part for SavedReport {} pub struct AdClient { /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension. #[serde(rename="productCode")] - pub product_code: String, + pub product_code: Option, /// Kind of resource this is, in this case adexchangeseller#adClient. - pub kind: String, + pub kind: Option, /// Unique identifier of this ad client. - pub id: String, + pub id: Option, /// Whether this ad client is opted in to ARC. #[serde(rename="arcOptIn")] - pub arc_opt_in: bool, + pub arc_opt_in: Option, /// Whether this ad client supports being reported on. #[serde(rename="supportsReporting")] - pub supports_reporting: bool, + pub supports_reporting: Option, } impl Part for AdClient {} @@ -514,9 +514,9 @@ impl Part for AdClient {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PreferredDeals { /// The preferred deals returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#preferredDeals. - pub kind: String, + pub kind: Option, } impl ResponseResult for PreferredDeals {} @@ -530,23 +530,23 @@ impl ResponseResult for PreferredDeals {} pub struct ReportingMetadataEntry { /// The names of the metrics which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted. #[serde(rename="requiredMetrics")] - pub required_metrics: Vec, + pub required_metrics: Option>, /// Kind of resource this is, in this case adexchangeseller#reportingMetadataEntry. - pub kind: String, + pub kind: Option, /// The names of the metrics the dimension or metric this reporting metadata entry describes is compatible with. #[serde(rename="compatibleMetrics")] - pub compatible_metrics: Vec, + pub compatible_metrics: Option>, /// For metrics this is a list of dimension IDs which the metric is compatible with, for dimensions it is a list of compatibility groups the dimension belongs to. #[serde(rename="compatibleDimensions")] - pub compatible_dimensions: Vec, + pub compatible_dimensions: Option>, /// Unique identifier of this reporting metadata entry, corresponding to the name of the appropriate dimension or metric. - pub id: String, + pub id: Option, /// The names of the dimensions which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted. #[serde(rename="requiredDimensions")] - pub required_dimensions: Vec, + pub required_dimensions: Option>, /// The codes of the projects supported by the dimension or metric this reporting metadata entry describes. #[serde(rename="supportedProducts")] - pub supported_products: Vec, + pub supported_products: Option>, } impl Part for ReportingMetadataEntry {} @@ -559,15 +559,15 @@ impl Part for ReportingMetadataEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomChannelTargetingInfo { /// The external description of the channel. - pub description: String, + pub description: Option, /// The language of the sites ads will be displayed on. #[serde(rename="siteLanguage")] - pub site_language: String, + pub site_language: Option, /// The locations in which ads appear. (Only valid for content and mobile content ads). Acceptable values for content ads are: TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT, MULTIPLE_LOCATIONS. Acceptable values for mobile content ads are: TOP, MIDDLE, BOTTOM, MULTIPLE_LOCATIONS. - pub location: String, + pub location: Option, /// The name used to describe this channel externally. #[serde(rename="adsAppearOn")] - pub ads_appear_on: String, + pub ads_appear_on: Option, } impl NestedType for CustomChannelTargetingInfo {} @@ -587,9 +587,9 @@ impl Part for CustomChannelTargetingInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metadata { /// no description provided - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#metadata. - pub kind: String, + pub kind: Option, } impl ResponseResult for Metadata {} @@ -602,12 +602,12 @@ impl ResponseResult for Metadata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlChannel { /// Kind of resource this is, in this case adexchangeseller#urlChannel. - pub kind: String, + pub kind: Option, /// Unique identifier of this URL channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home #[serde(rename="urlPattern")] - pub url_pattern: String, + pub url_pattern: Option, } impl Part for UrlChannel {} @@ -626,13 +626,13 @@ impl Part for UrlChannel {} pub struct AdClients { /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The ad clients returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#adClients. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for AdClients {} @@ -650,27 +650,27 @@ impl ResponseResult for AdClients {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PreferredDeal { /// Kind of resource this is, in this case adexchangeseller#preferredDeal. - pub kind: String, + pub kind: Option, /// The name of the buyer network this deal is for. #[serde(rename="buyerNetworkName")] - pub buyer_network_name: String, + pub buyer_network_name: Option, /// The currency code that applies to the fixed_cpm value. If not set then assumed to be USD. #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, /// The name of the advertiser this deal is for. #[serde(rename="advertiserName")] - pub advertiser_name: String, + pub advertiser_name: Option, /// The fixed price for this preferred deal. In cpm micros of currency according to currencyCode. If set, then this preferred deal is eligible for the fixed price tier of buying (highest priority, pay exactly the configured fixed price). #[serde(rename="fixedCpm")] - pub fixed_cpm: String, + pub fixed_cpm: Option, /// Time when this deal becomes active in seconds since the epoch (GMT). If not set then this deal is active immediately upon creation. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option, /// Time when this deal stops being active in seconds since the epoch (GMT). If not set then this deal is valid until manually disabled by the publisher. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// Unique identifier of this preferred deal. - pub id: String, + pub id: Option, } impl ResponseResult for PreferredDeal {} @@ -689,13 +689,13 @@ impl ResponseResult for PreferredDeal {} pub struct SavedReports { /// Continuation token used to page through saved reports. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The saved reports returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#savedReports. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for SavedReports {} @@ -708,12 +708,12 @@ impl ResponseResult for SavedReports {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportHeaders { /// The currency of this column. Only present if the header type is METRIC_CURRENCY. - pub currency: String, + pub currency: Option, /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The name of the header. - pub name: String, + pub name: Option, } impl NestedType for ReportHeaders {} @@ -727,16 +727,16 @@ impl Part for ReportHeaders {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Alert { /// Unique identifier of this alert. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// Kind of resource this is, in this case adexchangeseller#alert. - pub kind: String, + pub kind: Option, /// Type of this alert. Possible values: SELF_HOLD, MIGRATED_TO_BILLING3, ADDRESS_PIN_VERIFICATION, PHONE_PIN_VERIFICATION, CORPORATE_ENTITY, GRAYLISTED_PUBLISHER, API_HOLD. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The localized alert message. - pub message: String, + pub message: Option, /// Severity of this alert. Possible values: INFO, WARNING, SEVERE. - pub severity: String, + pub severity: Option, } impl Part for Alert {} @@ -755,13 +755,13 @@ impl Part for Alert {} pub struct Accounts { /// Continuation token used to page through accounts. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The accounts returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adexchangeseller#accounts. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for Accounts {} @@ -780,20 +780,20 @@ impl ResponseResult for Accounts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request. - pub headers: Vec, + pub headers: Option>, /// Kind this is, in this case adexchangeseller#report. - pub kind: String, + pub kind: Option, /// The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request. The dimension cells contain strings, and the metric cells contain numbers. - pub rows: Vec>, + pub rows: Option>>, /// The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit. #[serde(rename="totalMatchedRows")] - pub total_matched_rows: String, + pub total_matched_rows: Option, /// Any warnings associated with generation of the report. - pub warnings: Vec, + pub warnings: Option>, /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub averages: Vec, + pub averages: Option>, /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub totals: Vec, + pub totals: Option>, } impl ResponseResult for Report {} @@ -811,16 +811,16 @@ impl ResponseResult for Report {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomChannel { /// Kind of resource this is, in this case adexchangeseller#customChannel. - pub kind: String, + pub kind: Option, /// Code of this custom channel, not necessarily unique across ad clients. - pub code: String, + pub code: Option, /// The targeting information of this custom channel, if activated. #[serde(rename="targetingInfo")] - pub targeting_info: CustomChannelTargetingInfo, + pub targeting_info: Option, /// Unique identifier of this custom channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// Name of this custom channel. - pub name: String, + pub name: Option, } impl ResponseResult for CustomChannel {} @@ -1273,16 +1273,20 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1534,16 +1538,20 @@ impl<'a, C, A> AccountMetadataMetricListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1840,16 +1848,20 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2155,16 +2167,20 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2419,16 +2435,20 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2665,16 +2685,20 @@ impl<'a, C, A> AccountPreferreddealGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2915,16 +2939,20 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3159,16 +3187,20 @@ impl<'a, C, A> AccountMetadataDimensionListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3393,16 +3425,20 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3655,16 +3691,20 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3893,16 +3933,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4132,16 +4176,20 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4369,16 +4417,20 @@ impl<'a, C, A> AccountPreferreddealListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4599,16 +4651,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/admin1_directory-cli/Cargo.toml b/gen/admin1_directory-cli/Cargo.toml deleted file mode 100644 index 4aba0b2aef..0000000000 --- a/gen/admin1_directory-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-admin1_directory-cli" -version = "0.0.1+20150309" -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" -homepage = "https://developers.google.com/admin-sdk/directory/" -documentation = "http://byron.github.io/google-apis-rs/google_admin1_directory_cli" -license = "MIT" -keywords = ["admin", "google", "cli"] - -[[bin]] -name = "admin1-directory" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-admin1_directory] -path = "../admin1_directory" diff --git a/gen/admin1_directory-cli/README.md b/gen/admin1_directory-cli/README.md deleted file mode 100644 index ee5759b0f6..0000000000 --- a/gen/admin1_directory-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO ADMIN:DIRECTORY_V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/admin1_directory-cli/mkdocs.yml b/gen/admin1_directory-cli/mkdocs.yml deleted file mode 100644 index f5a2db0c20..0000000000 --- a/gen/admin1_directory-cli/mkdocs.yml +++ /dev/null @@ -1,83 +0,0 @@ -site_name: directory v0.0.1+20150309 -site_url: http://byron.github.io/google-apis-rs/google-admin1_directory-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_directory-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['asps_delete.md', 'Asps', 'Delete'] -- ['asps_get.md', 'Asps', 'Get'] -- ['asps_list.md', 'Asps', 'List'] -- ['channels_stop.md', 'Channels', 'Stop'] -- ['chromeosdevices_get.md', 'Chromeosdevices', 'Get'] -- ['chromeosdevices_list.md', 'Chromeosdevices', 'List'] -- ['chromeosdevices_patch.md', 'Chromeosdevices', 'Patch'] -- ['chromeosdevices_update.md', 'Chromeosdevices', 'Update'] -- ['groups_aliases-delete.md', 'Groups', 'Aliases Delete'] -- ['groups_aliases-insert.md', 'Groups', 'Aliases Insert'] -- ['groups_aliases-list.md', 'Groups', 'Aliases List'] -- ['groups_delete.md', 'Groups', 'Delete'] -- ['groups_get.md', 'Groups', 'Get'] -- ['groups_insert.md', 'Groups', 'Insert'] -- ['groups_list.md', 'Groups', 'List'] -- ['groups_patch.md', 'Groups', 'Patch'] -- ['groups_update.md', 'Groups', 'Update'] -- ['members_delete.md', 'Members', 'Delete'] -- ['members_get.md', 'Members', 'Get'] -- ['members_insert.md', 'Members', 'Insert'] -- ['members_list.md', 'Members', 'List'] -- ['members_patch.md', 'Members', 'Patch'] -- ['members_update.md', 'Members', 'Update'] -- ['mobiledevices_action.md', 'Mobiledevices', 'Action'] -- ['mobiledevices_delete.md', 'Mobiledevices', 'Delete'] -- ['mobiledevices_get.md', 'Mobiledevices', 'Get'] -- ['mobiledevices_list.md', 'Mobiledevices', 'List'] -- ['notifications_delete.md', 'Notifications', 'Delete'] -- ['notifications_get.md', 'Notifications', 'Get'] -- ['notifications_list.md', 'Notifications', 'List'] -- ['notifications_patch.md', 'Notifications', 'Patch'] -- ['notifications_update.md', 'Notifications', 'Update'] -- ['orgunits_delete.md', 'Orgunits', 'Delete'] -- ['orgunits_get.md', 'Orgunits', 'Get'] -- ['orgunits_insert.md', 'Orgunits', 'Insert'] -- ['orgunits_list.md', 'Orgunits', 'List'] -- ['orgunits_patch.md', 'Orgunits', 'Patch'] -- ['orgunits_update.md', 'Orgunits', 'Update'] -- ['schemas_delete.md', 'Schemas', 'Delete'] -- ['schemas_get.md', 'Schemas', 'Get'] -- ['schemas_insert.md', 'Schemas', 'Insert'] -- ['schemas_list.md', 'Schemas', 'List'] -- ['schemas_patch.md', 'Schemas', 'Patch'] -- ['schemas_update.md', 'Schemas', 'Update'] -- ['tokens_delete.md', 'Tokens', 'Delete'] -- ['tokens_get.md', 'Tokens', 'Get'] -- ['tokens_list.md', 'Tokens', 'List'] -- ['users_aliases-delete.md', 'Users', 'Aliases Delete'] -- ['users_aliases-insert.md', 'Users', 'Aliases Insert'] -- ['users_aliases-list.md', 'Users', 'Aliases List'] -- ['users_aliases-watch.md', 'Users', 'Aliases Watch'] -- ['users_delete.md', 'Users', 'Delete'] -- ['users_get.md', 'Users', 'Get'] -- ['users_insert.md', 'Users', 'Insert'] -- ['users_list.md', 'Users', 'List'] -- ['users_make-admin.md', 'Users', 'Make Admin'] -- ['users_patch.md', 'Users', 'Patch'] -- ['users_photos-delete.md', 'Users', 'Photos Delete'] -- ['users_photos-get.md', 'Users', 'Photos Get'] -- ['users_photos-patch.md', 'Users', 'Photos Patch'] -- ['users_photos-update.md', 'Users', 'Photos Update'] -- ['users_undelete.md', 'Users', 'Undelete'] -- ['users_update.md', 'Users', 'Update'] -- ['users_watch.md', 'Users', 'Watch'] -- ['verification-codes_generate.md', 'Verification Codes', 'Generate'] -- ['verification-codes_invalidate.md', 'Verification Codes', 'Invalidate'] -- ['verification-codes_list.md', 'Verification Codes', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/admin1_directory-cli/src/cmn.rs b/gen/admin1_directory-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/admin1_directory-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/admin1_directory-cli/src/main.rs b/gen/admin1_directory-cli/src/main.rs deleted file mode 100644 index 750712e1ea..0000000000 --- a/gen/admin1_directory-cli/src/main.rs +++ /dev/null @@ -1,4769 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_admin1_directory as api; - -use std::env; -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 --help - -All documentation details can be found TODO: - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Directory>, -} - - -impl Engine { - fn _asps_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let code_id: i32 = arg_from_str(&self.opt.arg_code_id, err, "", "integer"); - let mut call = self.hub.asps().delete(&self.opt.arg_user_key, code_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _asps_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let code_id: i32 = arg_from_str(&self.opt.arg_code_id, err, "", "integer"); - let mut call = self.hub.asps().get(&self.opt.arg_user_key, code_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _asps_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.asps().list(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Channel = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _chromeosdevices_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.chromeosdevices().get(&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); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _chromeosdevices_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.chromeosdevices().list(&self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "sort-order" => { - call = call.sort_order(value.unwrap_or("")); - }, - "query" => { - call = call.query(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "order-by" => { - call = call.order_by(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _chromeosdevices_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::ChromeOsDevice = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "mac-address" => { - request.mac_address = Some(value.unwrap_or("").to_string()); - }, - "last-sync" => { - request.last_sync = Some(value.unwrap_or("").to_string()); - }, - "order-number" => { - request.order_number = Some(value.unwrap_or("").to_string()); - }, - "annotated-user" => { - request.annotated_user = Some(value.unwrap_or("").to_string()); - }, - "firmware-version" => { - request.firmware_version = Some(value.unwrap_or("").to_string()); - }, - "boot-mode" => { - request.boot_mode = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "support-end-date" => { - request.support_end_date = Some(value.unwrap_or("").to_string()); - }, - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "will-auto-renew" => { - request.will_auto_renew = Some(arg_from_str(value.unwrap_or("false"), err, "will-auto-renew", "boolean")); - }, - "ethernet-mac-address" => { - request.ethernet_mac_address = Some(value.unwrap_or("").to_string()); - }, - "meid" => { - request.meid = Some(value.unwrap_or("").to_string()); - }, - "annotated-location" => { - request.annotated_location = Some(value.unwrap_or("").to_string()); - }, - "device-id" => { - request.device_id = Some(value.unwrap_or("").to_string()); - }, - "platform-version" => { - request.platform_version = Some(value.unwrap_or("").to_string()); - }, - "os-version" => { - request.os_version = Some(value.unwrap_or("").to_string()); - }, - "last-enrollment-time" => { - request.last_enrollment_time = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "serial-number" => { - request.serial_number = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "model" => { - request.model = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _chromeosdevices_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::ChromeOsDevice = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "mac-address" => { - request.mac_address = Some(value.unwrap_or("").to_string()); - }, - "last-sync" => { - request.last_sync = Some(value.unwrap_or("").to_string()); - }, - "order-number" => { - request.order_number = Some(value.unwrap_or("").to_string()); - }, - "annotated-user" => { - request.annotated_user = Some(value.unwrap_or("").to_string()); - }, - "firmware-version" => { - request.firmware_version = Some(value.unwrap_or("").to_string()); - }, - "boot-mode" => { - request.boot_mode = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "support-end-date" => { - request.support_end_date = Some(value.unwrap_or("").to_string()); - }, - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "will-auto-renew" => { - request.will_auto_renew = Some(arg_from_str(value.unwrap_or("false"), err, "will-auto-renew", "boolean")); - }, - "ethernet-mac-address" => { - request.ethernet_mac_address = Some(value.unwrap_or("").to_string()); - }, - "meid" => { - request.meid = Some(value.unwrap_or("").to_string()); - }, - "annotated-location" => { - request.annotated_location = Some(value.unwrap_or("").to_string()); - }, - "device-id" => { - request.device_id = Some(value.unwrap_or("").to_string()); - }, - "platform-version" => { - request.platform_version = Some(value.unwrap_or("").to_string()); - }, - "os-version" => { - request.os_version = Some(value.unwrap_or("").to_string()); - }, - "last-enrollment-time" => { - request.last_enrollment_time = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "serial-number" => { - request.serial_number = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "model" => { - request.model = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_aliases_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.groups().aliases_delete(&self.opt.arg_group_key, &self.opt.arg_alias); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _groups_aliases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Alias = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_aliases_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.groups().aliases_list(&self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.groups().delete(&self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _groups_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.groups().get(&self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Group = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "admin-created" => { - request.admin_created = Some(arg_from_str(value.unwrap_or("false"), err, "admin-created", "boolean")); - }, - "direct-members-count" => { - request.direct_members_count = Some(arg_from_str(value.unwrap_or("-0"), err, "direct-members-count", "int64")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.groups().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "user-key" => { - call = call.user_key(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")); - }, - "domain" => { - call = call.domain(value.unwrap_or("")); - }, - "customer" => { - call = call.customer(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Group = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "admin-created" => { - request.admin_created = Some(arg_from_str(value.unwrap_or("false"), err, "admin-created", "boolean")); - }, - "direct-members-count" => { - request.direct_members_count = Some(arg_from_str(value.unwrap_or("-0"), err, "direct-members-count", "int64")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Group = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "admin-created" => { - request.admin_created = Some(arg_from_str(value.unwrap_or("false"), err, "admin-created", "boolean")); - }, - "direct-members-count" => { - request.direct_members_count = Some(arg_from_str(value.unwrap_or("-0"), err, "direct-members-count", "int64")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _members_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.members().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _members_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.members().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _members_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Member = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _members_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.members().list(&self.opt.arg_group_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "roles" => { - call = call.roles(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _members_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Member = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _members_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Member = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _mobiledevices_action(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::MobileDeviceAction = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "action" => { - request.action = 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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _mobiledevices_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.mobiledevices().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _mobiledevices_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.mobiledevices().get(&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); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _mobiledevices_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.mobiledevices().list(&self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "sort-order" => { - call = call.sort_order(value.unwrap_or("")); - }, - "query" => { - call = call.query(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "order-by" => { - call = call.order_by(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _notifications_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.notifications().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _notifications_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.notifications().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _notifications_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.notifications().list(&self.opt.arg_customer); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _notifications_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Notification = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "body" => { - request.body = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "send-time" => { - request.send_time = Some(value.unwrap_or("").to_string()); - }, - "notification-id" => { - request.notification_id = Some(value.unwrap_or("").to_string()); - }, - "from-address" => { - request.from_address = Some(value.unwrap_or("").to_string()); - }, - "is-unread" => { - request.is_unread = Some(arg_from_str(value.unwrap_or("false"), err, "is-unread", "boolean")); - }, - "subject" => { - request.subject = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _notifications_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Notification = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "body" => { - request.body = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "send-time" => { - request.send_time = Some(value.unwrap_or("").to_string()); - }, - "notification-id" => { - request.notification_id = Some(value.unwrap_or("").to_string()); - }, - "from-address" => { - request.from_address = Some(value.unwrap_or("").to_string()); - }, - "is-unread" => { - request.is_unread = Some(arg_from_str(value.unwrap_or("false"), err, "is-unread", "boolean")); - }, - "subject" => { - request.subject = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _orgunits_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.orgunits().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _orgunits_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.orgunits().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _orgunits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::OrgUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "parent-org-unit-path" => { - request.parent_org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "parent-org-unit-id" => { - request.parent_org_unit_id = Some(value.unwrap_or("").to_string()); - }, - "block-inheritance" => { - request.block_inheritance = Some(arg_from_str(value.unwrap_or("false"), err, "block-inheritance", "boolean")); - }, - "org-unit-id" => { - request.org_unit_id = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _orgunits_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.orgunits().list(&self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "type" => { - call = call.type_(value.unwrap_or("")); - }, - "org-unit-path" => { - call = call.org_unit_path(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _orgunits_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::OrgUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "parent-org-unit-path" => { - request.parent_org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "parent-org-unit-id" => { - request.parent_org_unit_id = Some(value.unwrap_or("").to_string()); - }, - "block-inheritance" => { - request.block_inheritance = Some(arg_from_str(value.unwrap_or("false"), err, "block-inheritance", "boolean")); - }, - "org-unit-id" => { - request.org_unit_id = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _orgunits_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::OrgUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "parent-org-unit-path" => { - request.parent_org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "parent-org-unit-id" => { - request.parent_org_unit_id = Some(value.unwrap_or("").to_string()); - }, - "block-inheritance" => { - request.block_inheritance = Some(arg_from_str(value.unwrap_or("false"), err, "block-inheritance", "boolean")); - }, - "org-unit-id" => { - request.org_unit_id = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schemas_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.schemas().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _schemas_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.schemas().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schemas_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Schema = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schemas_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.schemas().list(&self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schemas_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Schema = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schemas_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Schema = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tokens_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.tokens().delete(&self.opt.arg_user_key, &self.opt.arg_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _tokens_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.tokens().get(&self.opt.arg_user_key, &self.opt.arg_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tokens_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.tokens().list(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_aliases_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().aliases_delete(&self.opt.arg_user_key, &self.opt.arg_alias); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _users_aliases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Alias = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_aliases_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().aliases_list(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_aliases_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Channel = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().delete(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _users_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().get(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "view-type" => { - call = call.view_type(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "custom-field-mask" => { - call = call.custom_field_mask(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::User = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_name_init(request: &mut api::User) { - if request.name.is_none() { - request.name = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "is-delegated-admin" => { - request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); - }, - "suspended" => { - request.suspended = Some(arg_from_str(value.unwrap_or("false"), err, "suspended", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "deletion-time" => { - request.deletion_time = Some(value.unwrap_or("").to_string()); - }, - "suspension-reason" => { - request.suspension_reason = Some(value.unwrap_or("").to_string()); - }, - "thumbnail-photo-url" => { - request.thumbnail_photo_url = Some(value.unwrap_or("").to_string()); - }, - "is-admin" => { - request.is_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-admin", "boolean")); - }, - "include-in-global-address-list" => { - request.include_in_global_address_list = Some(arg_from_str(value.unwrap_or("false"), err, "include-in-global-address-list", "boolean")); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-login-time" => { - request.last_login_time = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "agreed-to-terms" => { - request.agreed_to_terms = Some(arg_from_str(value.unwrap_or("false"), err, "agreed-to-terms", "boolean")); - }, - "ip-whitelisted" => { - request.ip_whitelisted = Some(arg_from_str(value.unwrap_or("false"), err, "ip-whitelisted", "boolean")); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "is-mailbox-setup" => { - request.is_mailbox_setup = Some(arg_from_str(value.unwrap_or("false"), err, "is-mailbox-setup", "boolean")); - }, - "password" => { - request.password = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "hash-function" => { - request.hash_function = Some(value.unwrap_or("").to_string()); - }, - "name.full-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().full_name = value.unwrap_or("").to_string(); - }, - "name.given-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); - }, - "name.family-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); - }, - "creation-time" => { - request_name_init(&mut request); - request.creation_time = Some(value.unwrap_or("").to_string()); - }, - "change-password-at-next-login" => { - request_name_init(&mut request); - request.change_password_at_next_login = Some(arg_from_str(value.unwrap_or("false"), err, "change-password-at-next-login", "boolean")); - }, - "customer-id" => { - request_name_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "view-type" => { - call = call.view_type(value.unwrap_or("")); - }, - "sort-order" => { - call = call.sort_order(value.unwrap_or("")); - }, - "show-deleted" => { - call = call.show_deleted(value.unwrap_or("")); - }, - "query" => { - call = call.query(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "order-by" => { - call = call.order_by(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "event" => { - call = call.event(value.unwrap_or("")); - }, - "domain" => { - call = call.domain(value.unwrap_or("")); - }, - "customer" => { - call = call.customer(value.unwrap_or("")); - }, - "custom-field-mask" => { - call = call.custom_field_mask(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_make_admin(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::UserMakeAdmin = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _users_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::User = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_name_init(request: &mut api::User) { - if request.name.is_none() { - request.name = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "is-delegated-admin" => { - request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); - }, - "suspended" => { - request.suspended = Some(arg_from_str(value.unwrap_or("false"), err, "suspended", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "deletion-time" => { - request.deletion_time = Some(value.unwrap_or("").to_string()); - }, - "suspension-reason" => { - request.suspension_reason = Some(value.unwrap_or("").to_string()); - }, - "thumbnail-photo-url" => { - request.thumbnail_photo_url = Some(value.unwrap_or("").to_string()); - }, - "is-admin" => { - request.is_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-admin", "boolean")); - }, - "include-in-global-address-list" => { - request.include_in_global_address_list = Some(arg_from_str(value.unwrap_or("false"), err, "include-in-global-address-list", "boolean")); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-login-time" => { - request.last_login_time = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "agreed-to-terms" => { - request.agreed_to_terms = Some(arg_from_str(value.unwrap_or("false"), err, "agreed-to-terms", "boolean")); - }, - "ip-whitelisted" => { - request.ip_whitelisted = Some(arg_from_str(value.unwrap_or("false"), err, "ip-whitelisted", "boolean")); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "is-mailbox-setup" => { - request.is_mailbox_setup = Some(arg_from_str(value.unwrap_or("false"), err, "is-mailbox-setup", "boolean")); - }, - "password" => { - request.password = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "hash-function" => { - request.hash_function = Some(value.unwrap_or("").to_string()); - }, - "name.full-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().full_name = value.unwrap_or("").to_string(); - }, - "name.given-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); - }, - "name.family-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); - }, - "creation-time" => { - request_name_init(&mut request); - request.creation_time = Some(value.unwrap_or("").to_string()); - }, - "change-password-at-next-login" => { - request_name_init(&mut request); - request.change_password_at_next_login = Some(arg_from_str(value.unwrap_or("false"), err, "change-password-at-next-login", "boolean")); - }, - "customer-id" => { - request_name_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_photos_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().photos_delete(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _users_photos_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.users().photos_get(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_photos_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::UserPhoto = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "photo-data" => { - request.photo_data = Some(value.unwrap_or("").to_string()); - }, - "height" => { - request.height = Some(arg_from_str(value.unwrap_or("-0"), err, "height", "integer")); - }, - "width" => { - request.width = Some(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_photos_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::UserPhoto = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "photo-data" => { - request.photo_data = Some(value.unwrap_or("").to_string()); - }, - "height" => { - request.height = Some(arg_from_str(value.unwrap_or("-0"), err, "height", "integer")); - }, - "width" => { - request.width = Some(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_undelete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::UserUndelete = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _users_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::User = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_name_init(request: &mut api::User) { - if request.name.is_none() { - request.name = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "is-delegated-admin" => { - request.is_delegated_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-delegated-admin", "boolean")); - }, - "suspended" => { - request.suspended = Some(arg_from_str(value.unwrap_or("false"), err, "suspended", "boolean")); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "aliases" => { - if request.aliases.is_none() { - request.aliases = Some(Default::default()); - } - request.aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "non-editable-aliases" => { - if request.non_editable_aliases.is_none() { - request.non_editable_aliases = Some(Default::default()); - } - request.non_editable_aliases.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "deletion-time" => { - request.deletion_time = Some(value.unwrap_or("").to_string()); - }, - "suspension-reason" => { - request.suspension_reason = Some(value.unwrap_or("").to_string()); - }, - "thumbnail-photo-url" => { - request.thumbnail_photo_url = Some(value.unwrap_or("").to_string()); - }, - "is-admin" => { - request.is_admin = Some(arg_from_str(value.unwrap_or("false"), err, "is-admin", "boolean")); - }, - "include-in-global-address-list" => { - request.include_in_global_address_list = Some(arg_from_str(value.unwrap_or("false"), err, "include-in-global-address-list", "boolean")); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-login-time" => { - request.last_login_time = Some(value.unwrap_or("").to_string()); - }, - "org-unit-path" => { - request.org_unit_path = Some(value.unwrap_or("").to_string()); - }, - "agreed-to-terms" => { - request.agreed_to_terms = Some(arg_from_str(value.unwrap_or("false"), err, "agreed-to-terms", "boolean")); - }, - "ip-whitelisted" => { - request.ip_whitelisted = Some(arg_from_str(value.unwrap_or("false"), err, "ip-whitelisted", "boolean")); - }, - "primary-email" => { - request.primary_email = Some(value.unwrap_or("").to_string()); - }, - "is-mailbox-setup" => { - request.is_mailbox_setup = Some(arg_from_str(value.unwrap_or("false"), err, "is-mailbox-setup", "boolean")); - }, - "password" => { - request.password = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "hash-function" => { - request.hash_function = Some(value.unwrap_or("").to_string()); - }, - "name.full-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().full_name = value.unwrap_or("").to_string(); - }, - "name.given-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); - }, - "name.family-name" => { - request_name_init(&mut request); - request.name.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); - }, - "creation-time" => { - request_name_init(&mut request); - request.creation_time = Some(value.unwrap_or("").to_string()); - }, - "change-password-at-next-login" => { - request_name_init(&mut request); - request.change_password_at_next_login = Some(arg_from_str(value.unwrap_or("false"), err, "change-password-at-next-login", "boolean")); - }, - "customer-id" => { - request_name_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _users_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Channel = Default::default(); - let mut call = self.hub.users().watch(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "view-type" => { - call = call.view_type(value.unwrap_or("")); - }, - "sort-order" => { - call = call.sort_order(value.unwrap_or("")); - }, - "show-deleted" => { - call = call.show_deleted(value.unwrap_or("")); - }, - "query" => { - call = call.query(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "order-by" => { - call = call.order_by(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "event" => { - call = call.event(value.unwrap_or("")); - }, - "domain" => { - call = call.domain(value.unwrap_or("")); - }, - "customer" => { - call = call.customer(value.unwrap_or("")); - }, - "custom-field-mask" => { - call = call.custom_field_mask(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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _verification_codes_generate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.verification_codes().generate(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _verification_codes_invalidate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.verification_codes().invalidate(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _verification_codes_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.verification_codes().list(&self.opt.arg_user_key); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option, Option) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option; - let mut err_opt: Option = None; - - if self.opt.cmd_asps { - if self.opt.cmd_delete { - call_result = self._asps_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._asps_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._asps_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_channels { - if self.opt.cmd_stop { - call_result = self._channels_stop(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_chromeosdevices { - if self.opt.cmd_get { - call_result = self._chromeosdevices_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._chromeosdevices_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._chromeosdevices_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._chromeosdevices_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_groups { - if self.opt.cmd_aliases_delete { - call_result = self._groups_aliases_delete(dry_run, &mut err); - } else if self.opt.cmd_aliases_insert { - call_result = self._groups_aliases_insert(dry_run, &mut err); - } else if self.opt.cmd_aliases_list { - call_result = self._groups_aliases_list(dry_run, &mut err); - } else if self.opt.cmd_delete { - call_result = self._groups_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._groups_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._groups_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._groups_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._groups_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._groups_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_members { - if self.opt.cmd_delete { - call_result = self._members_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._members_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._members_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._members_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._members_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._members_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_mobiledevices { - if self.opt.cmd_action { - call_result = self._mobiledevices_action(dry_run, &mut err); - } else if self.opt.cmd_delete { - call_result = self._mobiledevices_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._mobiledevices_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._mobiledevices_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_notifications { - if self.opt.cmd_delete { - call_result = self._notifications_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._notifications_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._notifications_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._notifications_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._notifications_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_orgunits { - if self.opt.cmd_delete { - call_result = self._orgunits_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._orgunits_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._orgunits_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._orgunits_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._orgunits_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._orgunits_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_schemas { - if self.opt.cmd_delete { - call_result = self._schemas_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._schemas_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._schemas_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._schemas_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._schemas_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._schemas_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_tokens { - if self.opt.cmd_delete { - call_result = self._tokens_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._tokens_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._tokens_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_users { - if self.opt.cmd_aliases_delete { - call_result = self._users_aliases_delete(dry_run, &mut err); - } else if self.opt.cmd_aliases_insert { - call_result = self._users_aliases_insert(dry_run, &mut err); - } else if self.opt.cmd_aliases_list { - call_result = self._users_aliases_list(dry_run, &mut err); - } else if self.opt.cmd_aliases_watch { - call_result = self._users_aliases_watch(dry_run, &mut err); - } else if self.opt.cmd_delete { - call_result = self._users_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._users_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._users_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._users_list(dry_run, &mut err); - } else if self.opt.cmd_make_admin { - call_result = self._users_make_admin(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._users_patch(dry_run, &mut err); - } else if self.opt.cmd_photos_delete { - call_result = self._users_photos_delete(dry_run, &mut err); - } else if self.opt.cmd_photos_get { - call_result = self._users_photos_get(dry_run, &mut err); - } else if self.opt.cmd_photos_patch { - call_result = self._users_photos_patch(dry_run, &mut err); - } else if self.opt.cmd_photos_update { - call_result = self._users_photos_update(dry_run, &mut err); - } else if self.opt.cmd_undelete { - call_result = self._users_undelete(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._users_update(dry_run, &mut err); - } else if self.opt.cmd_watch { - call_result = self._users_watch(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_verification_codes { - if self.opt.cmd_generate { - call_result = self._verification_codes_generate(dry_run, &mut err); - } else if self.opt.cmd_invalidate { - call_result = self._verification_codes_invalidate(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._verification_codes_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "admin1-directory-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "admin1-directory", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Directory::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/admin1_directory/Cargo.toml b/gen/admin1_directory/Cargo.toml index 69e1b374dc..71dd8e232c 100644 --- a/gen/admin1_directory/Cargo.toml +++ b/gen/admin1_directory/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-admin1_directory" -version = "0.1.5+20150309" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/admin-sdk/directory/" diff --git a/gen/admin1_directory/README.md b/gen/admin1_directory/README.md index 97d2b7b5af..8b80773344 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+20150309*, where *20150309* 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.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*. Everything else about the *directory* *v1_directory* API can be found at the [official documentation site](https://developers.google.com/admin-sdk/directory/). @@ -139,7 +139,7 @@ let mut hub = Directory::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Channel = Default::default(); +let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/admin1_directory/src/cmn.rs b/gen/admin1_directory/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/admin1_directory/src/cmn.rs +++ b/gen/admin1_directory/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/admin1_directory/src/lib.rs b/gen/admin1_directory/src/lib.rs index 2acec28472..66fb0b5171 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+20150309*, where *20150309* 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.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*. //! //! Everything else about the *directory* *v1_directory* API can be found at the //! [official documentation site](https://developers.google.com/admin-sdk/directory/). @@ -140,7 +140,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Channel = Default::default(); +//! let mut req = Channel::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -399,7 +399,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -515,13 +515,13 @@ impl<'a, C, A> Directory pub struct UserName { /// Full Name #[serde(rename="fullName")] - pub full_name: String, + pub full_name: Option, /// First Name #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option, /// Last Name #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option, } impl Part for UserName {} @@ -625,29 +625,29 @@ impl ResponseResult for Notification {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SchemaFieldSpec { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Read ACLs on the field specifying who can view values of this field. Valid values are "ALL_DOMAIN_USERS" and "ADMINS_AND_SELF". #[serde(rename="readAccessType")] - pub read_access_type: String, + pub read_access_type: Option, /// Type of the field. #[serde(rename="fieldType")] - pub field_type: String, + pub field_type: Option, /// Boolean specifying whether the field is indexed or not. - pub indexed: bool, + pub indexed: Option, /// Name of the field. #[serde(rename="fieldName")] - pub field_name: String, + pub field_name: Option, /// Indexing spec for a numeric field. By default, only exact match queries will be supported for numeric fields. Setting the numericIndexingSpec allows range queries to be supported. #[serde(rename="numericIndexingSpec")] - pub numeric_indexing_spec: SchemaFieldSpecNumericIndexingSpec, + pub numeric_indexing_spec: Option, /// Unique identifier of Field (Read-only) #[serde(rename="fieldId")] - pub field_id: String, + pub field_id: Option, /// Boolean specifying whether this is a multi-valued field or not. #[serde(rename="multiValued")] - pub multi_valued: bool, + pub multi_valued: Option, } impl Part for SchemaFieldSpec {} @@ -701,12 +701,12 @@ impl ResponseResult for Member {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrgUnits { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of user objects. #[serde(rename="organizationUnits")] - pub organization_units: Vec, + pub organization_units: Option>, } impl ResponseResult for OrgUnits {} @@ -726,25 +726,25 @@ impl ResponseResult for OrgUnits {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Token { /// A list of authorization scopes the application is granted. - pub scopes: Vec, + pub scopes: Option>, /// The type of the API resource. This is always admin#directory#token. - pub kind: String, + pub kind: Option, /// The Client ID of the application the token is issued to. #[serde(rename="clientId")] - pub client_id: String, + pub client_id: Option, /// Whether the token is issued to an installed application. The value is true if the application is installed to a desktop or mobile device. #[serde(rename="nativeApp")] - pub native_app: bool, + pub native_app: Option, /// The displayable name of the application the token is issued to. #[serde(rename="displayText")] - pub display_text: String, + pub display_text: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Whether the application is registered with Google. The value is true if the application has an anonymous Client ID. - pub anonymous: bool, + pub anonymous: Option, /// The unique ID of the user that issued the token. #[serde(rename="userKey")] - pub user_key: String, + pub user_key: Option, } impl Resource for Token {} @@ -763,11 +763,11 @@ impl ResponseResult for Token {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Asps { /// A list of ASP resources. - pub items: Vec, + pub items: Option>, /// The type of the API resource. This is always admin#directory#aspList. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, } impl ResponseResult for Asps {} @@ -865,23 +865,23 @@ impl ResponseResult for Schema {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Asp { /// The type of the API resource. This is always admin#directory#asp. - pub kind: String, + pub kind: Option, /// ETag of the ASP. - pub etag: String, + pub etag: Option, /// The name of the application that the user, represented by their userId, entered when the ASP was created. - pub name: String, + pub name: Option, /// The unique ID of the ASP. #[serde(rename="codeId")] - pub code_id: i32, + pub code_id: Option, /// The time when the ASP was last used. Expressed in Unix time format. #[serde(rename="lastTimeUsed")] - pub last_time_used: String, + pub last_time_used: Option, /// The unique ID of the user who issued the ASP. #[serde(rename="userKey")] - pub user_key: String, + pub user_key: Option, /// The time when the ASP was created. Expressed in Unix time format. #[serde(rename="creationTime")] - pub creation_time: String, + pub creation_time: Option, } impl Resource for Asp {} @@ -900,11 +900,11 @@ impl ResponseResult for Asp {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Tokens { /// A list of Token resources. - pub items: Vec, + pub items: Option>, /// The type of the API resource. This is always admin#directory#tokenList. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, } impl ResponseResult for Tokens {} @@ -923,16 +923,16 @@ impl ResponseResult for Tokens {} pub struct Notifications { /// Token for fetching the next page of notifications. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// List of notifications in this page. - pub items: Vec, + pub items: Option>, /// The type of the resource. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Number of unread notification for the domain. #[serde(rename="unreadNotificationsCount")] - pub unread_notifications_count: i32, + pub unread_notifications_count: Option, } impl ResponseResult for Notifications {} @@ -986,9 +986,9 @@ pub struct ChromeOsDevice { /// Chromebook Mac Address on ethernet network interface (Read-only) #[serde(rename="ethernetMacAddress")] pub ethernet_mac_address: Option, - /// Chromebook Os Version (Read-only) - #[serde(rename="osVersion")] - pub os_version: Option, + /// AssetId specified during enrollment or through later annotation + #[serde(rename="annotatedAssetId")] + pub annotated_asset_id: Option, /// Chromebook firmware version (Read-only) #[serde(rename="firmwareVersion")] pub firmware_version: Option, @@ -997,6 +997,9 @@ pub struct ChromeOsDevice { pub last_enrollment_time: Option, /// Kind of resource this is. pub kind: Option, + /// Chromebook Os Version (Read-only) + #[serde(rename="osVersion")] + pub os_version: Option, /// Notes added by the administrator pub notes: Option, /// Will Chromebook auto renew after support end date (Read-only) @@ -1158,13 +1161,13 @@ impl ResponseResult for User {} pub struct Groups { /// Token used to access next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of group objects. - pub groups: Vec, + pub groups: Option>, } impl ResponseResult for Groups {} @@ -1178,9 +1181,9 @@ impl ResponseResult for Groups {} pub struct ChromeOsDeviceRecentUsers { /// The type of the user #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Email address of the user. Present only if the user type is managed - pub email: String, + pub email: Option, } impl NestedType for ChromeOsDeviceRecentUsers {} @@ -1195,18 +1198,18 @@ impl Part for ChromeOsDeviceRecentUsers {} pub struct MobileDeviceApplications { /// Version code of application #[serde(rename="versionCode")] - pub version_code: i32, + pub version_code: Option, /// Package name of application #[serde(rename="packageName")] - pub package_name: String, + pub package_name: Option, /// Display name of application #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// Version name of application #[serde(rename="versionName")] - pub version_name: String, + pub version_name: Option, /// List of Permissions for application - pub permission: Vec, + pub permission: Option>, } impl NestedType for MobileDeviceApplications {} @@ -1218,7 +1221,7 @@ impl Part for MobileDeviceApplications {} /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UserCustomProperties(HashMap); +pub struct UserCustomProperties(Option>); impl Part for UserCustomProperties {} @@ -1236,13 +1239,13 @@ impl Part for UserCustomProperties {} pub struct Members { /// Token used to access next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of member objects. - pub members: Vec, + pub members: Option>, } impl ResponseResult for Members {} @@ -1279,11 +1282,11 @@ impl RequestValue for UserUndelete {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VerificationCodes { /// A list of verification code resources. - pub items: Vec, + pub items: Option>, /// The type of the resource. This is always admin#directory#verificationCodesList. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, } impl ResponseResult for VerificationCodes {} @@ -1331,13 +1334,13 @@ impl ResponseResult for Alias {} pub struct MobileDevices { /// Token used to access next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of Mobile Device objects. - pub mobiledevices: Vec, + pub mobiledevices: Option>, } impl ResponseResult for MobileDevices {} @@ -1350,10 +1353,10 @@ impl ResponseResult for MobileDevices {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChromeOsDeviceActiveTimeRanges { /// Date of usage - pub date: String, + pub date: Option, /// Duration in milliseconds #[serde(rename="activeTime")] - pub active_time: i32, + pub active_time: Option, } impl NestedType for ChromeOsDeviceActiveTimeRanges {} @@ -1447,15 +1450,15 @@ impl RequestValue for UserMakeAdmin {} pub struct Users { /// Token used to access next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Event that triggered this response (only used in case of Push Response) - pub trigger_event: String, + pub trigger_event: Option, /// List of user objects. - pub users: Vec, + pub users: Option>, } impl ResponseResult for Users {} @@ -1474,72 +1477,72 @@ impl ResponseResult for Users {} pub struct MobileDevice { /// Mobile Device Kernel version (Read-only) #[serde(rename="kernelVersion")] - pub kernel_version: String, + pub kernel_version: Option, /// Date and time the device was last synchronized with the policy settings in the Google Apps administrator control panel (Read-only) #[serde(rename="lastSync")] - pub last_sync: String, + pub last_sync: Option, /// Mobile Device compromised status (Read-only) #[serde(rename="deviceCompromisedStatus")] - pub device_compromised_status: String, + pub device_compromised_status: Option, /// Unique identifier of Mobile Device (Read-only) #[serde(rename="resourceId")] - pub resource_id: String, + pub resource_id: Option, /// Mobile Device MEID number (Read-only) - pub meid: String, + pub meid: Option, /// The default locale used on the Mobile Device (Read-only) #[serde(rename="defaultLanguage")] - pub default_language: String, + pub default_language: Option, /// Mobile Device Build number (Read-only) #[serde(rename="buildNumber")] - pub build_number: String, + pub build_number: Option, /// List of applications installed on Mobile Device - pub applications: Vec, + pub applications: Option>, /// Mobile Device serial number (Read-only) #[serde(rename="deviceId")] - pub device_id: String, + pub device_id: Option, /// Mobile Device IMEI number (Read-only) - pub imei: String, + pub imei: Option, /// Mobile Device user agent #[serde(rename="userAgent")] - pub user_agent: String, + pub user_agent: Option, /// Mobile Device Baseband version (Read-only) #[serde(rename="basebandVersion")] - pub baseband_version: String, + pub baseband_version: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// List of owner user's names (Read-only) - pub name: Vec, + pub name: Option>, /// Date and time the device was first synchronized with the policy settings in the Google Apps administrator control panel (Read-only) #[serde(rename="firstSync")] - pub first_sync: String, + pub first_sync: Option, /// Name of the mobile operating system - pub os: String, + pub os: Option, /// Mobile Device SSN or Serial Number (Read-only) #[serde(rename="serialNumber")] - pub serial_number: String, + pub serial_number: Option, /// Mobile Device Hardware Id (Read-only) #[serde(rename="hardwareId")] - pub hardware_id: String, + pub hardware_id: Option, /// Mobile Device mobile or network operator (if available) (Read-only) #[serde(rename="networkOperator")] - pub network_operator: String, + pub network_operator: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Status of the device (Read-only) - pub status: String, + pub status: Option, /// Boolean indicating if this account is on owner/primary profile or not (Read-only) #[serde(rename="managedAccountIsOnOwnerProfile")] - pub managed_account_is_on_owner_profile: bool, + pub managed_account_is_on_owner_profile: Option, /// Name of the model of the device - pub model: String, + pub model: Option, /// The type of device (Read-only) #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// List of owner user's email addresses (Read-only) - pub email: Vec, + pub email: Option>, /// Mobile Device WiFi MAC address (Read-only) #[serde(rename="wifiMacAddress")] - pub wifi_mac_address: String, + pub wifi_mac_address: Option, } impl Resource for MobileDevice {} @@ -1559,13 +1562,13 @@ impl ResponseResult for MobileDevice {} pub struct ChromeOsDevices { /// Token used to access next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// List of Chrome OS Device objects. - pub chromeosdevices: Vec, + pub chromeosdevices: Option>, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Kind of resource this is. - pub kind: String, + pub kind: Option, } impl ResponseResult for ChromeOsDevices {} @@ -1651,10 +1654,10 @@ impl Resource for VerificationCode {} pub struct SchemaFieldSpecNumericIndexingSpec { /// Maximum value of this field. This is meant to be indicative rather than enforced. Values outside this range will still be indexed, but search may not be as performant. #[serde(rename="maxValue")] - pub max_value: f64, + pub max_value: Option, /// Minimum value of this field. This is meant to be indicative rather than enforced. Values outside this range will still be indexed, but search may not be as performant. #[serde(rename="minValue")] - pub min_value: f64, + pub min_value: Option, } impl NestedType for SchemaFieldSpecNumericIndexingSpec {} @@ -1673,11 +1676,11 @@ impl Part for SchemaFieldSpecNumericIndexingSpec {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Schemas { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of UserSchema objects. - pub schemas: Vec, + pub schemas: Option>, } impl ResponseResult for Schemas {} @@ -1696,11 +1699,11 @@ impl ResponseResult for Schemas {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Aliases { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// List of alias objects. - pub aliases: Vec, + pub aliases: Option>, } impl ResponseResult for Aliases {} @@ -3612,16 +3615,20 @@ impl<'a, C, A> TokenGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3852,16 +3859,20 @@ impl<'a, C, A> TokenListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4083,16 +4094,20 @@ impl<'a, C, A> TokenDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4232,7 +4247,7 @@ impl<'a, C, A> TokenDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4297,16 +4312,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4439,7 +4458,7 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: OrgUnit = Default::default(); +/// let mut req = OrgUnit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4531,16 +4550,20 @@ impl<'a, C, A> OrgunitInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4784,16 +4807,20 @@ impl<'a, C, A> OrgunitListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5036,16 +5063,20 @@ impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5196,7 +5227,7 @@ impl<'a, C, A> OrgunitGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: OrgUnit = Default::default(); +/// let mut req = OrgUnit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5296,16 +5327,20 @@ impl<'a, C, A> OrgunitUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5557,16 +5592,20 @@ impl<'a, C, A> OrgunitDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5707,7 +5746,7 @@ impl<'a, C, A> OrgunitDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: OrgUnit = Default::default(); +/// let mut req = OrgUnit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5807,16 +5846,20 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5980,7 +6023,7 @@ impl<'a, C, A> OrgunitPatchCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6046,16 +6089,20 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6278,16 +6325,20 @@ impl<'a, C, A> UserPhotoDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6417,7 +6468,7 @@ impl<'a, C, A> UserPhotoDeleteCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserUndelete = Default::default(); +/// let mut req = UserUndelete::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6508,16 +6559,20 @@ impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6660,7 +6715,7 @@ impl<'a, C, A> UserUndeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserMakeAdmin = Default::default(); +/// let mut req = UserMakeAdmin::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6751,16 +6806,20 @@ impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6903,7 +6962,7 @@ impl<'a, C, A> UserMakeAdminCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6995,16 +7054,20 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7157,7 +7220,7 @@ impl<'a, C, A> UserPatchCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7283,16 +7346,20 @@ impl<'a, C, A> UserWatchCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7599,16 +7666,20 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7738,7 +7809,7 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserPhoto = Default::default(); +/// let mut req = UserPhoto::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7830,16 +7901,20 @@ impl<'a, C, A> UserPhotoUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8088,16 +8163,20 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8258,7 +8337,7 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Alias = Default::default(); +/// let mut req = Alias::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8350,16 +8429,20 @@ impl<'a, C, A> UserAliaseInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8627,16 +8710,20 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8932,16 +9019,20 @@ impl<'a, C, A> UserAliaseDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -9081,7 +9172,7 @@ impl<'a, C, A> UserAliaseDeleteCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9173,16 +9264,20 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9335,7 +9430,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9432,16 +9527,20 @@ impl<'a, C, A> UserAliaseWatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9687,16 +9786,20 @@ impl<'a, C, A> UserAliaseListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9924,16 +10027,20 @@ impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10073,7 +10180,7 @@ impl<'a, C, A> UserPhotoGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserPhoto = Default::default(); +/// let mut req = UserPhoto::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10165,16 +10272,20 @@ impl<'a, C, A> UserPhotoPatchCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10409,16 +10520,20 @@ impl<'a, C, A> MobiledeviceDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10646,16 +10761,20 @@ impl<'a, C, A> MobiledeviceGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10923,16 +11042,20 @@ impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11114,7 +11237,7 @@ impl<'a, C, A> MobiledeviceListCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: MobileDeviceAction = Default::default(); +/// let mut req = MobileDeviceAction::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11207,16 +11330,20 @@ impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11369,7 +11496,7 @@ impl<'a, C, A> MobiledeviceActionCall<'a, C, A> where C: BorrowMut MemberUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11718,16 +11849,20 @@ impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11877,7 +12012,7 @@ impl<'a, C, A> MemberGetCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Member = Default::default(); +/// let mut req = Member::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11969,16 +12104,20 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12131,7 +12270,7 @@ impl<'a, C, A> MemberInsertCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Member = Default::default(); +/// let mut req = Member::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12225,16 +12364,20 @@ impl<'a, C, A> MemberPatchCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12479,16 +12622,20 @@ impl<'a, C, A> MemberDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -12724,16 +12871,20 @@ impl<'a, C, A> MemberListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12990,16 +13141,20 @@ impl<'a, C, A> NotificationListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13242,16 +13397,20 @@ impl<'a, C, A> NotificationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13391,7 +13550,7 @@ impl<'a, C, A> NotificationDeleteCall<'a, C, A> where C: BorrowMut NotificationPatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13657,7 +13820,7 @@ impl<'a, C, A> NotificationPatchCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Notification = Default::default(); +/// let mut req = Notification::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13751,16 +13914,20 @@ impl<'a, C, A> NotificationUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14006,16 +14173,20 @@ impl<'a, C, A> NotificationGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14276,16 +14447,20 @@ impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14467,7 +14642,7 @@ impl<'a, C, A> ChromeosdeviceListCall<'a, C, A> where C: BorrowMut ChromeosdevicePatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14833,16 +15012,20 @@ impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14999,7 +15182,7 @@ impl<'a, C, A> ChromeosdeviceGetCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChromeOsDevice = Default::default(); +/// let mut req = ChromeOsDevice::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15098,16 +15281,20 @@ impl<'a, C, A> ChromeosdeviceUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15357,16 +15544,20 @@ impl<'a, C, A> VerificationCodeGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -15576,16 +15767,20 @@ impl<'a, C, A> VerificationCodeInvalidateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -15796,16 +15991,20 @@ impl<'a, C, A> VerificationCodeListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16026,16 +16225,20 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16255,16 +16458,20 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16510,16 +16717,20 @@ impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16659,7 +16870,7 @@ impl<'a, C, A> GroupAliaseListCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Group = Default::default(); +/// let mut req = Group::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16751,16 +16962,20 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16913,7 +17128,7 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Group = Default::default(); +/// let mut req = Group::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17005,16 +17220,20 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17247,16 +17466,20 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -17386,7 +17609,7 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Alias = Default::default(); +/// let mut req = Alias::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17478,16 +17701,20 @@ impl<'a, C, A> GroupAliaseInsertCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17722,16 +17949,20 @@ impl<'a, C, A> GroupAliaseDeleteCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -17871,7 +18102,7 @@ impl<'a, C, A> GroupAliaseDeleteCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Group = Default::default(); +/// let mut req = Group::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17937,16 +18168,20 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18171,16 +18406,20 @@ impl<'a, C, A> AspDeleteCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -18401,16 +18640,20 @@ impl<'a, C, A> AspListCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18633,16 +18876,20 @@ impl<'a, C, A> AspGetCall<'a, C, A> where C: BorrowMut, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18873,16 +19120,20 @@ impl<'a, C, A> SchemaListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19105,16 +19356,20 @@ impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19264,7 +19519,7 @@ impl<'a, C, A> SchemaGetCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Schema = Default::default(); +/// let mut req = Schema::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19358,16 +19613,20 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19530,7 +19789,7 @@ impl<'a, C, A> SchemaPatchCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Schema = Default::default(); +/// let mut req = Schema::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19622,16 +19881,20 @@ impl<'a, C, A> SchemaInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19866,16 +20129,20 @@ impl<'a, C, A> SchemaDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -20015,7 +20282,7 @@ impl<'a, C, A> SchemaDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Schema = Default::default(); +/// let mut req = Schema::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -20109,16 +20376,20 @@ impl<'a, C, A> SchemaUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/admin1_reports-cli/Cargo.toml b/gen/admin1_reports-cli/Cargo.toml deleted file mode 100644 index b47c509026..0000000000 --- a/gen/admin1_reports-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-admin1_reports-cli" -version = "0.0.1+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" -homepage = "https://developers.google.com/admin-sdk/reports/" -documentation = "http://byron.github.io/google-apis-rs/google_admin1_reports_cli" -license = "MIT" -keywords = ["admin", "google", "cli"] - -[[bin]] -name = "admin1-reports" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-admin1_reports] -path = "../admin1_reports" diff --git a/gen/admin1_reports-cli/mkdocs.yml b/gen/admin1_reports-cli/mkdocs.yml deleted file mode 100644 index d5581f072c..0000000000 --- a/gen/admin1_reports-cli/mkdocs.yml +++ /dev/null @@ -1,21 +0,0 @@ -site_name: reports v0.0.1+20150115 -site_url: http://byron.github.io/google-apis-rs/google-admin1_reports-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/admin1_reports-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['activities_list.md', 'Activities', 'List'] -- ['activities_watch.md', 'Activities', 'Watch'] -- ['channels_stop.md', 'Channels', 'Stop'] -- ['customer-usage-reports_get.md', 'Customer Usage Reports', 'Get'] -- ['user-usage-report_get.md', 'User Usage Report', 'Get'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/admin1_reports-cli/src/main.rs b/gen/admin1_reports-cli/src/main.rs deleted file mode 100644 index 41dfbdd61d..0000000000 --- a/gen/admin1_reports-cli/src/main.rs +++ /dev/null @@ -1,535 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_admin1_reports as api; - -use std::env; -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 --help - -All documentation details can be found TODO: - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Reports>, -} - - -impl Engine { - fn _activities_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.activities().list(&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); - match key { - "start-time" => { - call = call.start_time(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")); - }, - "filters" => { - call = call.filters(value.unwrap_or("")); - }, - "event-name" => { - call = call.event_name(value.unwrap_or("")); - }, - "end-time" => { - call = call.end_time(value.unwrap_or("")); - }, - "customer-id" => { - call = call.customer_id(value.unwrap_or("")); - }, - "actor-ip-address" => { - call = call.actor_ip_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _activities_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Channel = Default::default(); - 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); - match key { - "start-time" => { - call = call.start_time(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")); - }, - "filters" => { - call = call.filters(value.unwrap_or("")); - }, - "event-name" => { - call = call.event_name(value.unwrap_or("")); - }, - "end-time" => { - call = call.end_time(value.unwrap_or("")); - }, - "customer-id" => { - call = call.customer_id(value.unwrap_or("")); - }, - "actor-ip-address" => { - call = call.actor_ip_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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Channel = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _customer_usage_reports_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.customer_usage_reports().get(&self.opt.arg_date); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "parameters" => { - call = call.parameters(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "customer-id" => { - call = call.customer_id(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _user_usage_report_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.user_usage_report().get(&self.opt.arg_user_key, &self.opt.arg_date); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "parameters" => { - call = call.parameters(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")); - }, - "filters" => { - call = call.filters(value.unwrap_or("")); - }, - "customer-id" => { - call = call.customer_id(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option, Option) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option; - let mut err_opt: Option = None; - - if self.opt.cmd_activities { - if self.opt.cmd_list { - call_result = self._activities_list(dry_run, &mut err); - } else if self.opt.cmd_watch { - call_result = self._activities_watch(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_channels { - if self.opt.cmd_stop { - call_result = self._channels_stop(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_customer_usage_reports { - if self.opt.cmd_get { - call_result = self._customer_usage_reports_get(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_user_usage_report { - if self.opt.cmd_get { - call_result = self._user_usage_report_get(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "admin1-reports-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "admin1-reports", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Reports::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/admin1_reports/Cargo.toml b/gen/admin1_reports/Cargo.toml index c2d4764578..ddbc44d5b1 100644 --- a/gen/admin1_reports/Cargo.toml +++ b/gen/admin1_reports/Cargo.toml @@ -5,7 +5,7 @@ name = "google-admin1_reports" version = "0.1.5+20150115" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/admin-sdk/reports/" diff --git a/gen/admin1_reports/README.md b/gen/admin1_reports/README.md index 6b5a68ee9e..3fb9cfc084 100644 --- a/gen/admin1_reports/README.md +++ b/gen/admin1_reports/README.md @@ -105,7 +105,7 @@ let mut hub = Reports::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Channel = Default::default(); +let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/admin1_reports/src/cmn.rs b/gen/admin1_reports/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/admin1_reports/src/cmn.rs +++ b/gen/admin1_reports/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/admin1_reports/src/lib.rs b/gen/admin1_reports/src/lib.rs index f21cf482ee..a0965e363d 100644 --- a/gen/admin1_reports/src/lib.rs +++ b/gen/admin1_reports/src/lib.rs @@ -106,7 +106,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Channel = Default::default(); +//! let mut req = Channel::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -293,7 +293,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -386,13 +386,13 @@ impl<'a, C, A> Reports pub struct Activities { /// Token for retrieving the next page #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Each record in read response. - pub items: Vec, + pub items: Option>, /// Kind of list response this is. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, } impl ResponseResult for Activities {} @@ -405,9 +405,9 @@ impl ResponseResult for Activities {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UsageReportsWarningsData { /// Key associated with a key-value pair to give detailed information on the warning. - pub key: String, + pub key: Option, /// Value associated with a key-value pair to give detailed information on the warning. - pub value: String, + pub value: Option, } impl NestedType for UsageReportsWarningsData {} @@ -421,15 +421,15 @@ impl Part for UsageReportsWarningsData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UsageReport { /// The date to which the record belongs. - pub date: String, + pub date: Option, /// The kind of object. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Parameter value pairs for various applications. - pub parameters: Vec, + pub parameters: Option>, /// Information about the type of the item. - pub entity: UsageReportEntity, + pub entity: Option, } impl Part for UsageReport {} @@ -443,21 +443,21 @@ impl Part for UsageReport {} pub struct UsageReportParameters { /// Nested message value of the parameter. #[serde(rename="msgValue")] - pub msg_value: Vec>, + pub msg_value: Option>>, /// RFC 3339 formatted value of the parameter. #[serde(rename="datetimeValue")] - pub datetime_value: String, + pub datetime_value: Option, /// The name of the parameter. - pub name: String, + pub name: Option, /// String value of the parameter. #[serde(rename="stringValue")] - pub string_value: String, + pub string_value: Option, /// Boolean value of the parameter. #[serde(rename="boolValue")] - pub bool_value: bool, + pub bool_value: Option, /// Integral value of the parameter. #[serde(rename="intValue")] - pub int_value: String, + pub int_value: Option, } impl NestedType for UsageReportParameters {} @@ -472,14 +472,14 @@ impl Part for UsageReportParameters {} pub struct ActivityActor { /// Obfuscated user id of the user. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option, /// Email address of the user. - pub email: String, + pub email: Option, /// For OAuth 2LO API requests, consumer_key of the requestor. - pub key: String, + pub key: Option, /// User or OAuth 2LO request. #[serde(rename="callerType")] - pub caller_type: String, + pub caller_type: Option, } impl NestedType for ActivityActor {} @@ -494,15 +494,15 @@ impl Part for ActivityActor {} pub struct ActivityId { /// Application name to which the event belongs. #[serde(rename="applicationName")] - pub application_name: String, + pub application_name: Option, /// Unique qualifier if multiple events have the same time. #[serde(rename="uniqueQualifier")] - pub unique_qualifier: String, + pub unique_qualifier: Option, /// Obfuscated customer ID of the source customer. #[serde(rename="customerId")] - pub customer_id: String, + pub customer_id: Option, /// Time of occurrence of the activity. - pub time: String, + pub time: Option, } impl NestedType for ActivityId {} @@ -516,11 +516,11 @@ impl Part for ActivityId {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UsageReportsWarnings { /// Human readable message for the warning. - pub message: String, + pub message: Option, /// Machine readable code / warning type. - pub code: String, + pub code: Option, /// Key-Value pairs to give detailed information on the warning. - pub data: Vec, + pub data: Option>, } impl NestedType for UsageReportsWarnings {} @@ -541,16 +541,16 @@ impl Part for UsageReportsWarnings {} pub struct UsageReports { /// Token for retrieving the next page #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The kind of object. - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// Various application parameter records. #[serde(rename="usageReports")] - pub usage_reports: Vec, + pub usage_reports: Option>, /// Warnings if any. - pub warnings: Vec, + pub warnings: Option>, } impl ResponseResult for UsageReports {} @@ -563,21 +563,21 @@ impl ResponseResult for UsageReports {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Activity { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// ETag of the entry. - pub etag: String, + pub etag: Option, /// Activity events. - pub events: Vec, + pub events: Option>, /// IP Address of the user doing the action. #[serde(rename="ipAddress")] - pub ip_address: String, + pub ip_address: Option, /// Domain of source customer. #[serde(rename="ownerDomain")] - pub owner_domain: String, + pub owner_domain: Option, /// User doing the action. - pub actor: ActivityActor, + pub actor: Option, /// Unique identifier for each activity record. - pub id: ActivityId, + pub id: Option, } impl Part for Activity {} @@ -591,20 +591,20 @@ impl Part for Activity {} pub struct ActivityEventsParameters { /// Boolean value of the parameter. #[serde(rename="boolValue")] - pub bool_value: bool, + pub bool_value: Option, /// Multi-string value of the parameter. #[serde(rename="multiValue")] - pub multi_value: Vec, + pub multi_value: Option>, /// The name of the parameter. - pub name: String, + pub name: Option, /// Multi-int value of the parameter. #[serde(rename="multiIntValue")] - pub multi_int_value: Vec, + pub multi_int_value: Option>, /// Integral value of the parameter. #[serde(rename="intValue")] - pub int_value: String, + pub int_value: Option, /// String value of the parameter. - pub value: String, + pub value: Option, } impl NestedType for ActivityEventsParameters {} @@ -619,11 +619,11 @@ impl Part for ActivityEventsParameters {} pub struct ActivityEvents { /// Type of event. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Name of event. - pub name: String, + pub name: Option, /// Parameter value pairs for various applications. - pub parameters: Vec, + pub parameters: Option>, } impl NestedType for ActivityEvents {} @@ -638,16 +638,16 @@ impl Part for ActivityEvents {} pub struct UsageReportEntity { /// Obfuscated user id for the record. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option, /// user's email. #[serde(rename="userEmail")] - pub user_email: String, + pub user_email: Option, /// The type of item, can be a customer or user. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Obfuscated customer id for the record. #[serde(rename="customerId")] - pub customer_id: String, + pub customer_id: Option, } impl NestedType for UsageReportEntity {} @@ -1015,7 +1015,7 @@ impl<'a, C, A> UserUsageReportMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1080,16 +1080,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1222,7 +1226,7 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1356,16 +1360,20 @@ impl<'a, C, A> ActivityWatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1707,16 +1715,20 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2018,16 +2030,20 @@ impl<'a, C, A> CustomerUsageReportGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2296,16 +2312,20 @@ impl<'a, C, A> UserUsageReportGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/admin2_email_migration-cli/Cargo.toml b/gen/admin2_email_migration-cli/Cargo.toml deleted file mode 100644 index 9434e00b26..0000000000 --- a/gen/admin2_email_migration-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-admin2_email_migration-cli" -version = "0.0.1+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" -homepage = "https://developers.google.com/admin-sdk/email-migration/v2/" -documentation = "http://byron.github.io/google-apis-rs/google_admin2_email_migration_cli" -license = "MIT" -keywords = ["admin", "google", "cli"] - -[[bin]] -name = "admin2-email-migration" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-admin2_email_migration] -path = "../admin2_email_migration" diff --git a/gen/admin2_email_migration-cli/README.md b/gen/admin2_email_migration-cli/README.md deleted file mode 100644 index ed6449c3ab..0000000000 --- a/gen/admin2_email_migration-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO ADMIN:EMAIL_MIGRATION_V2 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/admin2_email_migration-cli/mkdocs.yml b/gen/admin2_email_migration-cli/mkdocs.yml deleted file mode 100644 index c666938a66..0000000000 --- a/gen/admin2_email_migration-cli/mkdocs.yml +++ /dev/null @@ -1,17 +0,0 @@ -site_name: admin v0.0.1+20150303 -site_url: http://byron.github.io/google-apis-rs/google-admin2_email_migration-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/admin2_email_migration-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['mail_insert.md', 'Mail', 'Insert'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/admin2_email_migration-cli/src/cmn.rs b/gen/admin2_email_migration-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/admin2_email_migration-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/admin2_email_migration-cli/src/main.rs b/gen/admin2_email_migration-cli/src/main.rs deleted file mode 100644 index c90b782cc4..0000000000 --- a/gen/admin2_email_migration-cli/src/main.rs +++ /dev/null @@ -1,224 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_admin2_email_migration as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - admin2-email-migration [options] mail insert -r ... -u (simple|resumable) [-p ]... - admin2-email-migration --help - -All documentation details can be found TODO: - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Admin>, -} - - -impl Engine { - fn _mail_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::MailItem = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "is-trash" => { - request.is_trash = Some(arg_from_str(value.unwrap_or("false"), err, "is-trash", "boolean")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "labels" => { - if request.labels.is_none() { - request.labels = Some(Default::default()); - } - request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "is-draft" => { - request.is_draft = Some(arg_from_str(value.unwrap_or("false"), err, "is-draft", "boolean")); - }, - "is-inbox" => { - request.is_inbox = Some(arg_from_str(value.unwrap_or("false"), err, "is-inbox", "boolean")); - }, - "is-sent" => { - request.is_sent = Some(arg_from_str(value.unwrap_or("false"), err, "is-sent", "boolean")); - }, - "is-starred" => { - request.is_starred = Some(arg_from_str(value.unwrap_or("false"), err, "is-starred", "boolean")); - }, - "is-unread" => { - request.is_unread = Some(arg_from_str(value.unwrap_or("false"), err, "is-unread", "boolean")); - }, - "is-deleted" => { - 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()))); - } - } - } - 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); - 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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option, Option) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option; - let mut err_opt: Option = None; - - if self.opt.cmd_mail { - if self.opt.cmd_insert { - call_result = self._mail_insert(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "admin2-email-migration-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "admin2-email-migration", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Admin::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/admin2_email_migration/Cargo.toml b/gen/admin2_email_migration/Cargo.toml index 53e48fd475..30580a4fa8 100644 --- a/gen/admin2_email_migration/Cargo.toml +++ b/gen/admin2_email_migration/Cargo.toml @@ -5,7 +5,7 @@ name = "google-admin2_email_migration" version = "0.1.5+20150303" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/admin-sdk/email-migration/v2/" diff --git a/gen/admin2_email_migration/README.md b/gen/admin2_email_migration/README.md index ba10603d84..7245e0fcde 100644 --- a/gen/admin2_email_migration/README.md +++ b/gen/admin2_email_migration/README.md @@ -98,7 +98,7 @@ let mut hub = Admin::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: MailItem = Default::default(); +let mut req = MailItem::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `upload(...)`. diff --git a/gen/admin2_email_migration/src/cmn.rs b/gen/admin2_email_migration/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/admin2_email_migration/src/cmn.rs +++ b/gen/admin2_email_migration/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/admin2_email_migration/src/lib.rs b/gen/admin2_email_migration/src/lib.rs index 2cff7ab799..1328902964 100644 --- a/gen/admin2_email_migration/src/lib.rs +++ b/gen/admin2_email_migration/src/lib.rs @@ -99,7 +99,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: MailItem = Default::default(); +//! let mut req = MailItem::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `upload(...)`. @@ -275,7 +275,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: MailItem = Default::default(); +/// let mut req = MailItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -478,7 +478,7 @@ impl<'a, C, A> MailMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: MailItem = Default::default(); +/// let mut req = MailItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -580,16 +580,20 @@ impl<'a, C, A> MailInsertCall<'a, C, A> where C: BorrowMut, A: oa let mut upload_url: Option = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { diff --git a/gen/adsense1d4-cli/Cargo.toml b/gen/adsense1d4-cli/Cargo.toml index d53daead55..0aeb9b4e39 100644 --- a/gen/adsense1d4-cli/Cargo.toml +++ b/gen/adsense1d4-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-adsense1d4-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/adsense/management/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/adsense1d4-cli/src/cmn.rs b/gen/adsense1d4-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/adsense1d4-cli/src/cmn.rs +++ b/gen/adsense1d4-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/adsense1d4-cli/src/main.rs b/gen/adsense1d4-cli/src/main.rs index e90b07e5b0..da6280de6f 100644 --- a/gen/adsense1d4-cli/src/main.rs +++ b/gen/adsense1d4-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -69,6 +70,12 @@ Configuration: 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. "); mod cmn; @@ -92,7 +99,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adclients_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -130,8 +137,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -142,7 +148,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adunits_customchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -180,8 +186,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -192,7 +197,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adunits_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -224,8 +229,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -236,7 +240,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adunits_get_ad_code(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -268,8 +272,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -280,7 +283,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().adunits_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -321,8 +324,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -333,7 +335,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().alerts_delete(&self.opt.arg_account_id, &self.opt.arg_alert_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -364,7 +366,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -375,7 +376,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().alerts_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "locale" => { call = call.locale(value.unwrap_or("")); @@ -410,8 +411,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -422,7 +422,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().customchannels_adunits_list(&self.opt.arg_account_id, &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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -463,8 +463,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -475,7 +474,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().customchannels_get(&self.opt.arg_account_id, &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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -507,8 +506,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -519,7 +517,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().customchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -557,8 +555,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -569,7 +566,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().get(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tree" => { call = call.tree(arg_from_str(value.unwrap_or("false"), err, "tree", "boolean")); @@ -604,8 +601,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -616,7 +612,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -654,8 +650,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -666,7 +661,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().payments_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -698,8 +693,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -711,7 +705,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.accounts().reports_generate(&self.opt.arg_account_id, &self.opt.arg_start_date, &self.opt.arg_end_date); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "use-timezone-reporting" => { call = call.use_timezone_reporting(arg_from_str(value.unwrap_or("false"), err, "use-timezone-reporting", "boolean")); @@ -773,9 +767,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -789,7 +782,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().reports_saved_generate(&self.opt.arg_account_id, &self.opt.arg_saved_report_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -830,8 +823,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -842,7 +834,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().reports_saved_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -880,8 +872,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -892,7 +883,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().savedadstyles_get(&self.opt.arg_account_id, &self.opt.arg_saved_ad_style_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -924,8 +915,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -936,7 +926,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().savedadstyles_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -974,8 +964,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -986,7 +975,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().urlchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1024,8 +1013,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1036,7 +1024,7 @@ impl Engine { -> Option { let mut call = self.hub.adclients().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1074,8 +1062,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1086,7 +1073,7 @@ impl Engine { -> Option { let mut call = self.hub.adunits().customchannels_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1124,8 +1111,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1136,7 +1122,7 @@ impl Engine { -> Option { let mut call = self.hub.adunits().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1168,8 +1154,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1180,7 +1165,7 @@ impl Engine { -> Option { let mut call = self.hub.adunits().get_ad_code(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1212,8 +1197,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1224,7 +1208,7 @@ impl Engine { -> Option { let mut call = self.hub.adunits().list(&self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1265,8 +1249,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1277,7 +1260,7 @@ impl Engine { -> Option { let mut call = self.hub.alerts().delete(&self.opt.arg_alert_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1308,7 +1291,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1319,7 +1301,7 @@ impl Engine { -> Option { let mut call = self.hub.alerts().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "locale" => { call = call.locale(value.unwrap_or("")); @@ -1354,8 +1336,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1366,7 +1347,7 @@ impl Engine { -> Option { let mut call = self.hub.customchannels().adunits_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1407,8 +1388,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1419,7 +1399,7 @@ impl Engine { -> Option { let mut call = self.hub.customchannels().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1451,8 +1431,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1463,7 +1442,7 @@ impl Engine { -> Option { let mut call = self.hub.customchannels().list(&self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1501,8 +1480,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1513,7 +1491,7 @@ impl Engine { -> Option { let mut call = self.hub.metadata().dimensions_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1545,8 +1523,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1557,7 +1534,7 @@ impl Engine { -> Option { let mut call = self.hub.metadata().metrics_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1589,8 +1566,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1601,7 +1577,7 @@ impl Engine { -> Option { let mut call = self.hub.payments().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1633,8 +1609,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1646,7 +1621,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.reports().generate(&self.opt.arg_start_date, &self.opt.arg_end_date); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "use-timezone-reporting" => { call = call.use_timezone_reporting(arg_from_str(value.unwrap_or("false"), err, "use-timezone-reporting", "boolean")); @@ -1711,9 +1686,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -1727,7 +1701,7 @@ impl Engine { -> Option { let mut call = self.hub.reports().saved_generate(&self.opt.arg_saved_report_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -1768,8 +1742,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1780,7 +1753,7 @@ impl Engine { -> Option { let mut call = self.hub.reports().saved_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1818,8 +1791,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1830,7 +1802,7 @@ impl Engine { -> Option { let mut call = self.hub.savedadstyles().get(&self.opt.arg_saved_ad_style_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1862,8 +1834,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1874,7 +1845,7 @@ impl Engine { -> Option { let mut call = self.hub.savedadstyles().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1912,8 +1883,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1924,7 +1894,7 @@ impl Engine { -> Option { let mut call = self.hub.urlchannels().list(&self.opt.arg_ad_client_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1962,8 +1932,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2017,13 +1986,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_adclients { + } + else if self.opt.cmd_adclients { if self.opt.cmd_list { call_result = self._adclients_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_adunits { + } + else if self.opt.cmd_adunits { if self.opt.cmd_customchannels_list { call_result = self._adunits_customchannels_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2035,7 +2006,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_alerts { + } + else if self.opt.cmd_alerts { if self.opt.cmd_delete { call_result = self._alerts_delete(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2043,7 +2015,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_customchannels { + } + else if self.opt.cmd_customchannels { if self.opt.cmd_adunits_list { call_result = self._customchannels_adunits_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2053,7 +2026,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_metadata { + } + else if self.opt.cmd_metadata { if self.opt.cmd_dimensions_list { call_result = self._metadata_dimensions_list(dry_run, &mut err); } else if self.opt.cmd_metrics_list { @@ -2061,13 +2035,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_payments { + } + else if self.opt.cmd_payments { if self.opt.cmd_list { call_result = self._payments_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_reports { if self.opt.cmd_generate { call_result = self._reports_generate(dry_run, &mut err); } else if self.opt.cmd_saved_generate { @@ -2077,7 +2053,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_savedadstyles { + } + else if self.opt.cmd_savedadstyles { if self.opt.cmd_get { call_result = self._savedadstyles_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2085,7 +2062,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_urlchannels { + } + else if self.opt.cmd_urlchannels { if self.opt.cmd_list { call_result = self._urlchannels_list(dry_run, &mut err); } else { @@ -2111,21 +2089,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "adsense1d4-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "adsense1d4-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "adsense1d4", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "adsense1d4", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AdSense::new(hyper::Client::new(), auth), + hub: api::AdSense::new(client, auth), }; match engine._doit(true) { @@ -2145,12 +2139,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/adsense1d4/Cargo.toml b/gen/adsense1d4/Cargo.toml index 6f644b0fae..494ec452d3 100644 --- a/gen/adsense1d4/Cargo.toml +++ b/gen/adsense1d4/Cargo.toml @@ -5,7 +5,7 @@ name = "google-adsense1d4" version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/adsense/management/" diff --git a/gen/adsense1d4/src/cmn.rs b/gen/adsense1d4/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/adsense1d4/src/cmn.rs +++ b/gen/adsense1d4/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/adsense1d4/src/lib.rs b/gen/adsense1d4/src/lib.rs index 9287d7ff13..6cd8a08cf9 100644 --- a/gen/adsense1d4/src/lib.rs +++ b/gen/adsense1d4/src/lib.rs @@ -424,13 +424,13 @@ impl<'a, C, A> AdSense pub struct UrlChannels { /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The URL channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#urlChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for UrlChannels {} @@ -466,18 +466,18 @@ impl ResponseResult for UrlChannels {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Account { /// Kind of resource this is, in this case adsense#account. - pub kind: String, + pub kind: Option, /// Whether this account is premium. - pub premium: bool, + pub premium: Option, /// Name of this account. - pub name: String, + pub name: Option, /// AdSense timezone of this account. - pub timezone: String, + pub timezone: Option, /// Unique identifier of this account. - pub id: String, + pub id: Option, /// Sub accounts of the this account. #[serde(rename="subAccounts")] - pub sub_accounts: Vec, + pub sub_accounts: Option>, } impl Resource for Account {} @@ -500,13 +500,13 @@ impl ResponseResult for Account {} pub struct AdUnits { /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The ad units returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#adUnits. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for AdUnits {} @@ -519,9 +519,9 @@ impl ResponseResult for AdUnits {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyleFont { /// The family of the font. - pub family: String, + pub family: Option, /// The size of the font. - pub size: String, + pub size: Option, } impl NestedType for AdStyleFont {} @@ -544,25 +544,25 @@ impl Part for AdStyleFont {} pub struct AdsenseReportsGenerateResponse { /// The requested start date in yyyy-mm-dd format. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option, /// Kind this is, in this case adsense#report. - pub kind: String, + pub kind: Option, /// The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request. The dimension cells contain strings, and the metric cells contain numbers. - pub rows: Vec>, + pub rows: Option>>, /// The requested end date in yyyy-mm-dd format. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option, /// Any warnings associated with generation of the report. - pub warnings: Vec, + pub warnings: Option>, /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub totals: Vec, + pub totals: Option>, /// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request. - pub headers: Vec, + pub headers: Option>, /// The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit. #[serde(rename="totalMatchedRows")] - pub total_matched_rows: String, + pub total_matched_rows: Option, /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub averages: Vec, + pub averages: Option>, } impl ResponseResult for AdsenseReportsGenerateResponse {} @@ -575,12 +575,12 @@ impl ResponseResult for AdsenseReportsGenerateResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdsenseReportsGenerateResponseHeaders { /// The currency of this column. Only present if the header type is METRIC_CURRENCY. - pub currency: String, + pub currency: Option, /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The name of the header. - pub name: String, + pub name: Option, } impl NestedType for AdsenseReportsGenerateResponseHeaders {} @@ -595,15 +595,15 @@ impl Part for AdsenseReportsGenerateResponseHeaders {} pub struct AdUnitMobileContentAdsSettings { /// The scripting language to use for this ad unit. #[serde(rename="scriptingLanguage")] - pub scripting_language: String, + pub scripting_language: Option, /// The markup language to use for this ad unit. #[serde(rename="markupLanguage")] - pub markup_language: String, + pub markup_language: Option, /// Type of this ad unit. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Size of this ad unit. - pub size: String, + pub size: Option, } impl NestedType for AdUnitMobileContentAdsSettings {} @@ -623,9 +623,9 @@ impl Part for AdUnitMobileContentAdsSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Alerts { /// The alerts returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#alerts. - pub kind: String, + pub kind: Option, } impl ResponseResult for Alerts {} @@ -638,11 +638,11 @@ impl ResponseResult for Alerts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SavedReport { /// Kind of resource this is, in this case adsense#savedReport. - pub kind: String, + pub kind: Option, /// Unique identifier of this saved report. - pub id: String, + pub id: Option, /// This saved report's name. - pub name: String, + pub name: Option, } impl Part for SavedReport {} @@ -656,20 +656,20 @@ impl Part for SavedReport {} pub struct AdClient { /// ARC review mode this ad client is in. Empty if the client is not opted in to ARC. Possible values: POST_REVIEW, AUTOMATIC_PRE_REVIEW. #[serde(rename="arcReviewMode")] - pub arc_review_mode: String, + pub arc_review_mode: Option, /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension. #[serde(rename="productCode")] - pub product_code: String, + pub product_code: Option, /// Kind of resource this is, in this case adsense#adClient. - pub kind: String, + pub kind: Option, /// Whether this ad client is opted in to ARC. #[serde(rename="arcOptIn")] - pub arc_opt_in: bool, + pub arc_opt_in: Option, /// Whether this ad client supports being reported on. #[serde(rename="supportsReporting")] - pub supports_reporting: bool, + pub supports_reporting: Option, /// Unique identifier of this ad client. - pub id: String, + pub id: Option, } impl Part for AdClient {} @@ -682,12 +682,12 @@ impl Part for AdClient {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdUnitContentAdsSettingsBackupOption { /// Color to use when type is set to COLOR. - pub color: String, + pub color: Option, /// URL to use when type is set to URL. - pub url: String, + pub url: Option, /// Type of the backup option. Possible values are BLANK, COLOR and URL. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for AdUnitContentAdsSettingsBackupOption {} @@ -702,15 +702,15 @@ impl Part for AdUnitContentAdsSettingsBackupOption {} pub struct AdUnitFeedAdsSettings { /// The minimum length an entry should be in order to have attached ads. #[serde(rename="minimumWordCount")] - pub minimum_word_count: i32, + pub minimum_word_count: Option, /// The frequency at which ads should appear in the feed (i.e. every N entries). - pub frequency: i32, + pub frequency: Option, /// The position of the ads relative to the feed entries. #[serde(rename="adPosition")] - pub ad_position: String, + pub ad_position: Option, /// The type of ads which should appear. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for AdUnitFeedAdsSettings {} @@ -730,9 +730,9 @@ impl Part for AdUnitFeedAdsSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Payments { /// The list of Payments for the account. One or both of a) the account's most recent payment; and b) the account's upcoming payment. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#payments. - pub kind: String, + pub kind: Option, } impl ResponseResult for Payments {} @@ -746,23 +746,23 @@ impl ResponseResult for Payments {} pub struct ReportingMetadataEntry { /// The names of the metrics which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted. #[serde(rename="requiredMetrics")] - pub required_metrics: Vec, + pub required_metrics: Option>, /// Kind of resource this is, in this case adsense#reportingMetadataEntry. - pub kind: String, + pub kind: Option, /// The names of the metrics the dimension or metric this reporting metadata entry describes is compatible with. #[serde(rename="compatibleMetrics")] - pub compatible_metrics: Vec, + pub compatible_metrics: Option>, /// For metrics this is a list of dimension IDs which the metric is compatible with, for dimensions it is a list of compatibility groups the dimension belongs to. #[serde(rename="compatibleDimensions")] - pub compatible_dimensions: Vec, + pub compatible_dimensions: Option>, /// Unique identifier of this reporting metadata entry, corresponding to the name of the appropriate dimension or metric. - pub id: String, + pub id: Option, /// The names of the dimensions which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted. #[serde(rename="requiredDimensions")] - pub required_dimensions: Vec, + pub required_dimensions: Option>, /// The codes of the projects supported by the dimension or metric this reporting metadata entry describes. #[serde(rename="supportedProducts")] - pub supported_products: Vec, + pub supported_products: Option>, } impl Part for ReportingMetadataEntry {} @@ -775,15 +775,15 @@ impl Part for ReportingMetadataEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomChannelTargetingInfo { /// The external description of the channel. - pub description: String, + pub description: Option, /// The language of the sites ads will be displayed on. #[serde(rename="siteLanguage")] - pub site_language: String, + pub site_language: Option, /// The locations in which ads appear. (Only valid for content and mobile content ads). Acceptable values for content ads are: TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT, MULTIPLE_LOCATIONS. Acceptable values for mobile content ads are: TOP, MIDDLE, BOTTOM, MULTIPLE_LOCATIONS. - pub location: String, + pub location: Option, /// The name used to describe this channel externally. #[serde(rename="adsAppearOn")] - pub ads_appear_on: String, + pub ads_appear_on: Option, } impl NestedType for CustomChannelTargetingInfo {} @@ -806,13 +806,13 @@ impl Part for CustomChannelTargetingInfo {} pub struct CustomChannels { /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The custom channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#customChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for CustomChannels {} @@ -825,12 +825,12 @@ impl ResponseResult for CustomChannels {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlChannel { /// Kind of resource this is, in this case adsense#urlChannel. - pub kind: String, + pub kind: Option, /// Unique identifier of this URL channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home #[serde(rename="urlPattern")] - pub url_pattern: String, + pub url_pattern: Option, } impl Part for UrlChannel {} @@ -854,30 +854,30 @@ pub struct AdUnit { /// ACTIVE: Indicates that there has been activity on this ad unit in the last seven days. /// /// INACTIVE: Indicates that there has been no activity on this ad unit in the last seven days. - pub status: String, + pub status: Option, /// Kind of resource this is, in this case adsense#adUnit. - pub kind: String, + pub kind: Option, /// Identity code of this ad unit, not necessarily unique across ad clients. - pub code: String, + pub code: Option, /// Name of this ad unit. - pub name: String, + pub name: Option, /// Settings specific to feed ads (AFF). #[serde(rename="feedAdsSettings")] - pub feed_ads_settings: AdUnitFeedAdsSettings, + pub feed_ads_settings: Option, /// ID of the saved ad style which holds this ad unit's style information. #[serde(rename="savedStyleId")] - pub saved_style_id: String, + pub saved_style_id: Option, /// Settings specific to content ads (AFC) and highend mobile content ads (AFMC). #[serde(rename="contentAdsSettings")] - pub content_ads_settings: AdUnitContentAdsSettings, + pub content_ads_settings: Option, /// Unique identifier of this ad unit. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// Settings specific to WAP mobile content ads (AFMC). #[serde(rename="mobileContentAdsSettings")] - pub mobile_content_ads_settings: AdUnitMobileContentAdsSettings, + pub mobile_content_ads_settings: Option, /// Custom style information specific to this ad unit. #[serde(rename="customStyle")] - pub custom_style: AdStyle, + pub custom_style: Option, } impl Resource for AdUnit {} @@ -898,13 +898,13 @@ impl ResponseResult for AdUnit {} pub struct AdClients { /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The ad clients returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#adClients. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for AdClients {} @@ -917,13 +917,13 @@ impl ResponseResult for AdClients {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyle { /// The style of the corners in the ad. - pub corners: String, + pub corners: Option, /// The colors which are included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash. - pub colors: AdStyleColors, + pub colors: Option, /// The font which is included in the style. - pub font: AdStyleFont, + pub font: Option, /// Kind this is, in this case adsense#adStyle. - pub kind: String, + pub kind: Option, } impl Part for AdStyle {} @@ -936,15 +936,15 @@ impl Part for AdStyle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyleColors { /// The color of the ad url. - pub url: String, + pub url: Option, /// The color of the ad text. - pub text: String, + pub text: Option, /// The color of the ad border. - pub border: String, + pub border: Option, /// The color of the ad background. - pub background: String, + pub background: Option, /// The color of the ad title. - pub title: String, + pub title: Option, } impl NestedType for AdStyleColors {} @@ -965,13 +965,13 @@ impl Part for AdStyleColors {} pub struct SavedReports { /// Continuation token used to page through saved reports. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The saved reports returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#savedReports. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for SavedReports {} @@ -991,13 +991,13 @@ impl ResponseResult for SavedReports {} pub struct SavedAdStyles { /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The saved ad styles returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#savedAdStyles. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for SavedAdStyles {} @@ -1047,16 +1047,16 @@ impl Resource for Alert {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomChannel { /// Kind of resource this is, in this case adsense#customChannel. - pub kind: String, + pub kind: Option, /// Code of this custom channel, not necessarily unique across ad clients. - pub code: String, + pub code: Option, /// The targeting information of this custom channel, if activated. #[serde(rename="targetingInfo")] - pub targeting_info: CustomChannelTargetingInfo, + pub targeting_info: Option, /// Unique identifier of this custom channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// Name of this custom channel. - pub name: String, + pub name: Option, } impl Resource for CustomChannel {} @@ -1076,13 +1076,13 @@ impl ResponseResult for CustomChannel {} pub struct Accounts { /// Continuation token used to page through accounts. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The accounts returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#accounts. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for Accounts {} @@ -1096,12 +1096,12 @@ impl ResponseResult for Accounts {} pub struct AdUnitContentAdsSettings { /// Type of this ad unit. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The backup option to be used in instances where no ad is available. #[serde(rename="backupOption")] - pub backup_option: AdUnitContentAdsSettingsBackupOption, + pub backup_option: Option, /// Size of this ad unit. - pub size: String, + pub size: Option, } impl NestedType for AdUnitContentAdsSettings {} @@ -1121,14 +1121,14 @@ impl Part for AdUnitContentAdsSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SavedAdStyle { /// Kind of resource this is, in this case adsense#savedAdStyle. - pub kind: String, + pub kind: Option, /// Unique identifier of this saved ad style. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format. - pub id: String, + pub id: Option, /// The AdStyle itself. #[serde(rename="adStyle")] - pub ad_style: AdStyle, + pub ad_style: Option, /// The user selected name of this SavedAdStyle. - pub name: String, + pub name: Option, } impl Resource for SavedAdStyle {} @@ -1149,9 +1149,9 @@ impl ResponseResult for SavedAdStyle {} pub struct AdCode { /// The ad code snippet. #[serde(rename="adCode")] - pub ad_code: String, + pub ad_code: Option, /// Kind this is, in this case adsense#adCode. - pub kind: String, + pub kind: Option, } impl ResponseResult for AdCode {} @@ -1170,9 +1170,9 @@ impl ResponseResult for AdCode {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metadata { /// no description provided - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsense#metadata. - pub kind: String, + pub kind: Option, } impl ResponseResult for Metadata {} @@ -2466,16 +2466,20 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2722,16 +2726,20 @@ impl<'a, C, A> AdunitCustomchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2978,16 +2986,20 @@ impl<'a, C, A> AdunitGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3233,16 +3245,20 @@ impl<'a, C, A> AdunitListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3486,16 +3502,20 @@ impl<'a, C, A> AdunitGetAdCodeCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3710,16 +3730,20 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3943,16 +3967,20 @@ impl<'a, C, A> AlertDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4142,16 +4170,20 @@ impl<'a, C, A> AlertListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4353,16 +4385,20 @@ impl<'a, C, A> SavedadstyleListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4587,16 +4623,20 @@ impl<'a, C, A> SavedadstyleGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4801,16 +4841,20 @@ impl<'a, C, A> ReportSavedListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5104,16 +5148,20 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5434,16 +5482,20 @@ impl<'a, C, A> ReportSavedGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5686,16 +5738,20 @@ impl<'a, C, A> AccountAlertDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5921,16 +5977,20 @@ impl<'a, C, A> AccountAlertListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6175,16 +6235,20 @@ impl<'a, C, A> AccountReportSavedGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6420,16 +6484,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6654,16 +6722,20 @@ impl<'a, C, A> AccountPaymentListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6886,16 +6958,20 @@ impl<'a, C, A> AccountSavedadstyleGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7130,16 +7206,20 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7384,16 +7464,20 @@ impl<'a, C, A> AccountCustomchannelGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7653,16 +7737,20 @@ impl<'a, C, A> AccountCustomchannelAdunitListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7934,16 +8022,20 @@ impl<'a, C, A> AccountReportSavedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8190,16 +8282,20 @@ impl<'a, C, A> AccountUrlchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8461,16 +8557,20 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8808,16 +8908,20 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9135,16 +9239,20 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9391,16 +9499,20 @@ impl<'a, C, A> AccountCustomchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9655,16 +9767,20 @@ impl<'a, C, A> AccountSavedadstyleListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9903,16 +10019,20 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10167,16 +10287,20 @@ impl<'a, C, A> AccountAdunitCustomchannelListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10436,16 +10560,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10647,16 +10775,20 @@ impl<'a, C, A> PaymentListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10841,16 +10973,20 @@ impl<'a, C, A> MetadataDimensionListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11035,16 +11171,20 @@ impl<'a, C, A> MetadataMetricListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11257,16 +11397,20 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11507,16 +11651,20 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11768,16 +11916,20 @@ impl<'a, C, A> CustomchannelAdunitListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/adsensehost4d1-cli/Cargo.toml b/gen/adsensehost4d1-cli/Cargo.toml deleted file mode 100644 index 2f890802ba..0000000000 --- a/gen/adsensehost4d1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-adsensehost4d1-cli" -version = "0.0.1+20150326" -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" -homepage = "https://developers.google.com/adsense/host/" -documentation = "http://byron.github.io/google-apis-rs/google_adsensehost4d1_cli" -license = "MIT" -keywords = ["adsensehost", "google", "cli"] - -[[bin]] -name = "adsensehost4d1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-adsensehost4d1] -path = "../adsensehost4d1" diff --git a/gen/adsensehost4d1-cli/README.md b/gen/adsensehost4d1-cli/README.md deleted file mode 100644 index cc58d0fdf2..0000000000 --- a/gen/adsensehost4d1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO ADSENSEHOST:V4.1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/adsensehost4d1-cli/mkdocs.yml b/gen/adsensehost4d1-cli/mkdocs.yml deleted file mode 100644 index 12de3662b9..0000000000 --- a/gen/adsensehost4d1-cli/mkdocs.yml +++ /dev/null @@ -1,42 +0,0 @@ -site_name: AdSense Host v0.0.1+20150326 -site_url: http://byron.github.io/google-apis-rs/google-adsensehost4d1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['accounts_adclients-get.md', 'Accounts', 'Adclients Get'] -- ['accounts_adclients-list.md', 'Accounts', 'Adclients List'] -- ['accounts_adunits-delete.md', 'Accounts', 'Adunits Delete'] -- ['accounts_adunits-get.md', 'Accounts', 'Adunits Get'] -- ['accounts_adunits-get-ad-code.md', 'Accounts', 'Adunits Get Ad Code'] -- ['accounts_adunits-insert.md', 'Accounts', 'Adunits Insert'] -- ['accounts_adunits-list.md', 'Accounts', 'Adunits List'] -- ['accounts_adunits-patch.md', 'Accounts', 'Adunits Patch'] -- ['accounts_adunits-update.md', 'Accounts', 'Adunits Update'] -- ['accounts_get.md', 'Accounts', 'Get'] -- ['accounts_list.md', 'Accounts', 'List'] -- ['accounts_reports-generate.md', 'Accounts', 'Reports Generate'] -- ['adclients_get.md', 'Adclients', 'Get'] -- ['adclients_list.md', 'Adclients', 'List'] -- ['associationsessions_start.md', 'Associationsessions', 'Start'] -- ['associationsessions_verify.md', 'Associationsessions', 'Verify'] -- ['customchannels_delete.md', 'Customchannels', 'Delete'] -- ['customchannels_get.md', 'Customchannels', 'Get'] -- ['customchannels_insert.md', 'Customchannels', 'Insert'] -- ['customchannels_list.md', 'Customchannels', 'List'] -- ['customchannels_patch.md', 'Customchannels', 'Patch'] -- ['customchannels_update.md', 'Customchannels', 'Update'] -- ['reports_generate.md', 'Reports', 'Generate'] -- ['urlchannels_delete.md', 'Urlchannels', 'Delete'] -- ['urlchannels_insert.md', 'Urlchannels', 'Insert'] -- ['urlchannels_list.md', 'Urlchannels', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/adsensehost4d1-cli/src/main.rs b/gen/adsensehost4d1-cli/src/main.rs deleted file mode 100644 index 5144c3b985..0000000000 --- a/gen/adsensehost4d1-cli/src/main.rs +++ /dev/null @@ -1,1906 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_adsensehost4d1 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::AdSenseHost>, -} - - -impl Engine { - fn _accounts_adclients_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adclients_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adclients_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adclients_list(&self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adunits_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adunits_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_get_ad_code(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adunits_get_ad_code(&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); - match key { - "host-custom-channel-id" => { - call = call.add_host_custom_channel_id(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::AdUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_content_ads_settings_init(request: &mut api::AdUnit) { - if request.content_ads_settings.is_none() { - request.content_ads_settings = Some(Default::default()); - } - } - - fn request_custom_style_init(request: &mut api::AdUnit) { - if request.custom_style.is_none() { - request.custom_style = Some(Default::default()); - } - } - - fn request_mobile_content_ads_settings_init(request: &mut api::AdUnit) { - if request.mobile_content_ads_settings.is_none() { - request.mobile_content_ads_settings = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "content-ads-settings.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.color" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.color = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.url" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.url = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.size" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "id" => { - request_content_ads_settings_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "mobile-content-ads-settings.scripting-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().scripting_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.type" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.markup-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().markup_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.size" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "custom-style.corners" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().corners = value.unwrap_or("").to_string(); - }, - "custom-style.colors.url" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.url = value.unwrap_or("").to_string(); - }, - "custom-style.colors.text" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.text = value.unwrap_or("").to_string(); - }, - "custom-style.colors.border" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.border = value.unwrap_or("").to_string(); - }, - "custom-style.colors.background" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.background = value.unwrap_or("").to_string(); - }, - "custom-style.colors.title" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.title = value.unwrap_or("").to_string(); - }, - "custom-style.font.family" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.family = value.unwrap_or("").to_string(); - }, - "custom-style.font.size" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.size = value.unwrap_or("").to_string(); - }, - "custom-style.kind" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().adunits_list(&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); - match key { - "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")); - }, - "include-inactive" => { - call = call.include_inactive(arg_from_str(value.unwrap_or("false"), err, "include-inactive", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::AdUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_content_ads_settings_init(request: &mut api::AdUnit) { - if request.content_ads_settings.is_none() { - request.content_ads_settings = Some(Default::default()); - } - } - - fn request_custom_style_init(request: &mut api::AdUnit) { - if request.custom_style.is_none() { - request.custom_style = Some(Default::default()); - } - } - - fn request_mobile_content_ads_settings_init(request: &mut api::AdUnit) { - if request.mobile_content_ads_settings.is_none() { - request.mobile_content_ads_settings = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "content-ads-settings.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.color" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.color = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.url" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.url = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.size" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "id" => { - request_content_ads_settings_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "mobile-content-ads-settings.scripting-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().scripting_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.type" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.markup-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().markup_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.size" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "custom-style.corners" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().corners = value.unwrap_or("").to_string(); - }, - "custom-style.colors.url" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.url = value.unwrap_or("").to_string(); - }, - "custom-style.colors.text" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.text = value.unwrap_or("").to_string(); - }, - "custom-style.colors.border" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.border = value.unwrap_or("").to_string(); - }, - "custom-style.colors.background" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.background = value.unwrap_or("").to_string(); - }, - "custom-style.colors.title" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.title = value.unwrap_or("").to_string(); - }, - "custom-style.font.family" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.family = value.unwrap_or("").to_string(); - }, - "custom-style.font.size" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.size = value.unwrap_or("").to_string(); - }, - "custom-style.kind" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_adunits_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::AdUnit = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_content_ads_settings_init(request: &mut api::AdUnit) { - if request.content_ads_settings.is_none() { - request.content_ads_settings = Some(Default::default()); - } - } - - fn request_custom_style_init(request: &mut api::AdUnit) { - if request.custom_style.is_none() { - request.custom_style = Some(Default::default()); - } - } - - fn request_mobile_content_ads_settings_init(request: &mut api::AdUnit) { - if request.mobile_content_ads_settings.is_none() { - request.mobile_content_ads_settings = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "code" => { - request.code = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "content-ads-settings.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.color" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.color = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.url" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.url = value.unwrap_or("").to_string(); - }, - "content-ads-settings.backup-option.type" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().backup_option.type_ = value.unwrap_or("").to_string(); - }, - "content-ads-settings.size" => { - request_content_ads_settings_init(&mut request); - request.content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "id" => { - request_content_ads_settings_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "mobile-content-ads-settings.scripting-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().scripting_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.type" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.markup-language" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().markup_language = value.unwrap_or("").to_string(); - }, - "mobile-content-ads-settings.size" => { - request_mobile_content_ads_settings_init(&mut request); - request.mobile_content_ads_settings.as_mut().unwrap().size = value.unwrap_or("").to_string(); - }, - "custom-style.corners" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().corners = value.unwrap_or("").to_string(); - }, - "custom-style.colors.url" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.url = value.unwrap_or("").to_string(); - }, - "custom-style.colors.text" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.text = value.unwrap_or("").to_string(); - }, - "custom-style.colors.border" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.border = value.unwrap_or("").to_string(); - }, - "custom-style.colors.background" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.background = value.unwrap_or("").to_string(); - }, - "custom-style.colors.title" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().colors.title = value.unwrap_or("").to_string(); - }, - "custom-style.font.family" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.family = value.unwrap_or("").to_string(); - }, - "custom-style.font.size" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().font.size = value.unwrap_or("").to_string(); - }, - "custom-style.kind" => { - request_custom_style_init(&mut request); - request.custom_style.as_mut().unwrap().kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().get(&self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().list(&self.opt.arg_filter_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_reports_generate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.accounts().reports_generate(&self.opt.arg_account_id, &self.opt.arg_start_date, &self.opt.arg_end_date); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-index" => { - call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); - }, - "sort" => { - call = call.add_sort(value.unwrap_or("")); - }, - "metric" => { - call = call.add_metric(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "locale" => { - call = call.locale(value.unwrap_or("")); - }, - "filter" => { - call = call.add_filter(value.unwrap_or("")); - }, - "dimension" => { - call = call.add_dimension(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _adclients_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.adclients().get(&self.opt.arg_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _adclients_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.adclients().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _associationsessions_start(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.associationsessions().start(&self.opt.arg_product_code, &self.opt.arg_website_url); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "website-locale" => { - call = call.website_locale(value.unwrap_or("")); - }, - "user-locale" => { - call = call.user_locale(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _associationsessions_verify(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.associationsessions().verify(&self.opt.arg_token); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.customchannels().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.customchannels().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::CustomChannel = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.customchannels().list(&self.opt.arg_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::CustomChannel = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customchannels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::CustomChannel = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _reports_generate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.reports().generate(&self.opt.arg_start_date, &self.opt.arg_end_date); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-index" => { - call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); - }, - "sort" => { - call = call.add_sort(value.unwrap_or("")); - }, - "metric" => { - call = call.add_metric(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "locale" => { - call = call.locale(value.unwrap_or("")); - }, - "filter" => { - call = call.add_filter(value.unwrap_or("")); - }, - "dimension" => { - call = call.add_dimension(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _urlchannels_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.urlchannels().delete(&self.opt.arg_ad_client_id, &self.opt.arg_url_channel_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _urlchannels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::UrlChannel = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _urlchannels_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.urlchannels().list(&self.opt.arg_ad_client_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option, Option) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option; - let mut err_opt: Option = None; - - if self.opt.cmd_accounts { - if self.opt.cmd_adclients_get { - call_result = self._accounts_adclients_get(dry_run, &mut err); - } else if self.opt.cmd_adclients_list { - call_result = self._accounts_adclients_list(dry_run, &mut err); - } else if self.opt.cmd_adunits_delete { - call_result = self._accounts_adunits_delete(dry_run, &mut err); - } else if self.opt.cmd_adunits_get { - call_result = self._accounts_adunits_get(dry_run, &mut err); - } else if self.opt.cmd_adunits_get_ad_code { - call_result = self._accounts_adunits_get_ad_code(dry_run, &mut err); - } else if self.opt.cmd_adunits_insert { - call_result = self._accounts_adunits_insert(dry_run, &mut err); - } else if self.opt.cmd_adunits_list { - call_result = self._accounts_adunits_list(dry_run, &mut err); - } else if self.opt.cmd_adunits_patch { - call_result = self._accounts_adunits_patch(dry_run, &mut err); - } else if self.opt.cmd_adunits_update { - call_result = self._accounts_adunits_update(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._accounts_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._accounts_list(dry_run, &mut err); - } else if self.opt.cmd_reports_generate { - call_result = self._accounts_reports_generate(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_adclients { - if self.opt.cmd_get { - call_result = self._adclients_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._adclients_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_associationsessions { - if self.opt.cmd_start { - call_result = self._associationsessions_start(dry_run, &mut err); - } else if self.opt.cmd_verify { - call_result = self._associationsessions_verify(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_customchannels { - if self.opt.cmd_delete { - call_result = self._customchannels_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._customchannels_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._customchannels_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._customchannels_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._customchannels_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._customchannels_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_reports { - if self.opt.cmd_generate { - call_result = self._reports_generate(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_urlchannels { - if self.opt.cmd_delete { - call_result = self._urlchannels_delete(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._urlchannels_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._urlchannels_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "adsensehost4d1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "adsensehost4d1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::AdSenseHost::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/adsensehost4d1/Cargo.toml b/gen/adsensehost4d1/Cargo.toml index 6937904dbb..c9ff5ea58d 100644 --- a/gen/adsensehost4d1/Cargo.toml +++ b/gen/adsensehost4d1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-adsensehost4d1" -version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/adsense/host/" diff --git a/gen/adsensehost4d1/README.md b/gen/adsensehost4d1/README.md index 1401141a55..99c90bc8f0 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+20150326*, where *20150326* 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.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*. Everything else about the *AdSense Host* *v4d1* API can be found at the [official documentation site](https://developers.google.com/adsense/host/). diff --git a/gen/adsensehost4d1/src/cmn.rs b/gen/adsensehost4d1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/adsensehost4d1/src/cmn.rs +++ b/gen/adsensehost4d1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/adsensehost4d1/src/lib.rs b/gen/adsensehost4d1/src/lib.rs index abc0aea66b..3d6a6d5da7 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+20150326*, where *20150326* 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.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*. //! //! Everything else about the *AdSense Host* *v4d1* API can be found at the //! [official documentation site](https://developers.google.com/adsense/host/). @@ -383,13 +383,13 @@ impl<'a, C, A> AdSenseHost pub struct UrlChannels { /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The URL channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsensehost#urlChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for UrlChannels {} @@ -402,12 +402,12 @@ impl ResponseResult for UrlChannels {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportHeaders { /// The currency of this column. Only present if the header type is METRIC_CURRENCY. - pub currency: String, + pub currency: Option, /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The name of the header. - pub name: String, + pub name: Option, } impl NestedType for ReportHeaders {} @@ -437,13 +437,13 @@ impl Part for ReportHeaders {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Account { /// Approval status of this account. One of: PENDING, APPROVED, DISABLED. - pub status: String, + pub status: Option, /// Kind of resource this is, in this case adsensehost#account. - pub kind: String, + pub kind: Option, /// Unique identifier of this account. - pub id: String, + pub id: Option, /// Name of this account. - pub name: String, + pub name: Option, } impl Resource for Account {} @@ -463,13 +463,13 @@ impl ResponseResult for Account {} pub struct AdUnits { /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The ad units returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsensehost#adUnits. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for AdUnits {} @@ -489,13 +489,13 @@ impl ResponseResult for AdUnits {} pub struct AdClients { /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The ad clients returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsensehost#adClients. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for AdClients {} @@ -508,13 +508,13 @@ impl ResponseResult for AdClients {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyle { /// The style of the corners in the ad. Possible values are SQUARE, SLIGHTLY_ROUNDED and VERY_ROUNDED. - pub corners: String, + pub corners: Option, /// The colors included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash. - pub colors: AdStyleColors, + pub colors: Option, /// The font which is included in the style. - pub font: AdStyleFont, + pub font: Option, /// Kind this is, in this case adsensehost#adStyle. - pub kind: String, + pub kind: Option, } impl Part for AdStyle {} @@ -527,15 +527,15 @@ impl Part for AdStyle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyleColors { /// The color of the ad url. - pub url: String, + pub url: Option, /// The color of the ad text. - pub text: String, + pub text: Option, /// The color of the ad border. - pub border: String, + pub border: Option, /// The color of the ad background. - pub background: String, + pub background: Option, /// The color of the ad title. - pub title: String, + pub title: Option, } impl NestedType for AdStyleColors {} @@ -550,15 +550,15 @@ impl Part for AdStyleColors {} pub struct AdUnitMobileContentAdsSettings { /// The scripting language to use for this ad unit. #[serde(rename="scriptingLanguage")] - pub scripting_language: String, + pub scripting_language: Option, /// The markup language to use for this ad unit. #[serde(rename="markupLanguage")] - pub markup_language: String, + pub markup_language: Option, /// Type of this ad unit. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Size of this ad unit. - pub size: String, + pub size: Option, } impl NestedType for AdUnitMobileContentAdsSettings {} @@ -578,9 +578,9 @@ impl Part for AdUnitMobileContentAdsSettings {} pub struct AdCode { /// The ad code snippet. #[serde(rename="adCode")] - pub ad_code: String, + pub ad_code: Option, /// Kind this is, in this case adsensehost#adCode. - pub kind: String, + pub kind: Option, } impl ResponseResult for AdCode {} @@ -671,17 +671,17 @@ impl ResponseResult for UrlChannel {} pub struct AdClient { /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension. #[serde(rename="productCode")] - pub product_code: String, + pub product_code: Option, /// Kind of resource this is, in this case adsensehost#adClient. - pub kind: String, + pub kind: Option, /// Unique identifier of this ad client. - pub id: String, + pub id: Option, /// Whether this ad client is opted in to ARC. #[serde(rename="arcOptIn")] - pub arc_opt_in: bool, + pub arc_opt_in: Option, /// Whether this ad client supports being reported on. #[serde(rename="supportsReporting")] - pub supports_reporting: bool, + pub supports_reporting: Option, } impl Resource for AdClient {} @@ -695,12 +695,12 @@ impl ResponseResult for AdClient {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdUnitContentAdsSettingsBackupOption { /// Color to use when type is set to COLOR. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash. - pub color: String, + pub color: Option, /// URL to use when type is set to URL. - pub url: String, + pub url: Option, /// Type of the backup option. Possible values are BLANK, COLOR and URL. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for AdUnitContentAdsSettingsBackupOption {} @@ -720,29 +720,29 @@ impl Part for AdUnitContentAdsSettingsBackupOption {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AssociationSession { /// Status of the completed association, available once the association callback token has been verified. One of ACCEPTED, REJECTED, or ERROR. - pub status: String, + pub status: Option, /// The products to associate with the user. Options: AFC, AFF, AFS, AFMC #[serde(rename="productCodes")] - pub product_codes: Vec, + pub product_codes: Option>, /// Kind of resource this is, in this case adsensehost#associationSession. - pub kind: String, + pub kind: Option, /// The preferred locale of the user themselves when going through the AdSense association flow. #[serde(rename="userLocale")] - pub user_locale: String, + pub user_locale: Option, /// The locale of the user's hosted website. #[serde(rename="websiteLocale")] - pub website_locale: String, + pub website_locale: Option, /// Redirect URL of this association session. Used to redirect users into the AdSense association flow. #[serde(rename="redirectUrl")] - pub redirect_url: String, + pub redirect_url: Option, /// The URL of the user's hosted website. #[serde(rename="websiteUrl")] - pub website_url: String, + pub website_url: Option, /// Unique identifier of this association session. - pub id: String, + pub id: Option, /// Hosted account id of the associated publisher after association. Present if status is ACCEPTED. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl Resource for AssociationSession {} @@ -761,11 +761,11 @@ impl ResponseResult for AssociationSession {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Accounts { /// The accounts returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsensehost#accounts. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for Accounts {} @@ -779,12 +779,12 @@ impl ResponseResult for Accounts {} pub struct AdUnitContentAdsSettings { /// Type of this ad unit. Possible values are TEXT, TEXT_IMAGE, IMAGE and LINK. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The backup option to be used in instances where no ad is available. #[serde(rename="backupOption")] - pub backup_option: AdUnitContentAdsSettingsBackupOption, + pub backup_option: Option, /// Size of this ad unit. Size values are in the form SIZE_{width}_{height}. - pub size: String, + pub size: Option, } impl NestedType for AdUnitContentAdsSettings {} @@ -798,9 +798,9 @@ impl Part for AdUnitContentAdsSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdStyleFont { /// The family of the font. Possible values are: ACCOUNT_DEFAULT_FAMILY, ADSENSE_DEFAULT_FAMILY, ARIAL, TIMES and VERDANA. - pub family: String, + pub family: Option, /// The size of the font. Possible values are: ACCOUNT_DEFAULT_SIZE, ADSENSE_DEFAULT_SIZE, SMALL, MEDIUM and LARGE. - pub size: String, + pub size: Option, } impl NestedType for AdStyleFont {} @@ -820,20 +820,20 @@ impl Part for AdStyleFont {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request. - pub headers: Vec, + pub headers: Option>, /// Kind this is, in this case adsensehost#report. - pub kind: String, + pub kind: Option, /// The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request. The dimension cells contain strings, and the metric cells contain numbers. - pub rows: Vec>, + pub rows: Option>>, /// The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit. #[serde(rename="totalMatchedRows")] - pub total_matched_rows: String, + pub total_matched_rows: Option, /// Any warnings associated with generation of the report. - pub warnings: Vec, + pub warnings: Option>, /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub averages: Vec, + pub averages: Option>, /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty. - pub totals: Vec, + pub totals: Option>, } impl Resource for Report {} @@ -883,13 +883,13 @@ impl ResponseResult for CustomChannel {} pub struct CustomChannels { /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The custom channels returned in this list response. - pub items: Vec, + pub items: Option>, /// Kind of list this is, in this case adsensehost#customChannels. - pub kind: String, + pub kind: Option, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option, } impl ResponseResult for CustomChannels {} @@ -1698,7 +1698,7 @@ impl<'a, C, A> CustomchannelMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UrlChannel = Default::default(); +/// let mut req = UrlChannel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1790,16 +1790,20 @@ impl<'a, C, A> UrlchannelInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2035,16 +2039,20 @@ impl<'a, C, A> UrlchannelDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2285,16 +2293,20 @@ impl<'a, C, A> UrlchannelListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2513,16 +2525,20 @@ impl<'a, C, A> AdclientListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2747,16 +2763,20 @@ impl<'a, C, A> AdclientGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2971,16 +2991,20 @@ impl<'a, C, A> AssociationsessionStartCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3202,16 +3226,20 @@ impl<'a, C, A> AssociationsessionVerifyCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3461,16 +3489,20 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3771,16 +3803,20 @@ impl<'a, C, A> AccountAdunitListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4014,16 +4050,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4258,16 +4298,20 @@ impl<'a, C, A> AccountAdunitGetAdCodeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4571,16 +4615,20 @@ impl<'a, C, A> AccountReportGenerateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4878,16 +4926,20 @@ impl<'a, C, A> AccountAdunitDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5138,16 +5190,20 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5301,7 +5357,7 @@ impl<'a, C, A> AccountAdclientListCall<'a, C, A> where C: BorrowMut AccountAdunitPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5662,16 +5722,20 @@ impl<'a, C, A> AccountAdclientGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5902,16 +5966,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6051,7 +6119,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AdUnit = Default::default(); +/// let mut req = AdUnit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6145,16 +6213,20 @@ impl<'a, C, A> AccountAdunitInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6402,16 +6474,20 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6571,7 +6647,7 @@ impl<'a, C, A> AccountAdunitGetCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AdUnit = Default::default(); +/// let mut req = AdUnit::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6665,16 +6741,20 @@ impl<'a, C, A> AccountAdunitUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6920,16 +7000,20 @@ impl<'a, C, A> CustomchannelGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7162,16 +7246,20 @@ impl<'a, C, A> CustomchannelDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7321,7 +7409,7 @@ impl<'a, C, A> CustomchannelDeleteCall<'a, C, A> where C: BorrowMut CustomchannelUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7666,16 +7758,20 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7829,7 +7925,7 @@ impl<'a, C, A> CustomchannelListCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CustomChannel = Default::default(); +/// let mut req = CustomChannel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7923,16 +8019,20 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8095,7 +8195,7 @@ impl<'a, C, A> CustomchannelPatchCall<'a, C, A> where C: BorrowMut CustomchannelInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/analytics3-cli/Cargo.toml b/gen/analytics3-cli/Cargo.toml index c989132652..5c527e477e 100644 --- a/gen/analytics3-cli/Cargo.toml +++ b/gen/analytics3-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-analytics3-cli" -version = "0.0.1+20150308" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/analytics/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/analytics3-cli/mkdocs.yml b/gen/analytics3-cli/mkdocs.yml index 92e7661763..45e39ee2b2 100644 --- a/gen/analytics3-cli/mkdocs.yml +++ b/gen/analytics3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: analytics v0.0.1+20150308 +site_name: analytics v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/analytics3-cli/src/cmn.rs +++ b/gen/analytics3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/analytics3-cli/src/main.rs b/gen/analytics3-cli/src/main.rs index b20c70143f..8e028baeef 100644 --- a/gen/analytics3-cli/src/main.rs +++ b/gen/analytics3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -109,6 +110,12 @@ Configuration: 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. "); mod cmn; @@ -132,7 +139,7 @@ impl Engine { -> Option { let mut call = self.hub.data().ga_get(&self.opt.arg_ids, &self.opt.arg_start_date, &self.opt.arg_end_date, &self.opt.arg_metrics); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -188,8 +195,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -200,7 +206,7 @@ impl Engine { -> Option { let mut call = self.hub.data().mcf_get(&self.opt.arg_ids, &self.opt.arg_start_date, &self.opt.arg_end_date, &self.opt.arg_metrics); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -250,8 +256,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -262,7 +267,7 @@ impl Engine { -> Option { let mut call = self.hub.data().realtime_get(&self.opt.arg_ids, &self.opt.arg_metrics); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort" => { call = call.sort(value.unwrap_or("")); @@ -306,8 +311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -318,7 +322,7 @@ impl Engine { -> Option { let mut call = self.hub.management().account_summaries_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -356,8 +360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -368,7 +371,7 @@ impl Engine { -> Option { let mut call = self.hub.management().account_user_links_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -399,7 +402,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -408,10 +410,10 @@ impl Engine { fn _management_account_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -431,18 +433,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -460,84 +484,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -549,11 +573,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -572,8 +602,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -584,7 +613,7 @@ impl Engine { -> Option { let mut call = self.hub.management().account_user_links_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -622,8 +651,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -632,10 +660,10 @@ impl Engine { fn _management_account_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -655,18 +683,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -684,84 +734,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -773,11 +823,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -796,8 +852,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -808,7 +863,7 @@ impl Engine { -> Option { let mut call = self.hub.management().accounts_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -846,8 +901,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -858,7 +912,7 @@ impl Engine { -> Option { let mut call = self.hub.management().custom_data_sources_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -896,8 +950,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -908,7 +961,7 @@ impl Engine { -> Option { let mut call = self.hub.management().custom_dimensions_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -940,8 +993,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -950,10 +1002,10 @@ impl Engine { fn _management_custom_dimensions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomDimension = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -973,9 +1025,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1012,11 +1065,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "id" => { request_parent_link_init(&mut request); @@ -1047,8 +1100,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1059,7 +1111,7 @@ impl Engine { -> Option { let mut call = self.hub.management().custom_dimensions_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -1097,8 +1149,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1107,10 +1158,10 @@ impl Engine { fn _management_custom_dimensions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomDimension = Default::default(); + 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); + 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")); @@ -1133,9 +1184,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1172,11 +1224,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "id" => { request_parent_link_init(&mut request); @@ -1207,8 +1259,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1217,10 +1268,10 @@ impl Engine { fn _management_custom_dimensions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomDimension = Default::default(); + 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); + 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")); @@ -1243,9 +1294,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1282,11 +1334,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "id" => { request_parent_link_init(&mut request); @@ -1317,8 +1369,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1329,7 +1380,7 @@ impl Engine { -> Option { let mut call = self.hub.management().custom_metrics_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1361,8 +1412,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1371,10 +1421,10 @@ impl Engine { fn _management_custom_metrics_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomMetric = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1394,9 +1444,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1439,11 +1490,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -1478,8 +1529,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1490,7 +1540,7 @@ impl Engine { -> Option { let mut call = self.hub.management().custom_metrics_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -1528,8 +1578,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1538,10 +1587,10 @@ impl Engine { fn _management_custom_metrics_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomMetric = Default::default(); + 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); + 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")); @@ -1564,9 +1613,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1609,11 +1659,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -1648,8 +1698,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1658,10 +1707,10 @@ impl Engine { fn _management_custom_metrics_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CustomMetric = Default::default(); + 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); + 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")); @@ -1684,9 +1733,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1729,11 +1779,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -1768,8 +1818,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1780,7 +1829,7 @@ impl Engine { -> Option { let mut call = self.hub.management().experiments_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1811,7 +1860,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1822,7 +1870,7 @@ impl Engine { -> Option { let mut call = self.hub.management().experiments_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1854,8 +1902,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1864,10 +1911,10 @@ impl Engine { fn _management_experiments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Experiment = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1887,9 +1934,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1974,11 +2022,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "end-time" => { request_parent_link_init(&mut request); @@ -2005,8 +2053,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2017,7 +2064,7 @@ impl Engine { -> Option { let mut call = self.hub.management().experiments_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2055,8 +2102,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2065,10 +2111,10 @@ impl Engine { fn _management_experiments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Experiment = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2088,9 +2134,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2175,11 +2222,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "end-time" => { request_parent_link_init(&mut request); @@ -2206,8 +2253,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2216,10 +2262,10 @@ impl Engine { fn _management_experiments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Experiment = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2239,9 +2285,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2326,11 +2373,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "end-time" => { request_parent_link_init(&mut request); @@ -2357,8 +2404,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2369,7 +2415,7 @@ impl Engine { -> Option { let mut call = self.hub.management().filters_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2401,8 +2447,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2413,7 +2458,7 @@ impl Engine { -> Option { let mut call = self.hub.management().filters_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2445,8 +2490,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2455,10 +2499,10 @@ impl Engine { fn _management_filters_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Filter = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2478,9 +2522,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2538,7 +2583,7 @@ impl Engine { }, "uppercase-details.field" => { request_uppercase_details_init(&mut request); - request.uppercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.uppercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "updated" => { request_uppercase_details_init(&mut request); @@ -2546,111 +2591,111 @@ impl Engine { }, "advanced-details.extract-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.override-output-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().override_output_field = arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean"); + request.advanced_details.as_mut().unwrap().override_output_field = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean")); }, "advanced-details.field-a-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_a_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean")); }, "advanced-details.output-constructor" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_constructor = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_constructor = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-b-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_b_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean")); }, "advanced-details.case-sensitive" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean"); + request.advanced_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean")); }, "advanced-details.field-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.extract-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.output-to-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_to_field = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_to_field = Some(value.unwrap_or("").to_string()); }, "lowercase-details.field" => { request_lowercase_details_init(&mut request); - request.lowercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.lowercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.case-sensitive" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean"); + request.search_and_replace_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean")); }, "search-and-replace-details.search-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().search_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().search_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.replace-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().replace_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().replace_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.field" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "exclude-details.case-sensitive" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean"); + request.exclude_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean")); }, "exclude-details.kind" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "exclude-details.match-type" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "exclude-details.expression-value" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "exclude-details.field" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "include-details.case-sensitive" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean"); + request.include_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean")); }, "include-details.kind" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "include-details.match-type" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "include-details.expression-value" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "include-details.field" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -2685,8 +2730,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2697,7 +2741,7 @@ impl Engine { -> Option { let mut call = self.hub.management().filters_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2735,8 +2779,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2745,10 +2788,10 @@ impl Engine { fn _management_filters_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Filter = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2768,9 +2811,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2828,7 +2872,7 @@ impl Engine { }, "uppercase-details.field" => { request_uppercase_details_init(&mut request); - request.uppercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.uppercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "updated" => { request_uppercase_details_init(&mut request); @@ -2836,111 +2880,111 @@ impl Engine { }, "advanced-details.extract-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.override-output-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().override_output_field = arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean"); + request.advanced_details.as_mut().unwrap().override_output_field = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean")); }, "advanced-details.field-a-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_a_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean")); }, "advanced-details.output-constructor" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_constructor = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_constructor = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-b-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_b_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean")); }, "advanced-details.case-sensitive" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean"); + request.advanced_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean")); }, "advanced-details.field-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.extract-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.output-to-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_to_field = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_to_field = Some(value.unwrap_or("").to_string()); }, "lowercase-details.field" => { request_lowercase_details_init(&mut request); - request.lowercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.lowercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.case-sensitive" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean"); + request.search_and_replace_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean")); }, "search-and-replace-details.search-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().search_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().search_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.replace-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().replace_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().replace_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.field" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "exclude-details.case-sensitive" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean"); + request.exclude_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean")); }, "exclude-details.kind" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "exclude-details.match-type" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "exclude-details.expression-value" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "exclude-details.field" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "include-details.case-sensitive" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean"); + request.include_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean")); }, "include-details.kind" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "include-details.match-type" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "include-details.expression-value" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "include-details.field" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -2975,8 +3019,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2985,10 +3028,10 @@ impl Engine { fn _management_filters_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Filter = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3008,9 +3051,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3068,7 +3112,7 @@ impl Engine { }, "uppercase-details.field" => { request_uppercase_details_init(&mut request); - request.uppercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.uppercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "updated" => { request_uppercase_details_init(&mut request); @@ -3076,111 +3120,111 @@ impl Engine { }, "advanced-details.extract-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.override-output-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().override_output_field = arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean"); + request.advanced_details.as_mut().unwrap().override_output_field = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.override-output-field", "boolean")); }, "advanced-details.field-a-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_a_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-a-required", "boolean")); }, "advanced-details.output-constructor" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_constructor = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_constructor = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-b-required" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b_required = arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean"); + request.advanced_details.as_mut().unwrap().field_b_required = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.field-b-required", "boolean")); }, "advanced-details.case-sensitive" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean"); + request.advanced_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "advanced-details.case-sensitive", "boolean")); }, "advanced-details.field-b" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_b = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_b = Some(value.unwrap_or("").to_string()); }, "advanced-details.field-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().field_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().field_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.extract-a" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().extract_a = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().extract_a = Some(value.unwrap_or("").to_string()); }, "advanced-details.output-to-field" => { request_advanced_details_init(&mut request); - request.advanced_details.as_mut().unwrap().output_to_field = value.unwrap_or("").to_string(); + request.advanced_details.as_mut().unwrap().output_to_field = Some(value.unwrap_or("").to_string()); }, "lowercase-details.field" => { request_lowercase_details_init(&mut request); - request.lowercase_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.lowercase_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.case-sensitive" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean"); + request.search_and_replace_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "search-and-replace-details.case-sensitive", "boolean")); }, "search-and-replace-details.search-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().search_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().search_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.replace-string" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().replace_string = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().replace_string = Some(value.unwrap_or("").to_string()); }, "search-and-replace-details.field" => { request_search_and_replace_details_init(&mut request); - request.search_and_replace_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.search_and_replace_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "exclude-details.case-sensitive" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean"); + request.exclude_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "exclude-details.case-sensitive", "boolean")); }, "exclude-details.kind" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "exclude-details.match-type" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "exclude-details.expression-value" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "exclude-details.field" => { request_exclude_details_init(&mut request); - request.exclude_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.exclude_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "include-details.case-sensitive" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean"); + request.include_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "include-details.case-sensitive", "boolean")); }, "include-details.kind" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "include-details.match-type" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "include-details.expression-value" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().expression_value = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().expression_value = Some(value.unwrap_or("").to_string()); }, "include-details.field" => { request_include_details_init(&mut request); - request.include_details.as_mut().unwrap().field = value.unwrap_or("").to_string(); + request.include_details.as_mut().unwrap().field = Some(value.unwrap_or("").to_string()); }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -3215,8 +3259,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3227,7 +3270,7 @@ impl Engine { -> Option { let mut call = self.hub.management().goals_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3259,8 +3302,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3269,10 +3311,10 @@ impl Engine { fn _management_goals_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Goal = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3292,9 +3334,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3334,11 +3377,11 @@ impl Engine { }, "visit-time-on-site-details.comparison-type" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-time-on-site-details.comparison-value" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "name" => { request_visit_time_on_site_details_init(&mut request); @@ -3350,19 +3393,19 @@ impl Engine { }, "url-destination-details.url" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "url-destination-details.case-sensitive" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean"); + request.url_destination_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean")); }, "url-destination-details.match-type" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "url-destination-details.first-step-required" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().first_step_required = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean"); + request.url_destination_details.as_mut().unwrap().first_step_required = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean")); }, "kind" => { request_url_destination_details_init(&mut request); @@ -3374,11 +3417,11 @@ impl Engine { }, "visit-num-pages-details.comparison-type" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-num-pages-details.comparison-value" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "internal-web-property-id" => { request_visit_num_pages_details_init(&mut request); @@ -3386,7 +3429,7 @@ impl Engine { }, "event-details.use-event-value" => { request_event_details_init(&mut request); - request.event_details.as_mut().unwrap().use_event_value = arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean"); + request.event_details.as_mut().unwrap().use_event_value = Some(arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean")); }, "web-property-id" => { request_event_details_init(&mut request); @@ -3402,11 +3445,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -3441,8 +3484,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3453,7 +3495,7 @@ impl Engine { -> Option { let mut call = self.hub.management().goals_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -3491,8 +3533,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3501,10 +3542,10 @@ impl Engine { fn _management_goals_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Goal = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3524,9 +3565,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3566,11 +3608,11 @@ impl Engine { }, "visit-time-on-site-details.comparison-type" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-time-on-site-details.comparison-value" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "name" => { request_visit_time_on_site_details_init(&mut request); @@ -3582,19 +3624,19 @@ impl Engine { }, "url-destination-details.url" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "url-destination-details.case-sensitive" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean"); + request.url_destination_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean")); }, "url-destination-details.match-type" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "url-destination-details.first-step-required" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().first_step_required = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean"); + request.url_destination_details.as_mut().unwrap().first_step_required = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean")); }, "kind" => { request_url_destination_details_init(&mut request); @@ -3606,11 +3648,11 @@ impl Engine { }, "visit-num-pages-details.comparison-type" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-num-pages-details.comparison-value" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "internal-web-property-id" => { request_visit_num_pages_details_init(&mut request); @@ -3618,7 +3660,7 @@ impl Engine { }, "event-details.use-event-value" => { request_event_details_init(&mut request); - request.event_details.as_mut().unwrap().use_event_value = arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean"); + request.event_details.as_mut().unwrap().use_event_value = Some(arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean")); }, "web-property-id" => { request_event_details_init(&mut request); @@ -3634,11 +3676,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -3673,8 +3715,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3683,10 +3724,10 @@ impl Engine { fn _management_goals_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Goal = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3706,9 +3747,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3748,11 +3790,11 @@ impl Engine { }, "visit-time-on-site-details.comparison-type" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-time-on-site-details.comparison-value" => { request_visit_time_on_site_details_init(&mut request); - request.visit_time_on_site_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_time_on_site_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "name" => { request_visit_time_on_site_details_init(&mut request); @@ -3764,19 +3806,19 @@ impl Engine { }, "url-destination-details.url" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "url-destination-details.case-sensitive" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().case_sensitive = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean"); + request.url_destination_details.as_mut().unwrap().case_sensitive = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.case-sensitive", "boolean")); }, "url-destination-details.match-type" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().match_type = value.unwrap_or("").to_string(); + request.url_destination_details.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "url-destination-details.first-step-required" => { request_url_destination_details_init(&mut request); - request.url_destination_details.as_mut().unwrap().first_step_required = arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean"); + request.url_destination_details.as_mut().unwrap().first_step_required = Some(arg_from_str(value.unwrap_or("false"), err, "url-destination-details.first-step-required", "boolean")); }, "kind" => { request_url_destination_details_init(&mut request); @@ -3788,11 +3830,11 @@ impl Engine { }, "visit-num-pages-details.comparison-type" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_type = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_type = Some(value.unwrap_or("").to_string()); }, "visit-num-pages-details.comparison-value" => { request_visit_num_pages_details_init(&mut request); - request.visit_num_pages_details.as_mut().unwrap().comparison_value = value.unwrap_or("").to_string(); + request.visit_num_pages_details.as_mut().unwrap().comparison_value = Some(value.unwrap_or("").to_string()); }, "internal-web-property-id" => { request_visit_num_pages_details_init(&mut request); @@ -3800,7 +3842,7 @@ impl Engine { }, "event-details.use-event-value" => { request_event_details_init(&mut request); - request.event_details.as_mut().unwrap().use_event_value = arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean"); + request.event_details.as_mut().unwrap().use_event_value = Some(arg_from_str(value.unwrap_or("false"), err, "event-details.use-event-value", "boolean")); }, "web-property-id" => { request_event_details_init(&mut request); @@ -3816,11 +3858,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "type" => { request_parent_link_init(&mut request); @@ -3855,8 +3897,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3867,7 +3908,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profile_filter_links_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3898,7 +3939,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3909,7 +3949,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profile_filter_links_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3941,8 +3981,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3951,10 +3990,10 @@ impl Engine { fn _management_profile_filter_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProfileFilterLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3974,9 +4013,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4001,51 +4041,51 @@ impl Engine { }, "filter-ref.kind" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "filter-ref.href" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "filter-ref.id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "filter-ref.name" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "filter-ref.account-id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.kind" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "profile-ref.name" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "profile-ref.internal-web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().internal_web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.href" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "profile-ref.web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "profile-ref.account-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_profile_ref_init(&mut request); @@ -4072,8 +4112,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4084,7 +4123,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profile_filter_links_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -4122,8 +4161,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4132,10 +4170,10 @@ impl Engine { fn _management_profile_filter_links_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProfileFilterLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4155,9 +4193,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4182,51 +4221,51 @@ impl Engine { }, "filter-ref.kind" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "filter-ref.href" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "filter-ref.id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "filter-ref.name" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "filter-ref.account-id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.kind" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "profile-ref.name" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "profile-ref.internal-web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().internal_web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.href" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "profile-ref.web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "profile-ref.account-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_profile_ref_init(&mut request); @@ -4253,8 +4292,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4263,10 +4301,10 @@ impl Engine { fn _management_profile_filter_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProfileFilterLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4286,9 +4324,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4313,51 +4352,51 @@ impl Engine { }, "filter-ref.kind" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "filter-ref.href" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "filter-ref.id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "filter-ref.name" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "filter-ref.account-id" => { request_filter_ref_init(&mut request); - request.filter_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.filter_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.kind" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "profile-ref.name" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "profile-ref.internal-web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().internal_web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.href" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "profile-ref.web-property-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().web_property_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "profile-ref.id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "profile-ref.account-id" => { request_profile_ref_init(&mut request); - request.profile_ref.as_mut().unwrap().account_id = value.unwrap_or("").to_string(); + request.profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_profile_ref_init(&mut request); @@ -4384,8 +4423,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4396,7 +4434,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profile_user_links_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4427,7 +4465,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4436,10 +4473,10 @@ impl Engine { fn _management_profile_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4459,18 +4496,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -4488,84 +4547,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -4577,11 +4636,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -4600,8 +4665,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4612,7 +4676,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profile_user_links_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -4650,8 +4714,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4660,10 +4723,10 @@ impl Engine { fn _management_profile_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4683,18 +4746,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -4712,84 +4797,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -4801,11 +4886,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -4824,8 +4915,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4836,7 +4926,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profiles_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4867,7 +4957,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4878,7 +4967,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profiles_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4910,8 +4999,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4920,10 +5008,10 @@ impl Engine { fn _management_profiles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Profile = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4943,9 +5031,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5006,11 +5095,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "enhanced-e-commerce-tracking" => { request_child_link_init(&mut request); @@ -5018,7 +5107,10 @@ impl Engine { }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-page" => { request_permissions_init(&mut request); @@ -5050,11 +5142,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_parent_link_init(&mut request); @@ -5077,8 +5169,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5089,7 +5180,7 @@ impl Engine { -> Option { let mut call = self.hub.management().profiles_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -5127,8 +5218,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5137,10 +5227,10 @@ impl Engine { fn _management_profiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Profile = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5160,9 +5250,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5223,11 +5314,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "enhanced-e-commerce-tracking" => { request_child_link_init(&mut request); @@ -5235,7 +5326,10 @@ impl Engine { }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-page" => { request_permissions_init(&mut request); @@ -5267,11 +5361,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_parent_link_init(&mut request); @@ -5294,8 +5388,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5304,10 +5397,10 @@ impl Engine { fn _management_profiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Profile = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5327,9 +5420,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5390,11 +5484,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "enhanced-e-commerce-tracking" => { request_child_link_init(&mut request); @@ -5402,7 +5496,10 @@ impl Engine { }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-page" => { request_permissions_init(&mut request); @@ -5434,11 +5531,11 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_parent_link_init(&mut request); @@ -5461,8 +5558,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5473,7 +5569,7 @@ impl Engine { -> Option { let mut call = self.hub.management().segments_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -5511,8 +5607,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5523,7 +5618,7 @@ impl Engine { -> Option { let mut call = self.hub.management().unsampled_reports_get(&self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_profile_id, &self.opt.arg_unsampled_report_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5555,8 +5650,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5565,10 +5659,10 @@ impl Engine { fn _management_unsampled_reports_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UnsampledReport = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5588,9 +5682,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5615,11 +5710,11 @@ impl Engine { }, "cloud-storage-download-details.bucket-id" => { request_cloud_storage_download_details_init(&mut request); - request.cloud_storage_download_details.as_mut().unwrap().bucket_id = value.unwrap_or("").to_string(); + request.cloud_storage_download_details.as_mut().unwrap().bucket_id = Some(value.unwrap_or("").to_string()); }, "cloud-storage-download-details.object-id" => { request_cloud_storage_download_details_init(&mut request); - request.cloud_storage_download_details.as_mut().unwrap().object_id = value.unwrap_or("").to_string(); + request.cloud_storage_download_details.as_mut().unwrap().object_id = Some(value.unwrap_or("").to_string()); }, "download-type" => { request_cloud_storage_download_details_init(&mut request); @@ -5647,7 +5742,7 @@ impl Engine { }, "drive-download-details.document-id" => { request_drive_download_details_init(&mut request); - request.drive_download_details.as_mut().unwrap().document_id = value.unwrap_or("").to_string(); + request.drive_download_details.as_mut().unwrap().document_id = Some(value.unwrap_or("").to_string()); }, "profile-id" => { request_drive_download_details_init(&mut request); @@ -5702,8 +5797,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5714,7 +5808,7 @@ impl Engine { -> Option { let mut call = self.hub.management().unsampled_reports_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -5752,8 +5846,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5762,10 +5855,10 @@ impl Engine { fn _management_uploads_delete_upload_data(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AnalyticsDataimportDeleteUploadDataRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5785,18 +5878,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.custom_data_import_uids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()))); @@ -5814,7 +5908,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -5825,7 +5918,7 @@ impl Engine { -> Option { let mut call = self.hub.management().uploads_get(&self.opt.arg_account_id, &self.opt.arg_web_property_id, &self.opt.arg_custom_data_source_id, &self.opt.arg_upload_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5857,8 +5950,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5869,7 +5961,7 @@ impl Engine { -> Option { let mut call = self.hub.management().uploads_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -5907,8 +5999,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5919,7 +6010,7 @@ impl Engine { -> Option { let mut call = self.hub.management().uploads_upload_data(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5961,8 +6052,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5973,7 +6063,7 @@ impl Engine { -> Option { let mut call = self.hub.management().web_property_ad_words_links_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6004,7 +6094,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -6015,7 +6104,7 @@ impl Engine { -> Option { let mut call = self.hub.management().web_property_ad_words_links_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6047,8 +6136,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6057,10 +6145,10 @@ impl Engine { fn _management_web_property_ad_words_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityAdWordsLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6080,9 +6168,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6092,6 +6181,13 @@ impl Engine { } } + fn request_entity_web_property_ref_init(request: &mut api::EntityAdWordsLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -6101,33 +6197,33 @@ impl Engine { }, "profile-ids" => { if request.profile_ids.is_none() { - request.profile_ids = Some(Default::default()); + request.profile_ids = Some(Default::default()); } - request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_entity_init(&mut request); @@ -6154,8 +6250,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6166,7 +6261,7 @@ impl Engine { -> Option { let mut call = self.hub.management().web_property_ad_words_links_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -6204,8 +6299,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6214,10 +6308,10 @@ impl Engine { fn _management_web_property_ad_words_links_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityAdWordsLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6237,9 +6331,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6249,6 +6344,13 @@ impl Engine { } } + fn request_entity_web_property_ref_init(request: &mut api::EntityAdWordsLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -6258,33 +6360,33 @@ impl Engine { }, "profile-ids" => { if request.profile_ids.is_none() { - request.profile_ids = Some(Default::default()); + request.profile_ids = Some(Default::default()); } - request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_entity_init(&mut request); @@ -6311,8 +6413,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6321,10 +6422,10 @@ impl Engine { fn _management_web_property_ad_words_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityAdWordsLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6344,9 +6445,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6356,6 +6458,13 @@ impl Engine { } } + fn request_entity_web_property_ref_init(request: &mut api::EntityAdWordsLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -6365,33 +6474,33 @@ impl Engine { }, "profile-ids" => { if request.profile_ids.is_none() { - request.profile_ids = Some(Default::default()); + request.profile_ids = Some(Default::default()); } - request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.profile_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_entity_init(&mut request); @@ -6418,8 +6527,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6430,7 +6538,7 @@ impl Engine { -> Option { let mut call = self.hub.management().webproperties_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6462,8 +6570,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6472,10 +6579,10 @@ impl Engine { fn _management_webproperties_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Webproperty = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6495,9 +6602,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6549,11 +6657,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "industry-vertical" => { request_child_link_init(&mut request); @@ -6561,15 +6669,18 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_permissions_init(&mut request); @@ -6600,8 +6711,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6612,7 +6722,7 @@ impl Engine { -> Option { let mut call = self.hub.management().webproperties_list(&self.opt.arg_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -6650,8 +6760,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6660,10 +6769,10 @@ impl Engine { fn _management_webproperties_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Webproperty = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6683,9 +6792,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6737,11 +6847,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "industry-vertical" => { request_child_link_init(&mut request); @@ -6749,15 +6859,18 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_permissions_init(&mut request); @@ -6788,8 +6901,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6798,10 +6910,10 @@ impl Engine { fn _management_webproperties_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Webproperty = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6821,9 +6933,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6875,11 +6988,11 @@ impl Engine { }, "child-link.href" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "child-link.type" => { request_child_link_init(&mut request); - request.child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "industry-vertical" => { request_child_link_init(&mut request); @@ -6887,15 +7000,18 @@ impl Engine { }, "parent-link.href" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "parent-link.type" => { request_parent_link_init(&mut request); - request.parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_permissions_init(&mut request); @@ -6926,8 +7042,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6938,7 +7053,7 @@ impl Engine { -> Option { let mut call = self.hub.management().webproperty_user_links_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6969,7 +7084,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -6978,10 +7092,10 @@ impl Engine { fn _management_webproperty_user_links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7001,18 +7115,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -7030,84 +7166,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -7119,11 +7255,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -7142,8 +7284,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7154,7 +7295,7 @@ impl Engine { -> Option { let mut call = self.hub.management().webproperty_user_links_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -7192,8 +7333,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7202,10 +7342,10 @@ impl Engine { fn _management_webproperty_user_links_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EntityUserLink = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7225,18 +7365,40 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_entity_account_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().account_ref.is_none() { + request.entity.as_mut().unwrap().account_ref = Some(Default::default()); + } + } + fn request_entity_init(request: &mut api::EntityUserLink) { if request.entity.is_none() { request.entity = Some(Default::default()); } } + fn request_entity_profile_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().profile_ref.is_none() { + request.entity.as_mut().unwrap().profile_ref = Some(Default::default()); + } + } + + fn request_entity_web_property_ref_init(request: &mut api::EntityUserLink) { + request_entity_init(request); + if request.entity.as_mut().unwrap().web_property_ref.is_none() { + request.entity.as_mut().unwrap().web_property_ref = Some(Default::default()); + } + } + fn request_permissions_init(request: &mut api::EntityUserLink) { if request.permissions.is_none() { request.permissions = Some(Default::default()); @@ -7254,84 +7416,84 @@ impl Engine { request.kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.kind = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.href = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.id = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.account-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().account_ref.name = value.unwrap_or("").to_string(); + request_entity_account_ref_init(&mut request); + request.entity.as_mut().unwrap().account_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.kind = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.name = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.href = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.web_property_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.profile-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().profile_ref.account_id = value.unwrap_or("").to_string(); + request_entity_profile_ref_init(&mut request); + request.entity.as_mut().unwrap().profile_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.kind" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.kind = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.name" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.name = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.internal-web-property-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.internal_web_property_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().internal_web_property_id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.href" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.href = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "entity.web-property-ref.account-id" => { - request_entity_init(&mut request); - request.entity.as_mut().unwrap().web_property_ref.account_id = value.unwrap_or("").to_string(); + request_entity_web_property_ref_init(&mut request); + request.entity.as_mut().unwrap().web_property_ref.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); }, "user-ref.kind" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "user-ref.email" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().email = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().email = Some(value.unwrap_or("").to_string()); }, "user-ref.id" => { request_user_ref_init(&mut request); - request.user_ref.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.user_ref.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_user_ref_init(&mut request); @@ -7343,11 +7505,17 @@ impl Engine { }, "permissions.local" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().local.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().local.is_none() { + request.permissions.as_mut().unwrap().local = Some(Default::default()); + } + request.permissions.as_mut().unwrap().local.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "permissions.effective" => { request_permissions_init(&mut request); - request.permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.permissions.as_mut().unwrap().effective.is_none() { + request.permissions.as_mut().unwrap().effective = Some(Default::default()); + } + 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()))); @@ -7366,8 +7534,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7378,7 +7545,7 @@ impl Engine { -> Option { let mut call = self.hub.metadata().columns_list(&self.opt.arg_report_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7410,8 +7577,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7420,10 +7586,10 @@ impl Engine { fn _provisioning_create_account_ticket(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountTicket = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7443,18 +7609,33 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_child_link_init(request: &mut api::AccountTicket) { + request_account_init(request); + if request.account.as_mut().unwrap().child_link.is_none() { + request.account.as_mut().unwrap().child_link = Some(Default::default()); + } + } + fn request_account_init(request: &mut api::AccountTicket) { if request.account.is_none() { request.account = Some(Default::default()); } } + fn request_account_permissions_init(request: &mut api::AccountTicket) { + request_account_init(request); + if request.account.as_mut().unwrap().permissions.is_none() { + request.account.as_mut().unwrap().permissions = Some(Default::default()); + } + } + fn request_profile_child_link_init(request: &mut api::AccountTicket) { request_profile_init(request); if request.profile.as_mut().unwrap().child_link.is_none() { @@ -7560,11 +7741,11 @@ impl Engine { }, "profile.child-link.href" => { request_profile_child_link_init(&mut request); - request.profile.as_mut().unwrap().child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.profile.as_mut().unwrap().child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "profile.child-link.type" => { request_profile_child_link_init(&mut request); - request.profile.as_mut().unwrap().child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.profile.as_mut().unwrap().child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "profile.enhanced-e-commerce-tracking" => { request_profile_child_link_init(&mut request); @@ -7572,7 +7753,10 @@ impl Engine { }, "profile.permissions.effective" => { request_profile_permissions_init(&mut request); - request.profile.as_mut().unwrap().permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.profile.as_mut().unwrap().permissions.as_mut().unwrap().effective.is_none() { + request.profile.as_mut().unwrap().permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.profile.as_mut().unwrap().permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "profile.default-page" => { request_profile_permissions_init(&mut request); @@ -7604,11 +7788,11 @@ impl Engine { }, "profile.parent-link.href" => { request_profile_parent_link_init(&mut request); - request.profile.as_mut().unwrap().parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.profile.as_mut().unwrap().parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "profile.parent-link.type" => { request_profile_parent_link_init(&mut request); - request.profile.as_mut().unwrap().parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.profile.as_mut().unwrap().parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "profile.self-link" => { request_profile_parent_link_init(&mut request); @@ -7616,39 +7800,42 @@ impl Engine { }, "account.kind" => { request_account_init(&mut request); - request.account.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.account.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "account.name" => { request_account_init(&mut request); - request.account.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.account.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "account.created" => { request_account_init(&mut request); - request.account.as_mut().unwrap().created = value.unwrap_or("").to_string(); + request.account.as_mut().unwrap().created = Some(value.unwrap_or("").to_string()); }, "account.updated" => { request_account_init(&mut request); - request.account.as_mut().unwrap().updated = value.unwrap_or("").to_string(); + request.account.as_mut().unwrap().updated = Some(value.unwrap_or("").to_string()); }, "account.child-link.href" => { - request_account_init(&mut request); - request.account.as_mut().unwrap().child_link.href = value.unwrap_or("").to_string(); + request_account_child_link_init(&mut request); + request.account.as_mut().unwrap().child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "account.child-link.type" => { - request_account_init(&mut request); - request.account.as_mut().unwrap().child_link.type_ = value.unwrap_or("").to_string(); + request_account_child_link_init(&mut request); + request.account.as_mut().unwrap().child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "account.id" => { - request_account_init(&mut request); - request.account.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_account_child_link_init(&mut request); + request.account.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "account.self-link" => { - request_account_init(&mut request); - request.account.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request_account_child_link_init(&mut request); + request.account.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "account.permissions.effective" => { - request_account_init(&mut request); - request.account.as_mut().unwrap().permissions.effective.push(value.unwrap_or("").to_string()); + request_account_permissions_init(&mut request); + if request.account.as_mut().unwrap().permissions.as_mut().unwrap().effective.is_none() { + request.account.as_mut().unwrap().permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.account.as_mut().unwrap().permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "webproperty.website-url" => { request_webproperty_init(&mut request); @@ -7688,11 +7875,11 @@ impl Engine { }, "webproperty.child-link.href" => { request_webproperty_child_link_init(&mut request); - request.webproperty.as_mut().unwrap().child_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.webproperty.as_mut().unwrap().child_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "webproperty.child-link.type" => { request_webproperty_child_link_init(&mut request); - request.webproperty.as_mut().unwrap().child_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.webproperty.as_mut().unwrap().child_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "webproperty.industry-vertical" => { request_webproperty_child_link_init(&mut request); @@ -7700,15 +7887,18 @@ impl Engine { }, "webproperty.parent-link.href" => { request_webproperty_parent_link_init(&mut request); - request.webproperty.as_mut().unwrap().parent_link.as_mut().unwrap().href = value.unwrap_or("").to_string(); + request.webproperty.as_mut().unwrap().parent_link.as_mut().unwrap().href = Some(value.unwrap_or("").to_string()); }, "webproperty.parent-link.type" => { request_webproperty_parent_link_init(&mut request); - request.webproperty.as_mut().unwrap().parent_link.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.webproperty.as_mut().unwrap().parent_link.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "webproperty.permissions.effective" => { request_webproperty_permissions_init(&mut request); - request.webproperty.as_mut().unwrap().permissions.as_mut().unwrap().effective.push(value.unwrap_or("").to_string()); + if request.webproperty.as_mut().unwrap().permissions.as_mut().unwrap().effective.is_none() { + request.webproperty.as_mut().unwrap().permissions.as_mut().unwrap().effective = Some(Default::default()); + } + request.webproperty.as_mut().unwrap().permissions.as_mut().unwrap().effective.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "webproperty.id" => { request_webproperty_permissions_init(&mut request); @@ -7751,8 +7941,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7774,7 +7963,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_management { + } + else if self.opt.cmd_management { if self.opt.cmd_account_summaries_list { call_result = self._management_account_summaries_list(dry_run, &mut err); } else if self.opt.cmd_account_user_links_delete { @@ -7924,13 +8114,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_metadata { + } + else if self.opt.cmd_metadata { if self.opt.cmd_columns_list { call_result = self._metadata_columns_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_provisioning { + } + else if self.opt.cmd_provisioning { if self.opt.cmd_create_account_ticket { call_result = self._provisioning_create_account_ticket(dry_run, &mut err); } else { @@ -7956,21 +8148,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "analytics3-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "analytics3-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "analytics3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "analytics3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Analytics::new(hyper::Client::new(), auth), + hub: api::Analytics::new(client, auth), }; match engine._doit(true) { @@ -7990,12 +8198,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/analytics3/Cargo.toml b/gen/analytics3/Cargo.toml index 00a43d8d0d..9e2cd4129b 100644 --- a/gen/analytics3/Cargo.toml +++ b/gen/analytics3/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-analytics3" -version = "0.1.5+20150308" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/analytics/" diff --git a/gen/analytics3/README.md b/gen/analytics3/README.md index fcfec1f1d3..92bfae65cd 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+20150308*, where *20150308* 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.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*. Everything else about the *analytics* *v3* API can be found at the [official documentation site](https://developers.google.com/analytics/). @@ -108,7 +108,7 @@ let mut hub = Analytics::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: EntityUserLink = Default::default(); +let mut req = EntityUserLink::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/analytics3/src/cmn.rs b/gen/analytics3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/analytics3/src/cmn.rs +++ b/gen/analytics3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/analytics3/src/lib.rs b/gen/analytics3/src/lib.rs index cf33bed54d..b56818890b 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+20150308*, where *20150308* 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.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*. //! //! Everything else about the *analytics* *v3* API can be found at the //! [official documentation site](https://developers.google.com/analytics/). @@ -109,7 +109,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: EntityUserLink = Default::default(); +//! let mut req = EntityUserLink::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -304,7 +304,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EntityUserLink = Default::default(); +/// let mut req = EntityUserLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -505,7 +505,7 @@ impl ResponseResult for Goal {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebpropertyPermissions { /// All the permissions that the user has for this web property. These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent account. - pub effective: Vec, + pub effective: Option>, } impl NestedType for WebpropertyPermissions {} @@ -519,16 +519,16 @@ impl Part for WebpropertyPermissions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FilterRef { /// Kind value for filter reference. - pub kind: String, + pub kind: Option, /// Link for this filter. - pub href: String, + pub href: Option, /// Account ID to which this filter belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// Filter ID. - pub id: String, + pub id: Option, /// Name of this filter. - pub name: String, + pub name: Option, } impl Part for FilterRef {} @@ -542,10 +542,10 @@ impl Part for FilterRef {} pub struct GoalEventDetails { /// List of event conditions. #[serde(rename="eventConditions")] - pub event_conditions: Vec, + pub event_conditions: Option>, /// Determines if the event value should be used as the value for this goal. #[serde(rename="useEventValue")] - pub use_event_value: bool, + pub use_event_value: Option, } impl NestedType for GoalEventDetails {} @@ -579,22 +579,22 @@ impl RequestValue for AnalyticsDataimportDeleteUploadDataRequest {} pub struct RealtimeDataProfileInfo { /// Internal ID for the web property to which this view (profile) belongs. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// Table ID for view (profile). #[serde(rename="tableId")] - pub table_id: String, + pub table_id: Option, /// Web Property ID to which this view (profile) belongs. #[serde(rename="webPropertyId")] - pub web_property_id: String, + pub web_property_id: Option, /// View (Profile) ID. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option, /// View (Profile) name. #[serde(rename="profileName")] - pub profile_name: String, + pub profile_name: Option, /// Account ID to which this view (profile) belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl NestedType for RealtimeDataProfileInfo {} @@ -609,17 +609,17 @@ impl Part for RealtimeDataProfileInfo {} pub struct RealtimeDataQuery { /// Maximum results per page. #[serde(rename="max-results")] - pub max_results: i32, + pub max_results: Option, /// List of dimensions or metrics based on which real time data is sorted. - pub sort: Vec, + pub sort: Option>, /// List of real time metrics. - pub metrics: Vec, + pub metrics: Option>, /// List of real time dimensions. - pub dimensions: String, + pub dimensions: Option, /// Comma-separated list of dimension or metric filters. - pub filters: String, + pub filters: Option, /// Unique table ID. - pub ids: String, + pub ids: Option, } impl NestedType for RealtimeDataQuery {} @@ -633,22 +633,22 @@ impl Part for RealtimeDataQuery {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfileRef { /// Analytics view (profile) reference. - pub kind: String, + pub kind: Option, /// Link for this view (profile). - pub href: String, + pub href: Option, /// Name of this view (profile). - pub name: String, + pub name: Option, /// Web property ID of the form UA-XXXXX-YY to which this view (profile) belongs. #[serde(rename="webPropertyId")] - pub web_property_id: String, + pub web_property_id: Option, /// Account ID to which this view (profile) belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// Internal ID for the web property to which this view (profile) belongs. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// View (Profile) ID. - pub id: String, + pub id: Option, } impl Part for ProfileRef {} @@ -666,46 +666,46 @@ impl Part for ProfileRef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct McfData { /// Resource type. - pub kind: String, + pub kind: Option, /// Analytics data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request. - pub rows: Vec>, + pub rows: Option>>, /// Determines if the Analytics data contains sampled data. #[serde(rename="containsSampledData")] - pub contains_sampled_data: bool, + pub contains_sampled_data: Option, /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request. #[serde(rename="columnHeaders")] - pub column_headers: Vec, + pub column_headers: Option>, /// The total number of rows for the query, regardless of the number of rows in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// The maximum number of rows the response can contain, regardless of the actual number of rows returned. Its value ranges from 1 to 10,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request. #[serde(rename="totalsForAllResults")] - pub totals_for_all_results: HashMap, + pub totals_for_all_results: Option>, /// Link to next page for this Analytics data query. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The number of samples used to calculate the result. #[serde(rename="sampleSize")] - pub sample_size: String, + pub sample_size: Option, /// Analytics data request query parameters. - pub query: McfDataQuery, + pub query: Option, /// Link to previous page for this Analytics data query. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// Information for the view (profile), for which the Analytics data was requested. #[serde(rename="profileInfo")] - pub profile_info: McfDataProfileInfo, + pub profile_info: Option, /// Unique ID for this data response. - pub id: String, + pub id: Option, /// Link to this page. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Total size of the sample space from which the samples were selected. #[serde(rename="sampleSpace")] - pub sample_space: String, + pub sample_space: Option, } impl ResponseResult for McfData {} @@ -723,26 +723,26 @@ impl ResponseResult for McfData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDataSources { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// Collection of custom data sources. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this custom data source collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this custom data source collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for CustomDataSources {} @@ -760,26 +760,26 @@ impl ResponseResult for CustomDataSources {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Goals { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of goals. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this goal collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this goal collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of resources in the result. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Goals {} @@ -792,23 +792,23 @@ impl ResponseResult for Goals {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Account { /// Resource type for Analytics account. - pub kind: String, + pub kind: Option, /// Account name. - pub name: String, + pub name: Option, /// Time the account was created. - pub created: String, + pub created: Option, /// Time the account was last modified. - pub updated: String, + pub updated: Option, /// Child link for an account entry. Points to the list of web properties for this account. #[serde(rename="childLink")] - pub child_link: AccountChildLink, + pub child_link: Option, /// Account ID. - pub id: String, + pub id: Option, /// Link for this account. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Permissions the user has for this account. - pub permissions: AccountPermissions, + pub permissions: Option, } impl Part for Account {} @@ -827,48 +827,48 @@ impl Part for Account {} pub struct GaData { /// Determines if Analytics data contains samples. #[serde(rename="containsSampledData")] - pub contains_sampled_data: bool, + pub contains_sampled_data: Option, /// Link to previous page for this Analytics data query. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// no description provided #[serde(rename="dataTable")] - pub data_table: GaDataDataTable, + pub data_table: Option, /// Analytics data request query parameters. - pub query: GaDataQuery, + pub query: Option, /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request. #[serde(rename="totalsForAllResults")] - pub totals_for_all_results: HashMap, + pub totals_for_all_results: Option>, /// Unique ID for this data response. - pub id: String, + pub id: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// Analytics data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request. - pub rows: Vec>, + pub rows: Option>>, /// The total number of rows for the query, regardless of the number of rows in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// The maximum number of rows the response can contain, regardless of the actual number of rows returned. Its value ranges from 1 to 10,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to next page for this Analytics data query. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The number of samples used to calculate the result. #[serde(rename="sampleSize")] - pub sample_size: String, + pub sample_size: Option, /// Information for the view (profile), for which the Analytics data was requested. #[serde(rename="profileInfo")] - pub profile_info: GaDataProfileInfo, + pub profile_info: Option, /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request. #[serde(rename="columnHeaders")] - pub column_headers: Vec, + pub column_headers: Option>, /// Link to this page. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Total size of the sample space from which the samples were selected. #[serde(rename="sampleSpace")] - pub sample_space: String, + pub sample_space: Option, } impl ResponseResult for GaData {} @@ -881,10 +881,10 @@ impl ResponseResult for GaData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExperimentParentLink { /// Link to the view (profile) to which this experiment belongs. This field is read-only. - pub href: String, + pub href: Option, /// Value is "analytics#profile". This field is read-only. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for ExperimentParentLink {} @@ -963,10 +963,10 @@ impl ResponseResult for UnsampledReport {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebpropertyParentLink { /// Link to the account for this web property. - pub href: String, + pub href: Option, /// Type of the parent link. Its value is "analytics#account". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for WebpropertyParentLink {} @@ -980,10 +980,10 @@ impl Part for WebpropertyParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfileParentLink { /// Link to the web property to which this view (profile) belongs. - pub href: String, + pub href: Option, /// Value is "analytics#webproperty". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for ProfileParentLink {} @@ -997,11 +997,11 @@ impl Part for ProfileParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRef { /// no description provided - pub kind: String, + pub kind: Option, /// Email ID of this user. - pub email: String, + pub email: Option, /// User ID. - pub id: String, + pub id: Option, } impl Part for UserRef {} @@ -1019,26 +1019,26 @@ impl Part for UserRef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Accounts { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of accounts. - pub items: Vec, + pub items: Option>, /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Previous link for this account collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Next link for this account collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Accounts {} @@ -1052,34 +1052,34 @@ impl ResponseResult for Accounts {} pub struct FilterAdvancedDetails { /// Field A. #[serde(rename="fieldA")] - pub field_a: String, + pub field_a: Option, /// Indicates if the existing value of the output field, if any, should be overridden by the output expression. #[serde(rename="overrideOutputField")] - pub override_output_field: bool, + pub override_output_field: Option, /// Indicates if field A is required to match. #[serde(rename="fieldARequired")] - pub field_a_required: bool, + pub field_a_required: Option, /// Expression used to construct the output value. #[serde(rename="outputConstructor")] - pub output_constructor: String, + pub output_constructor: Option, /// Indicates if field B is required to match. #[serde(rename="fieldBRequired")] - pub field_b_required: bool, + pub field_b_required: Option, /// Indicates if the filter expressions are case sensitive. #[serde(rename="caseSensitive")] - pub case_sensitive: bool, + pub case_sensitive: Option, /// Field B. #[serde(rename="fieldB")] - pub field_b: String, + pub field_b: Option, /// Expression to extract from field B. #[serde(rename="extractB")] - pub extract_b: String, + pub extract_b: Option, /// Expression to extract from field A. #[serde(rename="extractA")] - pub extract_a: String, + pub extract_a: Option, /// Output field. #[serde(rename="outputToField")] - pub output_to_field: String, + pub output_to_field: Option, } impl NestedType for FilterAdvancedDetails {} @@ -1094,20 +1094,20 @@ impl Part for FilterAdvancedDetails {} pub struct WebPropertySummary { /// Website url for this web property. #[serde(rename="websiteUrl")] - pub website_url: String, + pub website_url: Option, /// Resource type for Analytics WebPropertySummary. - pub kind: String, + pub kind: Option, /// Web property name. - pub name: String, + pub name: Option, /// Level for this web property. Possible values are STANDARD or PREMIUM. - pub level: String, + pub level: Option, /// Internal ID for this web property. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// List of profiles under this web property. - pub profiles: Vec, + pub profiles: Option>, /// Web property ID of the form UA-XXXXX-YY. - pub id: String, + pub id: Option, } impl Part for WebPropertySummary {} @@ -1151,22 +1151,22 @@ impl ResponseResult for AccountTicket {} pub struct McfDataProfileInfo { /// Internal ID for the web property to which this view (profile) belongs. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// Table ID for view (profile). #[serde(rename="tableId")] - pub table_id: String, + pub table_id: Option, /// Web Property ID to which this view (profile) belongs. #[serde(rename="webPropertyId")] - pub web_property_id: String, + pub web_property_id: Option, /// View (Profile) ID. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option, /// View (Profile) name. #[serde(rename="profileName")] - pub profile_name: String, + pub profile_name: Option, /// Account ID to which this view (profile) belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl NestedType for McfDataProfileInfo {} @@ -1181,10 +1181,10 @@ impl Part for McfDataProfileInfo {} pub struct UnsampledReportCloudStorageDownloadDetails { /// Id of the bucket the file object is stored in. #[serde(rename="bucketId")] - pub bucket_id: String, + pub bucket_id: Option, /// Id of the file object containing the report data. #[serde(rename="objectId")] - pub object_id: String, + pub object_id: Option, } impl NestedType for UnsampledReportCloudStorageDownloadDetails {} @@ -1199,10 +1199,10 @@ impl Part for UnsampledReportCloudStorageDownloadDetails {} pub struct GoalVisitTimeOnSiteDetails { /// Type of comparison. Possible values are LESS_THAN or GREATER_THAN. #[serde(rename="comparisonType")] - pub comparison_type: String, + pub comparison_type: Option, /// Value used for this comparison. #[serde(rename="comparisonValue")] - pub comparison_value: String, + pub comparison_value: Option, } impl NestedType for GoalVisitTimeOnSiteDetails {} @@ -1216,9 +1216,9 @@ impl Part for GoalVisitTimeOnSiteDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GaDataDataTable { /// no description provided - pub rows: Vec, + pub rows: Option>, /// no description provided - pub cols: Vec, + pub cols: Option>, } impl NestedType for GaDataDataTable {} @@ -1273,26 +1273,26 @@ impl ResponseResult for EntityUserLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountSummaries { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of AccountSummaries. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this AccountSummary collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this AccountSummary collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for AccountSummaries {} @@ -1310,26 +1310,26 @@ impl ResponseResult for AccountSummaries {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDimensions { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// Collection of custom dimensions. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this custom dimension collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this custom dimension collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for CustomDimensions {} @@ -1343,7 +1343,7 @@ impl ResponseResult for CustomDimensions {} pub struct UnsampledReportDriveDownloadDetails { /// Id of the document/file containing the report data. #[serde(rename="documentId")] - pub document_id: String, + pub document_id: Option, } impl NestedType for UnsampledReportDriveDownloadDetails {} @@ -1357,18 +1357,18 @@ impl Part for UnsampledReportDriveDownloadDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoalUrlDestinationDetails { /// URL for this goal. - pub url: String, + pub url: Option, /// Determines if the goal URL must exactly match the capitalization of visited URLs. #[serde(rename="caseSensitive")] - pub case_sensitive: bool, + pub case_sensitive: Option, /// Match type for the goal URL. Possible values are HEAD, EXACT, or REGEX. #[serde(rename="matchType")] - pub match_type: String, + pub match_type: Option, /// List of steps configured for this goal funnel. - pub steps: Vec, + pub steps: Option>, /// Determines if the first step in this goal is required. #[serde(rename="firstStepRequired")] - pub first_step_required: bool, + pub first_step_required: Option, } impl NestedType for GoalUrlDestinationDetails {} @@ -1388,19 +1388,19 @@ impl Part for GoalUrlDestinationDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Upload { /// Upload status. Possible values: PENDING, COMPLETED, FAILED, DELETING, DELETED. - pub status: String, + pub status: Option, /// Resource type for Analytics upload. - pub kind: String, + pub kind: Option, /// Data import errors collection. - pub errors: Vec, + pub errors: Option>, /// Custom data source Id to which this data import belongs. #[serde(rename="customDataSourceId")] - pub custom_data_source_id: String, + pub custom_data_source_id: Option, /// A unique ID for this upload. - pub id: String, + pub id: Option, /// Account Id to which this upload belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl ResponseResult for Upload {} @@ -1418,26 +1418,26 @@ impl ResponseResult for Upload {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Profiles { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of views (profiles). - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this view (profile) collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this view (profile) collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Profiles {} @@ -1450,7 +1450,7 @@ impl ResponseResult for Profiles {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissions { /// All the permissions that the user has for this account. These include any implied permissions (e.g., EDIT implies VIEW). - pub effective: Vec, + pub effective: Option>, } impl NestedType for AccountPermissions {} @@ -1465,22 +1465,22 @@ impl Part for AccountPermissions {} pub struct GaDataProfileInfo { /// Internal ID for the web property to which this view (profile) belongs. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// Table ID for view (profile). #[serde(rename="tableId")] - pub table_id: String, + pub table_id: Option, /// Web Property ID to which this view (profile) belongs. #[serde(rename="webPropertyId")] - pub web_property_id: String, + pub web_property_id: Option, /// View (Profile) ID. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option, /// View (Profile) name. #[serde(rename="profileName")] - pub profile_name: String, + pub profile_name: Option, /// Account ID to which this view (profile) belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl NestedType for GaDataProfileInfo {} @@ -1494,10 +1494,10 @@ impl Part for GaDataProfileInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FilterParentLink { /// Link to the account to which this filter belongs. - pub href: String, + pub href: Option, /// Value is "analytics#account". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for FilterParentLink {} @@ -1516,26 +1516,26 @@ impl Part for FilterParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Webproperties { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of web properties. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this web property collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this web property collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Webproperties {} @@ -1548,9 +1548,9 @@ impl ResponseResult for Webproperties {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EntityUserLinkPermissions { /// Permissions that a user has been assigned at this very level. Does not include any implied or inherited permissions. Local permissions are modifiable. - pub local: Vec, + pub local: Option>, /// Effective permissions represent all the permissions that a user has for this entity. These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent entity. Effective permissions are read-only. - pub effective: Vec, + pub effective: Option>, } impl NestedType for EntityUserLinkPermissions {} @@ -1601,14 +1601,14 @@ impl ResponseResult for ProfileFilterLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountSummary { /// Resource type for Analytics AccountSummary. - pub kind: String, + pub kind: Option, /// List of web properties under this account. #[serde(rename="webProperties")] - pub web_properties: Vec, + pub web_properties: Option>, /// Account ID. - pub id: String, + pub id: Option, /// Account name. - pub name: String, + pub name: Option, } impl Part for AccountSummary {} @@ -1687,28 +1687,28 @@ impl ResponseResult for Webproperty {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RealtimeData { /// Resource type. - pub kind: String, + pub kind: Option, /// Real time data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request. - pub rows: Vec>, + pub rows: Option>>, /// The total number of rows for the query, regardless of the number of rows in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// Information for the view (profile), for which the real time data was requested. #[serde(rename="profileInfo")] - pub profile_info: RealtimeDataProfileInfo, + pub profile_info: Option, /// Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request. #[serde(rename="columnHeaders")] - pub column_headers: Vec, + pub column_headers: Option>, /// Real time data request query parameters. - pub query: RealtimeDataQuery, + pub query: Option, /// Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request. #[serde(rename="totalsForAllResults")] - pub totals_for_all_results: HashMap, + pub totals_for_all_results: Option>, /// Unique ID for this data response. - pub id: String, + pub id: Option, /// Link to this page. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for RealtimeData {} @@ -1722,15 +1722,15 @@ impl ResponseResult for RealtimeData {} pub struct FilterSearchAndReplaceDetails { /// Determines if the filter is case sensitive. #[serde(rename="caseSensitive")] - pub case_sensitive: bool, + pub case_sensitive: Option, /// Term to search. #[serde(rename="searchString")] - pub search_string: String, + pub search_string: Option, /// Term to replace the search term with. #[serde(rename="replaceString")] - pub replace_string: String, + pub replace_string: Option, /// Field to use in the filter. - pub field: String, + pub field: Option, } impl NestedType for FilterSearchAndReplaceDetails {} @@ -1847,26 +1847,26 @@ impl ResponseResult for Experiment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomMetrics { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// Collection of custom metrics. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this custom metric collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this custom metric collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for CustomMetrics {} @@ -1880,31 +1880,31 @@ impl ResponseResult for CustomMetrics {} pub struct GaDataQuery { /// Maximum results per page. #[serde(rename="max-results")] - pub max_results: i32, + pub max_results: Option, /// List of dimensions or metrics based on which Analytics data is sorted. - pub sort: Vec, + pub sort: Option>, /// List of analytics dimensions. - pub dimensions: String, + pub dimensions: Option, /// Start date. #[serde(rename="start-date")] - pub start_date: String, + pub start_date: Option, /// Start index. #[serde(rename="start-index")] - pub start_index: i32, + pub start_index: Option, /// End date. #[serde(rename="end-date")] - pub end_date: String, + pub end_date: Option, /// Unique table ID. - pub ids: String, + pub ids: Option, /// List of analytics metrics. - pub metrics: Vec, + pub metrics: Option>, /// Desired sampling level #[serde(rename="samplingLevel")] - pub sampling_level: String, + pub sampling_level: Option, /// Comma-separated list of dimension or metric filters. - pub filters: String, + pub filters: Option, /// Analytics advanced segment. - pub segment: String, + pub segment: Option, } impl NestedType for GaDataQuery {} @@ -1923,17 +1923,17 @@ impl Part for GaDataQuery {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Columns { /// List of columns for a report type. - pub items: Vec, + pub items: Option>, /// Collection type. - pub kind: String, + pub kind: Option, /// Etag of collection. This etag can be compared with the last response etag to check if response has changed. - pub etag: String, + pub etag: Option, /// Total number of columns returned in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// List of attributes names returned by columns. #[serde(rename="attributeNames")] - pub attribute_names: Vec, + pub attribute_names: Option>, } impl ResponseResult for Columns {} @@ -1947,15 +1947,15 @@ impl ResponseResult for Columns {} pub struct FilterExpression { /// Determines if the filter is case sensitive. #[serde(rename="caseSensitive")] - pub case_sensitive: bool, + pub case_sensitive: Option, /// Kind value for filter expression - pub kind: String, + pub kind: Option, /// Match type for this filter. Possible values are BEGINS_WITH, EQUAL, ENDS_WITH, CONTAINS, MATCHES. Include and Exclude filters can use any match type. Match type is not applicable to Upper case and Lower case filters. Search and Replace expressions in the Search and Replace filter and all filter expressions in the Advanced filter default to MATCHES. User should not set match type for those filters. #[serde(rename="matchType")] - pub match_type: String, + pub match_type: Option, /// Filter expression value #[serde(rename="expressionValue")] - pub expression_value: String, + pub expression_value: Option, /// Field to filter. Possible values: /// - Content and Traffic /// - PAGE_REQUEST_URI, @@ -2041,7 +2041,7 @@ pub struct FilterExpression { /// - SOCIAL_NETWORK, /// - SOCIAL_ACTION, /// - SOCIAL_ACTION_TARGET, - pub field: String, + pub field: Option, } impl Part for FilterExpression {} @@ -2055,10 +2055,10 @@ impl Part for FilterExpression {} pub struct McfDataRowsConversionPathValue { /// Node value of an interaction on conversion path. Such as source, medium etc. #[serde(rename="nodeValue")] - pub node_value: String, + pub node_value: Option, /// Type of an interaction on conversion path. Such as CLICK, IMPRESSION etc. #[serde(rename="interactionType")] - pub interaction_type: String, + pub interaction_type: Option, } impl NestedType for McfDataRowsConversionPathValue {} @@ -2072,7 +2072,7 @@ impl Part for McfDataRowsConversionPathValue {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GaDataDataTableRows { /// no description provided - pub c: Vec, + pub c: Option>, } impl NestedType for GaDataDataTableRows {} @@ -2086,13 +2086,13 @@ impl Part for GaDataDataTableRows {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdWordsAccount { /// Resource type for AdWords account. - pub kind: String, + pub kind: Option, /// Customer ID. This field is required when creating an AdWords link. #[serde(rename="customerId")] - pub customer_id: String, + pub customer_id: Option, /// True if auto-tagging is enabled on the AdWords account. Read-only after the insert operation. #[serde(rename="autoTaggingEnabled")] - pub auto_tagging_enabled: bool, + pub auto_tagging_enabled: Option, } impl Part for AdWordsAccount {} @@ -2105,19 +2105,19 @@ impl Part for AdWordsAccount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebPropertyRef { /// Analytics web property reference. - pub kind: String, + pub kind: Option, /// Link for this web property. - pub href: String, + pub href: Option, /// Name of this web property. - pub name: String, + pub name: Option, /// Account ID to which this web property belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// Internal ID for this web property. #[serde(rename="internalWebPropertyId")] - pub internal_web_property_id: String, + pub internal_web_property_id: Option, /// Web property ID of the form UA-XXXXX-YY. - pub id: String, + pub id: Option, } impl Part for WebPropertyRef {} @@ -2130,10 +2130,10 @@ impl Part for WebPropertyRef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebpropertyChildLink { /// Link to the list of views (profiles) for this web property. - pub href: String, + pub href: Option, /// Type of the parent link. Its value is "analytics#profiles". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for WebpropertyChildLink {} @@ -2147,7 +2147,7 @@ impl Part for WebpropertyChildLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GaDataDataTableRowsC { /// no description provided - pub v: String, + pub v: Option, } impl NestedType for GaDataDataTableRowsC {} @@ -2161,11 +2161,11 @@ impl Part for GaDataDataTableRowsC {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Column { /// Map of attribute name and value for this column. - pub attributes: HashMap, + pub attributes: Option>, /// Resource type for Analytics column. - pub kind: String, + pub kind: Option, /// Column id. - pub id: String, + pub id: Option, } impl Part for Column {} @@ -2183,26 +2183,26 @@ impl Part for Column {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfileFilterLinks { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of profile filter links. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this profile filter link collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this profile filter link collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for ProfileFilterLinks {} @@ -2318,24 +2318,24 @@ impl ResponseResult for EntityAdWordsLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Uploads { /// Collection type. - pub kind: String, + pub kind: Option, /// The total number of results for the query, regardless of the number of resources in the result. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// A list of uploads. - pub items: Vec, + pub items: Option>, /// Link to previous page for this upload collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this upload collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, } impl ResponseResult for Uploads {} @@ -2348,7 +2348,7 @@ impl ResponseResult for Uploads {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FilterLowercaseDetails { /// Field to use in the filter. - pub field: String, + pub field: Option, } impl NestedType for FilterLowercaseDetails {} @@ -2362,19 +2362,19 @@ impl Part for FilterLowercaseDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoalEventDetailsEventConditions { /// Expression used for this match. - pub expression: String, + pub expression: Option, /// Type of the match to be performed. Possible values are REGEXP, BEGINS_WITH, or EXACT. #[serde(rename="matchType")] - pub match_type: String, + pub match_type: Option, /// Type of this event condition. Possible values are CATEGORY, ACTION, LABEL, or VALUE. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN or EQUAL. #[serde(rename="comparisonType")] - pub comparison_type: String, + pub comparison_type: Option, /// Value used for this comparison. #[serde(rename="comparisonValue")] - pub comparison_value: String, + pub comparison_value: Option, } impl NestedType for GoalEventDetailsEventConditions {} @@ -2388,11 +2388,11 @@ impl Part for GoalEventDetailsEventConditions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoalUrlDestinationDetailsSteps { /// URL for this step. - pub url: String, + pub url: Option, /// Step name. - pub name: String, + pub name: Option, /// Step number. - pub number: i32, + pub number: Option, } impl NestedType for GoalUrlDestinationDetailsSteps {} @@ -2406,10 +2406,10 @@ impl Part for GoalUrlDestinationDetailsSteps {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomMetricParentLink { /// Link to the property to which the custom metric belongs. - pub href: String, + pub href: Option, /// Type of the parent link. Set to "analytics#webproperty". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for CustomMetricParentLink {} @@ -2424,12 +2424,12 @@ impl Part for CustomMetricParentLink {} pub struct McfDataColumnHeaders { /// Data type. Dimension and metric values data types such as INTEGER, DOUBLE, CURRENCY, MCF_SEQUENCE etc. #[serde(rename="dataType")] - pub data_type: String, + pub data_type: Option, /// Column Type. Either DIMENSION or METRIC. #[serde(rename="columnType")] - pub column_type: String, + pub column_type: Option, /// Column name. - pub name: String, + pub name: Option, } impl NestedType for McfDataColumnHeaders {} @@ -2443,10 +2443,10 @@ impl Part for McfDataColumnHeaders {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GoalParentLink { /// Link to the view (profile) to which this goal belongs. - pub href: String, + pub href: Option, /// Value is "analytics#profile". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for GoalParentLink {} @@ -2465,24 +2465,24 @@ impl Part for GoalParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EntityAdWordsLinks { /// Collection type. - pub kind: String, + pub kind: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// A list of entity AdWords links. - pub items: Vec, + pub items: Option>, /// Previous link for this AdWords link collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Next link for this AdWords link collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, } impl ResponseResult for EntityAdWordsLinks {} @@ -2496,13 +2496,13 @@ impl ResponseResult for EntityAdWordsLinks {} pub struct EntityUserLinkEntity { /// Account for this link. #[serde(rename="accountRef")] - pub account_ref: AccountRef, + pub account_ref: Option, /// View (Profile) for this link. #[serde(rename="profileRef")] - pub profile_ref: ProfileRef, + pub profile_ref: Option, /// Web property for this link. #[serde(rename="webPropertyRef")] - pub web_property_ref: WebPropertyRef, + pub web_property_ref: Option, } impl NestedType for EntityUserLinkEntity {} @@ -2516,13 +2516,13 @@ impl Part for EntityUserLinkEntity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountRef { /// Analytics account reference. - pub kind: String, + pub kind: Option, /// Link for this account. - pub href: String, + pub href: Option, /// Account ID. - pub id: String, + pub id: Option, /// Account name. - pub name: String, + pub name: Option, } impl Part for AccountRef {} @@ -2542,24 +2542,24 @@ impl Part for AccountRef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EntityUserLinks { /// Collection type. - pub kind: String, + pub kind: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, /// A list of entity user links. - pub items: Vec, + pub items: Option>, /// Previous link for this account collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// The starting index of the entries, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Next link for this account collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, } impl ResponseResult for EntityUserLinks {} @@ -2577,26 +2577,26 @@ impl ResponseResult for EntityUserLinks {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Segments { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type for segments. - pub kind: String, + pub kind: Option, /// A list of segments. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this segment collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this segment collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Segments {} @@ -2609,10 +2609,10 @@ impl ResponseResult for Segments {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountChildLink { /// Link to the list of web properties for this account. - pub href: String, + pub href: Option, /// Type of the child link. Its value is "analytics#webproperties". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for AccountChildLink {} @@ -2626,7 +2626,7 @@ impl Part for AccountChildLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FilterUppercaseDetails { /// Field to use in the filter. - pub field: String, + pub field: Option, } impl NestedType for FilterUppercaseDetails {} @@ -2641,10 +2641,10 @@ impl Part for FilterUppercaseDetails {} pub struct McfDataRows { /// A primitive dimension value. A primitive metric value. #[serde(rename="primitiveValue")] - pub primitive_value: String, + pub primitive_value: Option, /// A conversion path dimension value, containing a list of interactions with their attributes. #[serde(rename="conversionPathValue")] - pub conversion_path_value: Vec, + pub conversion_path_value: Option>, } impl NestedType for McfDataRows {} @@ -2658,14 +2658,14 @@ impl Part for McfDataRows {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfileSummary { /// Resource type for Analytics ProfileSummary. - pub kind: String, + pub kind: Option, /// View (Profile) type. Supported types: WEB or APP. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// View (profile) ID. - pub id: String, + pub id: Option, /// View (profile) name. - pub name: String, + pub name: Option, } impl Part for ProfileSummary {} @@ -2726,7 +2726,7 @@ impl ResponseResult for CustomDimension {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfilePermissions { /// All the permissions that the user has for this view (profile). These include any implied permissions (e.g., EDIT implies VIEW) or inherited permissions from the parent web property. - pub effective: Vec, + pub effective: Option>, } impl NestedType for ProfilePermissions {} @@ -2740,15 +2740,15 @@ impl Part for ProfilePermissions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExperimentVariations { /// Status of the variation. Possible values: "ACTIVE", "INACTIVE". INACTIVE variations are not served. This field may not be changed for an experiment whose status is ENDED. - pub status: String, + pub status: Option, /// The URL of the variation. This field may not be changed for an experiment whose status is RUNNING or ENDED. - pub url: String, + pub url: Option, /// True if the experiment has ended and this variation performed (statistically) significantly better than the original. This field is read-only. - pub won: bool, + pub won: Option, /// The name of the variation. This field is required when creating an experiment. This field may not be changed for an experiment whose status is ENDED. - pub name: String, + pub name: Option, /// Weight that this variation should receive. Only present if the experiment is running. This field is read-only. - pub weight: f64, + pub weight: Option, } impl NestedType for ExperimentVariations {} @@ -2762,26 +2762,26 @@ impl Part for ExperimentVariations {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Segment { /// Segment definition. - pub definition: String, + pub definition: Option, /// Resource type for Analytics segment. - pub kind: String, + pub kind: Option, /// Segment ID. Can be used with the 'segment' parameter in Core Reporting API. #[serde(rename="segmentId")] - pub segment_id: String, + pub segment_id: Option, /// Time the segment was created. - pub created: String, + pub created: Option, /// Time the segment was last modified. - pub updated: String, + pub updated: Option, /// Type for a segment. Possible values are "BUILT_IN" or "CUSTOM". #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Segment ID. - pub id: String, + pub id: Option, /// Link for this segment. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Segment name. - pub name: String, + pub name: Option, } impl Part for Segment {} @@ -2795,31 +2795,31 @@ impl Part for Segment {} pub struct McfDataQuery { /// Maximum results per page. #[serde(rename="max-results")] - pub max_results: i32, + pub max_results: Option, /// List of dimensions or metrics based on which Analytics data is sorted. - pub sort: Vec, + pub sort: Option>, /// List of analytics dimensions. - pub dimensions: String, + pub dimensions: Option, /// Start date. #[serde(rename="start-date")] - pub start_date: String, + pub start_date: Option, /// Start index. #[serde(rename="start-index")] - pub start_index: i32, + pub start_index: Option, /// End date. #[serde(rename="end-date")] - pub end_date: String, + pub end_date: Option, /// Unique table ID. - pub ids: String, + pub ids: Option, /// List of analytics metrics. - pub metrics: Vec, + pub metrics: Option>, /// Desired sampling level #[serde(rename="samplingLevel")] - pub sampling_level: String, + pub sampling_level: Option, /// Comma-separated list of dimension or metric filters. - pub filters: String, + pub filters: Option, /// Analytics advanced segment. - pub segment: String, + pub segment: Option, } impl NestedType for McfDataQuery {} @@ -2919,12 +2919,12 @@ impl ResponseResult for Profile {} pub struct GaDataColumnHeaders { /// Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc. #[serde(rename="dataType")] - pub data_type: String, + pub data_type: Option, /// Column Type. Either DIMENSION or METRIC. #[serde(rename="columnType")] - pub column_type: String, + pub column_type: Option, /// Column name. - pub name: String, + pub name: Option, } impl NestedType for GaDataColumnHeaders {} @@ -2939,11 +2939,11 @@ impl Part for GaDataColumnHeaders {} pub struct GaDataDataTableCols { /// no description provided #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// no description provided - pub id: String, + pub id: Option, /// no description provided - pub label: String, + pub label: Option, } impl NestedType for GaDataDataTableCols {} @@ -2958,10 +2958,10 @@ impl Part for GaDataDataTableCols {} pub struct GoalVisitNumPagesDetails { /// Type of comparison. Possible values are LESS_THAN, GREATER_THAN, or EQUAL. #[serde(rename="comparisonType")] - pub comparison_type: String, + pub comparison_type: Option, /// Value used for this comparison. #[serde(rename="comparisonValue")] - pub comparison_value: String, + pub comparison_value: Option, } impl NestedType for GoalVisitNumPagesDetails {} @@ -2975,10 +2975,10 @@ impl Part for GoalVisitNumPagesDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDataSourceChildLink { /// Link to the list of daily uploads for this custom data source. Link to the list of uploads for this custom data source. - pub href: String, + pub href: Option, /// Value is "analytics#dailyUploads". Value is "analytics#uploads". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for CustomDataSourceChildLink {} @@ -2997,26 +2997,26 @@ impl Part for CustomDataSourceChildLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UnsampledReports { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of unsampled reports. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this unsampled report collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this unsampled report collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of resources in the result. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for UnsampledReports {} @@ -3030,12 +3030,12 @@ impl ResponseResult for UnsampledReports {} pub struct RealtimeDataColumnHeaders { /// Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc. #[serde(rename="dataType")] - pub data_type: String, + pub data_type: Option, /// Column Type. Either DIMENSION or METRIC. #[serde(rename="columnType")] - pub column_type: String, + pub column_type: Option, /// Column name. - pub name: String, + pub name: Option, } impl NestedType for RealtimeDataColumnHeaders {} @@ -3050,7 +3050,7 @@ impl Part for RealtimeDataColumnHeaders {} pub struct EntityAdWordsLinkEntity { /// no description provided #[serde(rename="webPropertyRef")] - pub web_property_ref: WebPropertyRef, + pub web_property_ref: Option, } impl NestedType for EntityAdWordsLinkEntity {} @@ -3064,10 +3064,10 @@ impl Part for EntityAdWordsLinkEntity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDataSourceParentLink { /// Link to the web property to which this custom data source belongs. - pub href: String, + pub href: Option, /// Value is "analytics#webproperty". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for CustomDataSourceParentLink {} @@ -3081,44 +3081,44 @@ impl Part for CustomDataSourceParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDataSource { /// Resource type for Analytics custom data source. - pub kind: String, + pub kind: Option, /// Description of custom data source. - pub description: String, + pub description: Option, /// IDs of views (profiles) linked to the custom data source. #[serde(rename="profilesLinked")] - pub profiles_linked: Vec, + pub profiles_linked: Option>, /// no description provided #[serde(rename="uploadType")] - pub upload_type: String, + pub upload_type: Option, /// Time this custom data source was created. - pub created: String, + pub created: Option, /// Time this custom data source was last modified. - pub updated: String, + pub updated: Option, /// Account ID to which this custom data source belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// no description provided #[serde(rename="childLink")] - pub child_link: CustomDataSourceChildLink, + pub child_link: Option, /// Web property ID of the form UA-XXXXX-YY to which this custom data source belongs. #[serde(rename="webPropertyId")] - pub web_property_id: String, + pub web_property_id: Option, /// Parent link for this custom data source. Points to the web property to which this custom data source belongs. #[serde(rename="parentLink")] - pub parent_link: CustomDataSourceParentLink, + pub parent_link: Option, /// no description provided #[serde(rename="importBehavior")] - pub import_behavior: String, + pub import_behavior: Option, /// Type of the custom data source. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// Custom data source ID. - pub id: String, + pub id: Option, /// Link for this Analytics custom data source. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Name of this custom data source. - pub name: String, + pub name: Option, } impl Part for CustomDataSource {} @@ -3131,10 +3131,10 @@ impl Part for CustomDataSource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDimensionParentLink { /// Link to the property to which the custom dimension belongs. - pub href: String, + pub href: Option, /// Type of the parent link. Set to "analytics#webproperty". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for CustomDimensionParentLink {} @@ -3153,26 +3153,26 @@ impl Part for CustomDimensionParentLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Experiments { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of experiments. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this experiment collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this experiment collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of resources in the result. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Experiments {} @@ -3190,26 +3190,26 @@ impl ResponseResult for Experiments {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Filters { /// Email ID of the authenticated user - pub username: String, + pub username: Option, /// Collection type. - pub kind: String, + pub kind: Option, /// A list of filters. - pub items: Vec, + pub items: Option>, /// The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1,000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option, /// Link to previous page for this filter collection. #[serde(rename="previousLink")] - pub previous_link: String, + pub previous_link: Option, /// The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// Link to next page for this filter collection. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option, /// The total number of results for the query, regardless of the number of results in the response. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl ResponseResult for Filters {} @@ -3222,10 +3222,10 @@ impl ResponseResult for Filters {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProfileChildLink { /// Link to the list of goals for this view (profile). - pub href: String, + pub href: Option, /// Value is "analytics#goals". #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for ProfileChildLink {} @@ -5133,7 +5133,7 @@ impl<'a, C, A> MetadataMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Webproperty = Default::default(); +/// let mut req = Webproperty::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5225,16 +5225,20 @@ impl<'a, C, A> ManagementWebpropertyInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5472,16 +5476,20 @@ impl<'a, C, A> ManagementProfileGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5706,16 +5714,20 @@ impl<'a, C, A> ManagementAccountListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5859,7 +5871,7 @@ impl<'a, C, A> ManagementAccountListCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkPatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6233,16 +6249,20 @@ impl<'a, C, A> ManagementWebpropertyUserLinkDeleteCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6478,16 +6498,20 @@ impl<'a, C, A> ManagementProfileUserLinkDeleteCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6647,7 +6671,7 @@ impl<'a, C, A> ManagementProfileUserLinkDeleteCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EntityUserLink = Default::default(); +/// let mut req = EntityUserLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6745,16 +6769,20 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6937,7 +6965,7 @@ impl<'a, C, A> ManagementProfileUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Filter = Default::default(); +/// let mut req = Filter::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7029,16 +7057,20 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7191,7 +7223,7 @@ impl<'a, C, A> ManagementFilterInsertCall<'a, C, A> where C: BorrowMut ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7457,7 +7493,7 @@ impl<'a, C, A> ManagementAccountUserLinkUpdateCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Webproperty = Default::default(); +/// let mut req = Webproperty::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7551,16 +7587,20 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7723,7 +7763,7 @@ impl<'a, C, A> ManagementWebpropertyUpdateCall<'a, C, A> where C: BorrowMut ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8001,7 +8045,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkUpdateCall<'a, C, A> where C: Borrow /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UnsampledReport = Default::default(); +/// let mut req = UnsampledReport::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8097,16 +8141,20 @@ impl<'a, C, A> ManagementUnsampledReportInsertCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8364,16 +8412,20 @@ impl<'a, C, A> ManagementCustomMetricGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8620,16 +8672,20 @@ impl<'a, C, A> ManagementUploadGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8884,16 +8940,20 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkGetCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9146,16 +9206,20 @@ impl<'a, C, A> ManagementWebpropertyUserLinkListCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9319,7 +9383,7 @@ impl<'a, C, A> ManagementWebpropertyUserLinkListCall<'a, C, A> where C: BorrowMu /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ProfileFilterLink = Default::default(); +/// let mut req = ProfileFilterLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9417,16 +9481,20 @@ impl<'a, C, A> ManagementProfileFilterLinkUpdateCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9696,16 +9764,20 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9875,7 +9947,7 @@ impl<'a, C, A> ManagementExperimentGetCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionUpdateCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10252,16 +10328,20 @@ impl<'a, C, A> ManagementUnsampledReportGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10431,7 +10511,7 @@ impl<'a, C, A> ManagementUnsampledReportGetCall<'a, C, A> where C: BorrowMut ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10709,7 +10793,7 @@ impl<'a, C, A> ManagementProfileFilterLinkInsertCall<'a, C, A> where C: BorrowMu /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Filter = Default::default(); +/// let mut req = Filter::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10803,16 +10887,20 @@ impl<'a, C, A> ManagementFilterUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11061,16 +11149,20 @@ impl<'a, C, A> ManagementProfileFilterLinkDeleteCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11295,16 +11387,20 @@ impl<'a, C, A> ManagementSegmentListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11532,16 +11628,20 @@ impl<'a, C, A> ManagementProfileDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11691,7 +11791,7 @@ impl<'a, C, A> ManagementProfileDeleteCall<'a, C, A> where C: BorrowMut ManagementGoalPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11981,7 +12085,7 @@ impl<'a, C, A> ManagementGoalPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12271,7 +12379,7 @@ impl<'a, C, A> ManagementCustomDimensionPatchCall<'a, C, A> where C: BorrowMut ManagementExperimentPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12656,16 +12768,20 @@ impl<'a, C, A> ManagementExperimentListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12932,16 +13048,20 @@ impl<'a, C, A> ManagementProfileListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13200,16 +13320,20 @@ impl<'a, C, A> ManagementGoalListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13383,7 +13507,7 @@ impl<'a, C, A> ManagementGoalListCall<'a, C, A> where C: BorrowMut ManagementGoalInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13661,7 +13789,7 @@ impl<'a, C, A> ManagementGoalInsertCall<'a, C, A> where C: BorrowMut ManagementCustomMetricPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14048,16 +14180,20 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -14315,7 +14451,7 @@ impl<'a, C, A> ManagementUploadUploadDataCall<'a, C, A> where C: BorrowMut ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14569,7 +14709,7 @@ impl<'a, C, A> ManagementAccountUserLinkInsertCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EntityUserLink = Default::default(); +/// let mut req = EntityUserLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14663,16 +14803,20 @@ impl<'a, C, A> ManagementWebpropertyUserLinkInsertCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14921,16 +15065,20 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -15090,7 +15238,7 @@ impl<'a, C, A> ManagementExperimentDeleteCall<'a, C, A> where C: BorrowMut ManagementProfilePatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15451,16 +15603,20 @@ impl<'a, C, A> ManagementFilterGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15703,16 +15859,20 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkListCall<'a, C, A> where C: Borro loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15941,16 +16101,20 @@ impl<'a, C, A> ManagementAccountSummaryListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16187,16 +16351,20 @@ impl<'a, C, A> ManagementCustomDimensionListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16455,16 +16623,20 @@ impl<'a, C, A> ManagementUploadListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16733,16 +16905,20 @@ impl<'a, C, A> ManagementProfileUserLinkListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17007,16 +17183,20 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17170,7 +17350,7 @@ impl<'a, C, A> ManagementAccountUserLinkListCall<'a, C, A> where C: BorrowMut ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17460,7 +17644,7 @@ impl<'a, C, A> ManagementCustomMetricUpdateCall<'a, C, A> where C: BorrowMut ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17727,7 +17915,7 @@ impl<'a, C, A> ManagementUploadDeleteUploadDataCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Experiment = Default::default(); +/// let mut req = Experiment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17825,16 +18013,20 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18017,7 +18209,7 @@ impl<'a, C, A> ManagementExperimentUpdateCall<'a, C, A> where C: BorrowMut ManagementGoalUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18400,16 +18596,20 @@ impl<'a, C, A> ManagementCustomDataSourceListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18666,16 +18866,20 @@ impl<'a, C, A> ManagementCustomMetricListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18934,16 +19138,20 @@ impl<'a, C, A> ManagementUnsampledReportListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19200,16 +19408,20 @@ impl<'a, C, A> ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19359,7 +19571,7 @@ impl<'a, C, A> ManagementWebpropertyGetCall<'a, C, A> where C: BorrowMut ManagementExperimentInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19722,16 +19938,20 @@ impl<'a, C, A> ManagementCustomDimensionGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19986,16 +20206,20 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -20169,7 +20393,7 @@ impl<'a, C, A> ManagementProfileFilterLinkListCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Webproperty = Default::default(); +/// let mut req = Webproperty::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -20263,16 +20487,20 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20435,7 +20663,7 @@ impl<'a, C, A> ManagementWebpropertyPatchCall<'a, C, A> where C: BorrowMut ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20701,7 +20933,7 @@ impl<'a, C, A> ManagementCustomDimensionInsertCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CustomMetric = Default::default(); +/// let mut req = CustomMetric::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -20795,16 +21027,20 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20967,7 +21203,7 @@ impl<'a, C, A> ManagementCustomMetricInsertCall<'a, C, A> where C: BorrowMut ManagementProfileUserLinkInsertCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21336,16 +21576,20 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21499,7 +21743,7 @@ impl<'a, C, A> ManagementWebpropertyListCall<'a, C, A> where C: BorrowMut ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21765,7 +22013,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkInsertCall<'a, C, A> where C: Bor /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EntityAdWordsLink = Default::default(); +/// let mut req = EntityAdWordsLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -21861,16 +22109,20 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkPatchCall<'a, C, A> where C: Borr loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22130,16 +22382,20 @@ impl<'a, C, A> ManagementGoalGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22393,16 +22649,20 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -22552,7 +22812,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkDeleteCall<'a, C, A> where C: Bor /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EntityAdWordsLink = Default::default(); +/// let mut req = EntityAdWordsLink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -22648,16 +22908,20 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22830,7 +23094,7 @@ impl<'a, C, A> ManagementWebPropertyAdWordsLinkUpdateCall<'a, C, A> where C: Bor /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Filter = Default::default(); +/// let mut req = Filter::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -22924,16 +23188,20 @@ impl<'a, C, A> ManagementFilterPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -23187,16 +23455,20 @@ impl<'a, C, A> ManagementFilterListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23433,16 +23705,20 @@ impl<'a, C, A> ManagementFilterDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -23592,7 +23868,7 @@ impl<'a, C, A> ManagementFilterDeleteCall<'a, C, A> where C: BorrowMut ManagementProfileInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -23940,16 +24220,20 @@ impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -24089,7 +24373,7 @@ impl<'a, C, A> ManagementAccountUserLinkDeleteCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Profile = Default::default(); +/// let mut req = Profile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -24185,16 +24469,20 @@ impl<'a, C, A> ManagementProfileUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -24454,16 +24742,20 @@ impl<'a, C, A> ManagementProfileFilterLinkGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -24726,16 +25018,20 @@ impl<'a, C, A> DataMcfGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25050,16 +25346,20 @@ impl<'a, C, A> DataGaGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25364,16 +25664,20 @@ impl<'a, C, A> DataRealtimeGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25551,7 +25855,7 @@ impl<'a, C, A> DataRealtimeGetCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccountTicket = Default::default(); +/// let mut req = AccountTicket::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -25617,16 +25921,20 @@ impl<'a, C, A> ProvisioningCreateAccountTicketCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -25850,16 +26158,20 @@ impl<'a, C, A> MetadataColumnListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/androidenterprise1-cli/Cargo.toml b/gen/androidenterprise1-cli/Cargo.toml index dce9177ab1..33a95f9dd1 100644 --- a/gen/androidenterprise1-cli/Cargo.toml +++ b/gen/androidenterprise1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-androidenterprise1-cli" version = "0.0.1+20150309" -authors = ["Sebastian Thiel "] +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" documentation = "http://byron.github.io/google-apis-rs/google_androidenterprise1_cli" @@ -22,6 +22,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/androidenterprise1-cli/src/cmn.rs b/gen/androidenterprise1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/androidenterprise1-cli/src/cmn.rs +++ b/gen/androidenterprise1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/androidenterprise1-cli/src/main.rs b/gen/androidenterprise1-cli/src/main.rs index 8fd152c636..1aca27bdc3 100644 --- a/gen/androidenterprise1-cli/src/main.rs +++ b/gen/androidenterprise1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -75,6 +76,12 @@ Configuration: 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. "); mod cmn; @@ -98,7 +105,7 @@ impl Engine { -> Option { let mut call = self.hub.collections().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -129,7 +136,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -140,7 +146,7 @@ impl Engine { -> Option { let mut call = self.hub.collections().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -172,8 +178,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -182,10 +187,10 @@ impl Engine { fn _collections_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Collection = Default::default(); + let mut request = api::Collection::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -205,9 +210,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -217,9 +223,9 @@ impl Engine { }, "product-id" => { if request.product_id.is_none() { - request.product_id = Some(Default::default()); + request.product_id = Some(Default::default()); } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -247,8 +253,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -259,7 +264,7 @@ impl Engine { -> Option { let mut call = self.hub.collections().list(&self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -291,8 +296,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -301,10 +305,10 @@ impl Engine { fn _collections_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Collection = Default::default(); + let mut request = api::Collection::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -324,9 +328,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -336,9 +341,9 @@ impl Engine { }, "product-id" => { if request.product_id.is_none() { - request.product_id = Some(Default::default()); + request.product_id = Some(Default::default()); } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -366,8 +371,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -376,10 +380,10 @@ impl Engine { fn _collections_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Collection = Default::default(); + let mut request = api::Collection::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -399,9 +403,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -411,9 +416,9 @@ impl Engine { }, "product-id" => { if request.product_id.is_none() { - request.product_id = Some(Default::default()); + request.product_id = Some(Default::default()); } - request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -441,8 +446,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -453,7 +457,7 @@ impl Engine { -> Option { let mut call = self.hub.collectionviewers().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -484,7 +488,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -495,7 +498,7 @@ impl Engine { -> Option { let mut call = self.hub.collectionviewers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -527,8 +530,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -539,7 +541,7 @@ impl Engine { -> Option { let mut call = self.hub.collectionviewers().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -571,8 +573,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -581,10 +582,10 @@ impl Engine { fn _collectionviewers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::User = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -604,9 +605,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -637,8 +639,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -647,10 +648,10 @@ impl Engine { fn _collectionviewers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::User = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -670,9 +671,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -703,8 +705,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -715,7 +716,7 @@ impl Engine { -> Option { let mut call = self.hub.devices().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -747,8 +748,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -759,7 +759,7 @@ impl Engine { -> Option { let mut call = self.hub.devices().get_state(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -791,8 +791,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -803,7 +802,7 @@ impl Engine { -> Option { let mut call = self.hub.devices().list(&self.opt.arg_enterprise_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -835,8 +834,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -845,10 +843,10 @@ impl Engine { fn _devices_set_state(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::DeviceState = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -868,9 +866,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -898,8 +897,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -910,7 +908,7 @@ impl Engine { -> Option { let mut call = self.hub.enterprises().delete(&self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -941,7 +939,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -950,10 +947,10 @@ impl Engine { fn _enterprises_enroll(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Enterprise = Default::default(); + let mut request = api::Enterprise::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -973,9 +970,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1009,8 +1007,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1021,7 +1018,7 @@ impl Engine { -> Option { let mut call = self.hub.enterprises().get(&self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1053,8 +1050,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1063,10 +1059,10 @@ impl Engine { fn _enterprises_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Enterprise = Default::default(); + let mut request = api::Enterprise::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1086,9 +1082,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1122,8 +1119,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1134,7 +1130,7 @@ impl Engine { -> Option { let mut call = self.hub.enterprises().list(&self.opt.arg_domain); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1166,8 +1162,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1176,10 +1171,10 @@ impl Engine { fn _enterprises_set_account(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::EnterpriseAccount = Default::default(); + let mut request = api::EnterpriseAccount::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1199,9 +1194,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1229,8 +1225,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1241,7 +1236,7 @@ impl Engine { -> Option { let mut call = self.hub.enterprises().unenroll(&self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1272,7 +1267,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1283,7 +1277,7 @@ impl Engine { -> Option { let mut call = self.hub.entitlements().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1314,7 +1308,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1325,7 +1318,7 @@ impl Engine { -> Option { let mut call = self.hub.entitlements().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1357,8 +1350,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1369,7 +1361,7 @@ impl Engine { -> Option { let mut call = self.hub.entitlements().list(&self.opt.arg_enterprise_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1401,8 +1393,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1411,10 +1402,10 @@ impl Engine { fn _entitlements_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Entitlement = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "install" => { call = call.install(arg_from_str(value.unwrap_or("false"), err, "install", "boolean")); @@ -1437,9 +1428,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1470,8 +1462,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1480,10 +1471,10 @@ impl Engine { fn _entitlements_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Entitlement = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "install" => { call = call.install(arg_from_str(value.unwrap_or("false"), err, "install", "boolean")); @@ -1506,9 +1497,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1539,8 +1531,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1551,7 +1542,7 @@ impl Engine { -> Option { let mut call = self.hub.grouplicenses().get(&self.opt.arg_enterprise_id, &self.opt.arg_group_license_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1583,8 +1574,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1595,7 +1585,7 @@ impl Engine { -> Option { let mut call = self.hub.grouplicenses().list(&self.opt.arg_enterprise_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1627,8 +1617,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1639,7 +1628,7 @@ impl Engine { -> Option { let mut call = self.hub.grouplicenseusers().list(&self.opt.arg_enterprise_id, &self.opt.arg_group_license_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1671,8 +1660,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1683,7 +1671,7 @@ impl Engine { -> Option { let mut call = self.hub.installs().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1714,7 +1702,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1725,7 +1712,7 @@ impl Engine { -> Option { let mut call = self.hub.installs().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1757,8 +1744,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1769,7 +1755,7 @@ impl Engine { -> Option { let mut call = self.hub.installs().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1801,8 +1787,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1811,10 +1796,10 @@ impl Engine { fn _installs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Install = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1834,9 +1819,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1870,8 +1856,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1880,10 +1865,10 @@ impl Engine { fn _installs_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Install = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1903,9 +1888,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1939,8 +1925,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1951,7 +1936,7 @@ impl Engine { -> Option { let mut call = self.hub.permissions().get(&self.opt.arg_permission_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "language" => { call = call.language(value.unwrap_or("")); @@ -1986,8 +1971,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1998,7 +1982,7 @@ impl Engine { -> Option { let mut call = self.hub.products().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "language" => { call = call.language(value.unwrap_or("")); @@ -2033,8 +2017,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2045,7 +2028,7 @@ impl Engine { -> Option { let mut call = self.hub.products().get_app_restrictions_schema(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "language" => { call = call.language(value.unwrap_or("")); @@ -2080,8 +2063,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2092,7 +2074,7 @@ impl Engine { -> Option { let mut call = self.hub.products().get_permissions(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2124,8 +2106,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2134,10 +2115,10 @@ impl Engine { fn _products_update_permissions(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProductPermissions = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2157,9 +2138,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2187,8 +2169,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2199,7 +2180,7 @@ impl Engine { -> Option { let mut call = self.hub.users().generate_token(&self.opt.arg_enterprise_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2231,8 +2212,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2243,7 +2223,7 @@ impl Engine { -> Option { let mut call = self.hub.users().get(&self.opt.arg_enterprise_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2275,8 +2255,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2287,7 +2266,7 @@ impl Engine { -> Option { let mut call = self.hub.users().list(&self.opt.arg_enterprise_id, &self.opt.arg_email); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2319,8 +2298,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2331,7 +2309,7 @@ impl Engine { -> Option { let mut call = self.hub.users().revoke_token(&self.opt.arg_enterprise_id, &self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2362,7 +2340,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2390,7 +2367,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_collectionviewers { + } + else if self.opt.cmd_collectionviewers { if self.opt.cmd_delete { call_result = self._collectionviewers_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2404,7 +2382,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_devices { + } + else if self.opt.cmd_devices { if self.opt.cmd_get { call_result = self._devices_get(dry_run, &mut err); } else if self.opt.cmd_get_state { @@ -2416,7 +2395,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_enterprises { + } + else if self.opt.cmd_enterprises { if self.opt.cmd_delete { call_result = self._enterprises_delete(dry_run, &mut err); } else if self.opt.cmd_enroll { @@ -2434,7 +2414,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_entitlements { + } + else if self.opt.cmd_entitlements { if self.opt.cmd_delete { call_result = self._entitlements_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2448,7 +2429,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_grouplicenses { + } + else if self.opt.cmd_grouplicenses { if self.opt.cmd_get { call_result = self._grouplicenses_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2456,13 +2438,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_grouplicenseusers { + } + else if self.opt.cmd_grouplicenseusers { if self.opt.cmd_list { call_result = self._grouplicenseusers_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_installs { + } + else if self.opt.cmd_installs { if self.opt.cmd_delete { call_result = self._installs_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2476,13 +2460,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_permissions { + } + else if self.opt.cmd_permissions { if self.opt.cmd_get { call_result = self._permissions_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_products { + } + else if self.opt.cmd_products { if self.opt.cmd_get { call_result = self._products_get(dry_run, &mut err); } else if self.opt.cmd_get_app_restrictions_schema { @@ -2494,7 +2480,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_users { + } + else if self.opt.cmd_users { if self.opt.cmd_generate_token { call_result = self._users_generate_token(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2526,21 +2513,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "androidenterprise1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "androidenterprise1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "androidenterprise1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "androidenterprise1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AndroidEnterprise::new(hyper::Client::new(), auth), + hub: api::AndroidEnterprise::new(client, auth), }; match engine._doit(true) { @@ -2560,12 +2563,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/androidenterprise1/Cargo.toml b/gen/androidenterprise1/Cargo.toml index 81fe194fb3..4a39e14588 100644 --- a/gen/androidenterprise1/Cargo.toml +++ b/gen/androidenterprise1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-androidenterprise1" version = "0.1.5+20150309" -authors = ["Sebastian Thiel "] +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" documentation = "http://byron.github.io/google-apis-rs/google_androidenterprise1" diff --git a/gen/androidenterprise1/README.md b/gen/androidenterprise1/README.md index 18bce15ac2..78f41163c9 100644 --- a/gen/androidenterprise1/README.md +++ b/gen/androidenterprise1/README.md @@ -116,7 +116,7 @@ let mut hub = AndroidEnterprise::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Enterprise = Default::default(); +let mut req = Enterprise::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/androidenterprise1/src/cmn.rs b/gen/androidenterprise1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/androidenterprise1/src/cmn.rs +++ b/gen/androidenterprise1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/androidenterprise1/src/lib.rs b/gen/androidenterprise1/src/lib.rs index 00895984bf..3af3678d06 100644 --- a/gen/androidenterprise1/src/lib.rs +++ b/gen/androidenterprise1/src/lib.rs @@ -117,7 +117,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Enterprise = Default::default(); +//! let mut req = Enterprise::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -292,7 +292,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Enterprise = Default::default(); +/// let mut req = Enterprise::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -397,7 +397,7 @@ impl<'a, C, A> AndroidEnterprise #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppRestrictionsSchema { /// The set of restrictions that make up this schema. - pub restrictions: Vec, + pub restrictions: Option>, } impl ResponseResult for AppRestrictionsSchema {} @@ -411,21 +411,21 @@ impl ResponseResult for AppRestrictionsSchema {} pub struct AppRestrictionsSchemaRestriction { /// The type of the restriction. #[serde(rename="restrictionType")] - pub restriction_type: String, + pub restriction_type: Option, /// A longer description of the restriction, giving more detail of what it affects. - pub description: String, + pub description: Option, /// The unique key that the product uses to identify the restriction, e.g. "com.google.android.gm.fieldname". - pub key: String, + pub key: Option, /// The name of the restriction. - pub title: String, + pub title: Option, /// For choice or multiselect restrictions, the list of possible entries' human-readable names. - pub entry: Vec, + pub entry: Option>, /// The default value of the restriction. #[serde(rename="defaultValue")] - pub default_value: AppRestrictionsSchemaRestrictionRestrictionValue, + pub default_value: Option, /// For choice or multiselect restrictions, the list of possible entries' machine-readable values. #[serde(rename="entryValue")] - pub entry_value: Vec, + pub entry_value: Option>, } impl Part for AppRestrictionsSchemaRestriction {} @@ -439,19 +439,19 @@ impl Part for AppRestrictionsSchemaRestriction {} pub struct AppRestrictionsSchemaRestrictionRestrictionValue { /// The boolean value - this will only be present if type is bool. #[serde(rename="valueBool")] - pub value_bool: bool, + pub value_bool: Option, /// The integer value - this will only be present if type is integer. #[serde(rename="valueInteger")] - pub value_integer: i32, + pub value_integer: Option, /// The type of the value being provided. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The list of string values - this will only be present if type is multiselect. #[serde(rename="valueMultiselect")] - pub value_multiselect: Vec, + pub value_multiselect: Option>, /// The string value - this will be present for types string, choice and hidden. #[serde(rename="valueString")] - pub value_string: String, + pub value_string: Option, } impl Part for AppRestrictionsSchemaRestrictionRestrictionValue {} @@ -469,9 +469,9 @@ impl Part for AppRestrictionsSchemaRestrictionRestrictionValue {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EnterprisesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#enterprisesListResponse". - pub kind: String, + pub kind: Option, /// An enterprise. - pub enterprise: Vec, + pub enterprise: Option>, } impl ResponseResult for EnterprisesListResponse {} @@ -526,9 +526,9 @@ impl ResponseResult for Entitlement {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstallsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#installsListResponse". - pub kind: String, + pub kind: Option, /// An installation of an app for a user on a specific device. The existence of an install implies that the user must have an entitlement to the app. - pub install: Vec, + pub install: Option>, } impl ResponseResult for InstallsListResponse {} @@ -546,9 +546,9 @@ impl ResponseResult for InstallsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CollectionViewersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#collectionViewersListResponse". - pub kind: String, + pub kind: Option, /// A user of an enterprise. - pub user: Vec, + pub user: Option>, } impl ResponseResult for CollectionViewersListResponse {} @@ -566,9 +566,9 @@ impl ResponseResult for CollectionViewersListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DevicesListResponse { /// A managed device. - pub device: Vec, + pub device: Option>, /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#devicesListResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for DevicesListResponse {} @@ -670,12 +670,12 @@ impl ResponseResult for Enterprise {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserToken { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#userToken". - pub kind: String, + pub kind: Option, /// The unique ID for the user. #[serde(rename="userId")] - pub user_id: String, + pub user_id: Option, /// The token (activation code) to be entered by the user. This consists of a sequence of decimal digits. Note that the leading digit may be 0. - pub token: String, + pub token: Option, } impl ResponseResult for UserToken {} @@ -739,9 +739,9 @@ impl ResponseResult for DeviceState {} pub struct ProductPermission { /// An opaque string uniquely identifying the permission. #[serde(rename="permissionId")] - pub permission_id: String, + pub permission_id: Option, /// Whether the permission has been accepted or not. - pub state: String, + pub state: Option, } impl Part for ProductPermission {} @@ -765,24 +765,24 @@ impl Part for ProductPermission {} pub struct Product { /// A link to an image that can be used as an icon for the product. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option, /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#product". - pub kind: String, + pub kind: Option, /// The name of the product. - pub title: String, + pub title: Option, /// A link to the (consumer) Google Play details page for the product. #[serde(rename="detailsUrl")] - pub details_url: String, + pub details_url: Option, /// A link to the Google Play for Work details page for the product, for use by an Enterprise administrator. #[serde(rename="workDetailsUrl")] - pub work_details_url: String, + pub work_details_url: Option, /// The name of the author of the product (e.g. the app developer). #[serde(rename="authorName")] - pub author_name: String, + pub author_name: Option, /// A string of the form "app: /// " - e.g. "app:com.google.android.gm" represents the GMail app. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl Resource for Product {} @@ -804,13 +804,13 @@ impl ResponseResult for Product {} pub struct Permission { /// An opaque string uniquely identifying the permission. #[serde(rename="permissionId")] - pub permission_id: String, + pub permission_id: Option, /// A longer description of the permissions giving more details of what it affects. - pub description: String, + pub description: Option, /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#permission". - pub kind: String, + pub kind: Option, /// The name of the permission. - pub name: String, + pub name: Option, } impl Resource for Permission {} @@ -829,9 +829,9 @@ impl ResponseResult for Permission {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EntitlementsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#entitlementsListResponse". - pub kind: String, + pub kind: Option, /// An entitlement of a user to a product (e.g. an app). For example, a free app that they have installed, or a paid app that they have been allocated a license to. - pub entitlement: Vec, + pub entitlement: Option>, } impl ResponseResult for EntitlementsListResponse {} @@ -849,9 +849,9 @@ impl ResponseResult for EntitlementsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UsersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#usersListResponse". - pub kind: String, + pub kind: Option, /// A user of an enterprise. - pub user: Vec, + pub user: Option>, } impl ResponseResult for UsersListResponse {} @@ -906,9 +906,9 @@ impl ResponseResult for Collection {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CollectionsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#collectionsListResponse". - pub kind: String, + pub kind: Option, /// An ordered collection of products which can be made visible on the Google Play Store app to a selected group of users. - pub collection: Vec, + pub collection: Option>, } impl ResponseResult for CollectionsListResponse {} @@ -961,9 +961,9 @@ impl ResponseResult for User {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GroupLicenseUsersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#groupLicenseUsersListResponse". - pub kind: String, + pub kind: Option, /// A user of an enterprise. - pub user: Vec, + pub user: Option>, } impl ResponseResult for GroupLicenseUsersListResponse {} @@ -1008,10 +1008,10 @@ impl ResponseResult for EnterpriseAccount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Device { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#device". - pub kind: String, + pub kind: Option, /// The Google Play Services Android ID for the device encoded as a lowercase hex string, e.g. "123456789abcdef0". #[serde(rename="androidId")] - pub android_id: String, + pub android_id: Option, } impl Resource for Device {} @@ -1034,21 +1034,21 @@ impl ResponseResult for Device {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GroupLicense { /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#groupLicense". - pub kind: String, + pub kind: Option, /// The number of purchased licenses (possibly in multiple purchases). If this field is omitted then there is no limit on the number of licenses that can be provisioned (e.g. if the acquisition kind is "free"). #[serde(rename="numPurchased")] - pub num_purchased: i32, + pub num_purchased: Option, /// The total number of provisioned licenses for this product. Returned by read operations, but ignored in write operations. #[serde(rename="numProvisioned")] - pub num_provisioned: i32, + pub num_provisioned: Option, /// How this group license was acquired. "bulkPurchase" means that this group license object was created because the enterprise purchased licenses for this product; this is "free" otherwise (for free products). #[serde(rename="acquisitionKind")] - pub acquisition_kind: String, + pub acquisition_kind: Option, /// Whether the product to which this group license relates is currently approved by the enterprise, as either "approved" or "unapproved". Products are approved when a group license is first created, but this approval may be revoked by an enterprise admin via Google Play. Unapproved products will not be visible to end users in collections and new entitlements to them should not normally be created. - pub approval: String, + pub approval: Option, /// The ID of the product that the license is for, e.g. "app:com.google.android.gm". #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl Resource for GroupLicense {} @@ -1068,9 +1068,9 @@ impl ResponseResult for GroupLicense {} pub struct GroupLicensesListResponse { /// A group license for a product approved for use in the enterprise. #[serde(rename="groupLicense")] - pub group_license: Vec, + pub group_license: Option>, /// Identifies what kind of resource this is. Value: the fixed string "androidenterprise#groupLicensesListResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for GroupLicensesListResponse {} @@ -2536,16 +2536,20 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2695,7 +2699,7 @@ impl<'a, C, A> CollectionviewerDeleteCall<'a, C, A> where C: BorrowMut CollectionviewerPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3058,16 +3066,20 @@ impl<'a, C, A> CollectionviewerGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3310,16 +3322,20 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3469,7 +3485,7 @@ impl<'a, C, A> CollectionviewerListCall<'a, C, A> where C: BorrowMut CollectionviewerUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3829,16 +3849,20 @@ impl<'a, C, A> UserRevokeTokenCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4061,16 +4085,20 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4303,16 +4331,20 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4545,16 +4577,20 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4704,7 +4740,7 @@ impl<'a, C, A> UserGenerateTokenCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Install = Default::default(); +/// let mut req = Install::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4802,16 +4838,20 @@ impl<'a, C, A> InstallPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5081,16 +5121,20 @@ impl<'a, C, A> InstallGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5345,16 +5389,20 @@ impl<'a, C, A> InstallListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5600,16 +5648,20 @@ impl<'a, C, A> InstallDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5769,7 +5821,7 @@ impl<'a, C, A> InstallDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Install = Default::default(); +/// let mut req = Install::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5867,16 +5919,20 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6059,7 +6115,7 @@ impl<'a, C, A> InstallUpdateCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DeviceState = Default::default(); +/// let mut req = DeviceState::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6155,16 +6211,20 @@ impl<'a, C, A> DeviceSetStateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6422,16 +6482,20 @@ impl<'a, C, A> DeviceGetStateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6674,16 +6738,20 @@ impl<'a, C, A> DeviceListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6918,16 +6986,20 @@ impl<'a, C, A> DeviceGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7167,16 +7239,20 @@ impl<'a, C, A> EnterpriseUnenrollCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7306,7 +7382,7 @@ impl<'a, C, A> EnterpriseUnenrollCall<'a, C, A> where C: BorrowMut EnterpriseInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7593,16 +7673,20 @@ impl<'a, C, A> EnterpriseListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7823,16 +7907,20 @@ impl<'a, C, A> EnterpriseGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7972,7 +8060,7 @@ impl<'a, C, A> EnterpriseGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Enterprise = Default::default(); +/// let mut req = Enterprise::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8040,16 +8128,20 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8202,7 +8294,7 @@ impl<'a, C, A> EnterpriseEnrollCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EnterpriseAccount = Default::default(); +/// let mut req = EnterpriseAccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8294,16 +8386,20 @@ impl<'a, C, A> EnterpriseSetAccountCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8536,16 +8632,20 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8675,7 +8775,7 @@ impl<'a, C, A> EnterpriseDeleteCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Collection = Default::default(); +/// let mut req = Collection::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8767,16 +8867,20 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8929,7 +9033,7 @@ impl<'a, C, A> CollectionInsertCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Collection = Default::default(); +/// let mut req = Collection::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9023,16 +9127,20 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9195,7 +9303,7 @@ impl<'a, C, A> CollectionPatchCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Collection = Default::default(); +/// let mut req = Collection::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9289,16 +9397,20 @@ impl<'a, C, A> CollectionUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9542,16 +9654,20 @@ impl<'a, C, A> CollectionListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9774,16 +9890,20 @@ impl<'a, C, A> CollectionGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10015,16 +10135,20 @@ impl<'a, C, A> CollectionDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10247,16 +10371,20 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10406,7 +10534,7 @@ impl<'a, C, A> GrouplicenseuserListCall<'a, C, A> where C: BorrowMut EntitlementUpdateCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10779,16 +10911,20 @@ impl<'a, C, A> EntitlementListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11023,16 +11159,20 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11192,7 +11332,7 @@ impl<'a, C, A> EntitlementGetCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Entitlement = Default::default(); +/// let mut req = Entitlement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11293,16 +11433,20 @@ impl<'a, C, A> EntitlementPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11566,16 +11710,20 @@ impl<'a, C, A> EntitlementDeleteCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11808,16 +11956,20 @@ impl<'a, C, A> ProductGetPermissionCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12055,16 +12207,20 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12309,16 +12465,20 @@ impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12475,7 +12635,7 @@ impl<'a, C, A> ProductGetAppRestrictionsSchemaCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ProductPermissions = Default::default(); +/// let mut req = ProductPermissions::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12569,16 +12729,20 @@ impl<'a, C, A> ProductUpdatePermissionCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12824,16 +12988,20 @@ impl<'a, C, A> GrouplicenseGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13064,16 +13232,20 @@ impl<'a, C, A> GrouplicenseListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13299,16 +13471,20 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/androidpublisher2-cli/Cargo.toml b/gen/androidpublisher2-cli/Cargo.toml index cd3419e903..c3972823b5 100644 --- a/gen/androidpublisher2-cli/Cargo.toml +++ b/gen/androidpublisher2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-androidpublisher2-cli" version = "0.0.1+20150323" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/android-publisher" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/androidpublisher2-cli/src/cmn.rs b/gen/androidpublisher2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/androidpublisher2-cli/src/cmn.rs +++ b/gen/androidpublisher2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/androidpublisher2-cli/src/main.rs b/gen/androidpublisher2-cli/src/main.rs index 0e354e8841..c2c747226d 100644 --- a/gen/androidpublisher2-cli/src/main.rs +++ b/gen/androidpublisher2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -82,6 +83,12 @@ Configuration: 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. "); mod cmn; @@ -106,7 +113,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().apklistings_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -137,7 +144,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -149,7 +155,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().apklistings_deleteall(&self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -180,7 +186,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -192,7 +197,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().apklistings_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -224,8 +229,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -237,7 +241,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().apklistings_list(&self.opt.arg_package_name, &self.opt.arg_edit_id, apk_version_code); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -269,8 +273,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -279,11 +282,11 @@ impl Engine { fn _edits_apklistings_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ApkListing = Default::default(); + let mut request = api::ApkListing::default(); 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -303,9 +306,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -333,8 +337,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -343,11 +346,11 @@ impl Engine { fn _edits_apklistings_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ApkListing = Default::default(); + let mut request = api::ApkListing::default(); 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -367,9 +370,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -397,8 +401,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -407,10 +410,10 @@ impl Engine { fn _edits_apks_addexternallyhosted(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ApksAddExternallyHostedRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -430,9 +433,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -445,59 +449,68 @@ impl Engine { match &field_name.to_string()[..] { "externally-hosted-apk.icon-base64" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().icon_base64 = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().icon_base64 = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.certificate-base64s" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().certificate_base64s.push(value.unwrap_or("").to_string()); + if request.externally_hosted_apk.as_mut().unwrap().certificate_base64s.is_none() { + request.externally_hosted_apk.as_mut().unwrap().certificate_base64s = Some(Default::default()); + } + request.externally_hosted_apk.as_mut().unwrap().certificate_base64s.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "externally-hosted-apk.externally-hosted-url" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().externally_hosted_url = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().externally_hosted_url = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.maximum-sdk" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().maximum_sdk = arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.maximum-sdk", "integer"); + request.externally_hosted_apk.as_mut().unwrap().maximum_sdk = Some(arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.maximum-sdk", "integer")); }, "externally-hosted-apk.file-sha256-base64" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().file_sha256_base64 = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().file_sha256_base64 = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.file-sha1-base64" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().file_sha1_base64 = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().file_sha1_base64 = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.uses-features" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().uses_features.push(value.unwrap_or("").to_string()); + if request.externally_hosted_apk.as_mut().unwrap().uses_features.is_none() { + request.externally_hosted_apk.as_mut().unwrap().uses_features = Some(Default::default()); + } + request.externally_hosted_apk.as_mut().unwrap().uses_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "externally-hosted-apk.file-size" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().file_size = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().file_size = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.version-name" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().version_name = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().version_name = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.version-code" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().version_code = arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.version-code", "integer"); + request.externally_hosted_apk.as_mut().unwrap().version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.version-code", "integer")); }, "externally-hosted-apk.package-name" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().package_name = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().package_name = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.minimum-sdk" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().minimum_sdk = arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.minimum-sdk", "integer"); + request.externally_hosted_apk.as_mut().unwrap().minimum_sdk = Some(arg_from_str(value.unwrap_or("-0"), err, "externally-hosted-apk.minimum-sdk", "integer")); }, "externally-hosted-apk.application-label" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().application_label = value.unwrap_or("").to_string(); + request.externally_hosted_apk.as_mut().unwrap().application_label = Some(value.unwrap_or("").to_string()); }, "externally-hosted-apk.native-codes" => { request_externally_hosted_apk_init(&mut request); - request.externally_hosted_apk.as_mut().unwrap().native_codes.push(value.unwrap_or("").to_string()); + if request.externally_hosted_apk.as_mut().unwrap().native_codes.is_none() { + request.externally_hosted_apk.as_mut().unwrap().native_codes = Some(Default::default()); + } + 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()))); @@ -516,8 +529,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -528,7 +540,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().apks_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -560,8 +572,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -572,7 +583,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().apks_upload(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -614,8 +625,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -626,7 +636,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().commit(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -658,8 +668,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -670,7 +679,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -701,7 +710,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -712,7 +720,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().details_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -744,8 +752,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -754,10 +761,10 @@ impl Engine { fn _edits_details_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AppDetails = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -777,9 +784,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -813,8 +821,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -823,10 +830,10 @@ impl Engine { fn _edits_details_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AppDetails = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -846,9 +853,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -882,8 +890,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -895,7 +902,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().expansionfiles_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -927,8 +934,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -937,11 +943,11 @@ impl Engine { fn _edits_expansionfiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ExpansionFile = Default::default(); + let mut request = api::ExpansionFile::default(); 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -961,9 +967,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -991,8 +998,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1001,11 +1007,11 @@ impl Engine { fn _edits_expansionfiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ExpansionFile = Default::default(); + let mut request = api::ExpansionFile::default(); 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1025,9 +1031,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1055,8 +1062,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1068,7 +1074,7 @@ impl Engine { let apk_version_code: i32 = arg_from_str(&self.opt.arg_apk_version_code, err, "", "integer"); let mut call = self.hub.edits().expansionfiles_upload(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1110,8 +1116,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1122,7 +1127,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1154,8 +1159,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1166,7 +1170,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().images_delete(&self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language, &self.opt.arg_image_type, &self.opt.arg_image_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1197,7 +1201,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1208,7 +1211,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().images_deleteall(&self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language, &self.opt.arg_image_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1240,8 +1243,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1252,7 +1254,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().images_list(&self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language, &self.opt.arg_image_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1284,8 +1286,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1296,7 +1297,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().images_upload(&self.opt.arg_package_name, &self.opt.arg_edit_id, &self.opt.arg_language, &self.opt.arg_image_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1338,8 +1339,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1348,10 +1348,10 @@ impl Engine { fn _edits_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AppEdit = Default::default(); + let mut request = api::AppEdit::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1371,9 +1371,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1401,8 +1402,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1413,7 +1413,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().listings_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1444,7 +1444,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1455,7 +1454,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().listings_deleteall(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1486,7 +1485,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1497,7 +1495,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().listings_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1529,8 +1527,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1541,7 +1538,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().listings_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1573,8 +1570,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1583,10 +1579,10 @@ impl Engine { fn _edits_listings_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Listing = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1606,9 +1602,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1645,8 +1642,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1655,10 +1651,10 @@ impl Engine { fn _edits_listings_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Listing = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1678,9 +1674,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1717,8 +1714,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1729,7 +1725,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().testers_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1761,8 +1757,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1771,10 +1766,10 @@ impl Engine { fn _edits_testers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Testers = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1794,24 +1789,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1830,8 +1826,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1840,10 +1835,10 @@ impl Engine { fn _edits_testers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Testers = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1863,24 +1858,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.google_groups.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.google_plus_communities.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1899,8 +1895,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1911,7 +1906,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().tracks_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1943,8 +1938,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1955,7 +1949,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().tracks_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1987,8 +1981,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1997,10 +1990,10 @@ impl Engine { fn _edits_tracks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Track = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2020,9 +2013,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2035,9 +2029,9 @@ impl Engine { }, "version-codes" => { if request.version_codes.is_none() { - request.version_codes = Some(Default::default()); + request.version_codes = Some(Default::default()); } - request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); + 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()))); @@ -2056,8 +2050,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2066,10 +2059,10 @@ impl Engine { fn _edits_tracks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Track = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2089,9 +2082,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2104,9 +2098,9 @@ impl Engine { }, "version-codes" => { if request.version_codes.is_none() { - request.version_codes = Some(Default::default()); + request.version_codes = Some(Default::default()); } - request.version_codes.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "version-codes", "integer")); + 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()))); @@ -2125,8 +2119,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2137,7 +2130,7 @@ impl Engine { -> Option { let mut call = self.hub.edits().validate(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2169,8 +2162,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2179,10 +2171,10 @@ impl Engine { fn _inappproducts_batch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InappproductsBatchRequest = Default::default(); + let mut request = api::InappproductsBatchRequest::default(); let mut call = self.hub.inappproducts().batch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2202,9 +2194,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2226,8 +2219,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2238,7 +2230,7 @@ impl Engine { -> Option { let mut call = self.hub.inappproducts().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2269,7 +2261,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2280,7 +2271,7 @@ impl Engine { -> Option { let mut call = self.hub.inappproducts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2312,8 +2303,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2322,10 +2312,10 @@ impl Engine { fn _inappproducts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InAppProduct = Default::default(); + 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); + 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")); @@ -2348,9 +2338,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2360,12 +2351,26 @@ impl Engine { } } + fn request_season_end_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().end.is_none() { + request.season.as_mut().unwrap().end = Some(Default::default()); + } + } + fn request_season_init(request: &mut api::InAppProduct) { if request.season.is_none() { request.season = Some(Default::default()); } } + fn request_season_start_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().start.is_none() { + request.season.as_mut().unwrap().start = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); @@ -2377,20 +2382,20 @@ impl Engine { request.subscription_period = Some(value.unwrap_or("").to_string()); }, "season.start.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.day = arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer")); }, "season.start.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.month = arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer")); }, "season.end.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.day = arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer")); }, "season.end.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.month = arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer")); }, "package-name" => { request_season_init(&mut request); @@ -2410,11 +2415,11 @@ impl Engine { }, "default-price.currency" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.default_price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "default-price.price-micros" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().price_micros = value.unwrap_or("").to_string(); + 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()))); @@ -2433,8 +2438,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2445,7 +2449,7 @@ impl Engine { -> Option { let mut call = self.hub.inappproducts().list(&self.opt.arg_package_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "token" => { call = call.token(value.unwrap_or("")); @@ -2486,8 +2490,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2496,10 +2499,10 @@ impl Engine { fn _inappproducts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InAppProduct = Default::default(); + 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); + 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")); @@ -2522,9 +2525,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2534,12 +2538,26 @@ impl Engine { } } + fn request_season_end_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().end.is_none() { + request.season.as_mut().unwrap().end = Some(Default::default()); + } + } + fn request_season_init(request: &mut api::InAppProduct) { if request.season.is_none() { request.season = Some(Default::default()); } } + fn request_season_start_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().start.is_none() { + request.season.as_mut().unwrap().start = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); @@ -2551,20 +2569,20 @@ impl Engine { request.subscription_period = Some(value.unwrap_or("").to_string()); }, "season.start.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.day = arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer")); }, "season.start.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.month = arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer")); }, "season.end.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.day = arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer")); }, "season.end.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.month = arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer")); }, "package-name" => { request_season_init(&mut request); @@ -2584,11 +2602,11 @@ impl Engine { }, "default-price.currency" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.default_price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "default-price.price-micros" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().price_micros = value.unwrap_or("").to_string(); + 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()))); @@ -2607,8 +2625,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2617,10 +2634,10 @@ impl Engine { fn _inappproducts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InAppProduct = Default::default(); + 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); + 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")); @@ -2643,9 +2660,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2655,12 +2673,26 @@ impl Engine { } } + fn request_season_end_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().end.is_none() { + request.season.as_mut().unwrap().end = Some(Default::default()); + } + } + fn request_season_init(request: &mut api::InAppProduct) { if request.season.is_none() { request.season = Some(Default::default()); } } + fn request_season_start_init(request: &mut api::InAppProduct) { + request_season_init(request); + if request.season.as_mut().unwrap().start.is_none() { + request.season.as_mut().unwrap().start = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "sku" => { request.sku = Some(value.unwrap_or("").to_string()); @@ -2672,20 +2704,20 @@ impl Engine { request.subscription_period = Some(value.unwrap_or("").to_string()); }, "season.start.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.day = arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.day", "integer")); }, "season.start.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().start.month = arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer"); + request_season_start_init(&mut request); + request.season.as_mut().unwrap().start.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.start.month", "integer")); }, "season.end.day" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.day = arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().day = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.day", "integer")); }, "season.end.month" => { - request_season_init(&mut request); - request.season.as_mut().unwrap().end.month = arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer"); + request_season_end_init(&mut request); + request.season.as_mut().unwrap().end.as_mut().unwrap().month = Some(arg_from_str(value.unwrap_or("-0"), err, "season.end.month", "integer")); }, "package-name" => { request_season_init(&mut request); @@ -2705,11 +2737,11 @@ impl Engine { }, "default-price.currency" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.default_price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "default-price.price-micros" => { request_default_price_init(&mut request); - request.default_price.as_mut().unwrap().price_micros = value.unwrap_or("").to_string(); + 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()))); @@ -2728,8 +2760,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2740,7 +2771,7 @@ impl Engine { -> Option { let mut call = self.hub.purchases().products_get(&self.opt.arg_package_name, &self.opt.arg_product_id, &self.opt.arg_token); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2772,8 +2803,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2784,7 +2814,7 @@ impl Engine { -> Option { let mut call = self.hub.purchases().subscriptions_cancel(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2815,7 +2845,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2824,10 +2853,10 @@ impl Engine { fn _purchases_subscriptions_defer(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::SubscriptionPurchasesDeferRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2847,9 +2876,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2862,11 +2892,11 @@ impl Engine { 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -2885,8 +2915,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2897,7 +2926,7 @@ impl Engine { -> Option { let mut call = self.hub.purchases().subscriptions_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2929,8 +2958,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2941,7 +2969,7 @@ impl Engine { -> Option { let mut call = self.hub.purchases().subscriptions_refund(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2972,7 +3000,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2983,7 +3010,7 @@ impl Engine { -> Option { let mut call = self.hub.purchases().subscriptions_revoke(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3014,7 +3041,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3106,7 +3132,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_inappproducts { + } + else if self.opt.cmd_inappproducts { if self.opt.cmd_batch { call_result = self._inappproducts_batch(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -3124,7 +3151,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_purchases { + } + else if self.opt.cmd_purchases { if self.opt.cmd_products_get { call_result = self._purchases_products_get(dry_run, &mut err); } else if self.opt.cmd_subscriptions_cancel { @@ -3160,21 +3188,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "androidpublisher2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "androidpublisher2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "androidpublisher2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "androidpublisher2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AndroidPublisher::new(hyper::Client::new(), auth), + hub: api::AndroidPublisher::new(client, auth), }; match engine._doit(true) { @@ -3194,12 +3238,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/androidpublisher2/Cargo.toml b/gen/androidpublisher2/Cargo.toml index 4bb3acb968..62ecf1daa5 100644 --- a/gen/androidpublisher2/Cargo.toml +++ b/gen/androidpublisher2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-androidpublisher2" version = "0.1.5+20150323" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/android-publisher" diff --git a/gen/androidpublisher2/README.md b/gen/androidpublisher2/README.md index a543ebf6d0..1861b4ec00 100644 --- a/gen/androidpublisher2/README.md +++ b/gen/androidpublisher2/README.md @@ -106,7 +106,7 @@ let mut hub = AndroidPublisher::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: InAppProduct = Default::default(); +let mut req = InAppProduct::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/androidpublisher2/src/cmn.rs b/gen/androidpublisher2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/androidpublisher2/src/cmn.rs +++ b/gen/androidpublisher2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/androidpublisher2/src/lib.rs b/gen/androidpublisher2/src/lib.rs index d63e01dafa..2dd5cd8239 100644 --- a/gen/androidpublisher2/src/lib.rs +++ b/gen/androidpublisher2/src/lib.rs @@ -107,7 +107,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: InAppProduct = Default::default(); +//! let mut req = InAppProduct::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -227,7 +227,7 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { - /// View and manage your Google Play Android Developer account + /// View and manage your Google Play Developer account Full, } @@ -283,7 +283,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InAppProduct = Default::default(); +/// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -360,7 +360,7 @@ impl<'a, C, A> AndroidPublisher #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InappproductsUpdateResponse { /// no description provided - pub inappproduct: InAppProduct, + pub inappproduct: Option, } impl Part for InappproductsUpdateResponse {} @@ -427,7 +427,7 @@ impl ResponseResult for InAppProduct {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImagesListResponse { /// no description provided - pub images: Vec, + pub images: Option>, } impl ResponseResult for ImagesListResponse {} @@ -446,7 +446,7 @@ impl ResponseResult for ImagesListResponse {} pub struct ExpansionFilesUploadResponse { /// no description provided #[serde(rename="expansionFile")] - pub expansion_file: ExpansionFile, + pub expansion_file: Option, } impl ResponseResult for ExpansionFilesUploadResponse {} @@ -460,10 +460,10 @@ impl ResponseResult for ExpansionFilesUploadResponse {} pub struct SubscriptionDeferralInfo { /// The expected expiry time for the subscription. If the current expiry time for the subscription is not the value specified here, the deferral will not occur. #[serde(rename="expectedExpiryTimeMillis")] - pub expected_expiry_time_millis: String, + pub expected_expiry_time_millis: Option, /// The desired next expiry time for the subscription in milliseconds since Epoch. The given time must be after the current expiry time for the subscription. #[serde(rename="desiredExpiryTimeMillis")] - pub desired_expiry_time_millis: String, + pub desired_expiry_time_millis: Option, } impl Part for SubscriptionDeferralInfo {} @@ -525,9 +525,9 @@ impl RequestValue for InappproductsBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MonthDay { /// Day of a month, value in [1, 31] range. Valid range depends on the specified month. - pub day: u32, + pub day: Option, /// Month of a year. e.g. 1 = JAN, 2 = FEB etc. - pub month: u32, + pub month: Option, } impl Part for MonthDay {} @@ -548,20 +548,20 @@ pub struct ProductPurchase { /// - Yet to be consumed /// - Consumed #[serde(rename="consumptionState")] - pub consumption_state: i32, + pub consumption_state: Option, /// A developer-specified string that contains supplemental information about an order. #[serde(rename="developerPayload")] - pub developer_payload: String, + pub developer_payload: Option, /// This kind represents an inappPurchase object in the androidpublisher service. - pub kind: String, + pub kind: Option, /// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970). #[serde(rename="purchaseTimeMillis")] - pub purchase_time_millis: String, + pub purchase_time_millis: Option, /// The purchase state of the order. Possible values are: /// - Purchased /// - Cancelled #[serde(rename="purchaseState")] - pub purchase_state: i32, + pub purchase_state: Option, } impl ResponseResult for ProductPurchase {} @@ -579,9 +579,9 @@ impl ResponseResult for ProductPurchase {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApkListingsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apkListingsListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub listings: Vec, + pub listings: Option>, } impl ResponseResult for ApkListingsListResponse {} @@ -599,7 +599,7 @@ impl ResponseResult for ApkListingsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImagesDeleteAllResponse { /// no description provided - pub deleted: Vec, + pub deleted: Option>, } impl ResponseResult for ImagesDeleteAllResponse {} @@ -639,9 +639,9 @@ impl ResponseResult for Track {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Season { /// Inclusive start date of the recurrence period. - pub start: MonthDay, + pub start: Option, /// Inclusive end date of the recurrence period. - pub end: MonthDay, + pub end: Option, } impl Part for Season {} @@ -654,9 +654,9 @@ impl Part for Season {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InAppProductListing { /// no description provided - pub description: String, + pub description: Option, /// no description provided - pub title: String, + pub title: Option, } impl Part for InAppProductListing {} @@ -688,7 +688,7 @@ impl RequestValue for SubscriptionPurchasesDeferRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InappproductsInsertResponse { /// no description provided - pub inappproduct: InAppProduct, + pub inappproduct: Option, } impl Part for InappproductsInsertResponse {} @@ -702,49 +702,49 @@ impl Part for InappproductsInsertResponse {} pub struct ExternallyHostedApk { /// The icon image from the APK, as a base64 encoded byte array. #[serde(rename="iconBase64")] - pub icon_base64: String, + pub icon_base64: Option, /// A certificate (or array of certificates if a certificate-chain is used) used to signed this APK, represented as a base64 encoded byte array. #[serde(rename="certificateBase64s")] - pub certificate_base64s: Vec, + pub certificate_base64s: Option>, /// The URL at which the APK is hosted. This must be an https URL. #[serde(rename="externallyHostedUrl")] - pub externally_hosted_url: String, + pub externally_hosted_url: Option, /// The maximum SDK supported by this APK (optional). #[serde(rename="maximumSdk")] - pub maximum_sdk: i32, + pub maximum_sdk: Option, /// The SHA256 checksum of this APK, represented as a base64 encoded byte array. #[serde(rename="fileSha256Base64")] - pub file_sha256_base64: String, + pub file_sha256_base64: Option, /// The permissions requested by this APK. #[serde(rename="usesPermissions")] - pub uses_permissions: Vec, + pub uses_permissions: Option>, /// The SHA1 checksum of this APK, represented as a base64 encoded byte array. #[serde(rename="fileSha1Base64")] - pub file_sha1_base64: String, + pub file_sha1_base64: Option, /// The features required by this APK (optional). #[serde(rename="usesFeatures")] - pub uses_features: Vec, + pub uses_features: Option>, /// The native code environments supported by this APK (optional). #[serde(rename="nativeCodes")] - pub native_codes: Vec, + pub native_codes: Option>, /// The file size in bytes of this APK. #[serde(rename="fileSize")] - pub file_size: String, + pub file_size: Option, /// The version name of this APK. #[serde(rename="versionName")] - pub version_name: String, + pub version_name: Option, /// The version code of this APK. #[serde(rename="versionCode")] - pub version_code: i32, + pub version_code: Option, /// The minimum SDK targeted by this APK. #[serde(rename="minimumSdk")] - pub minimum_sdk: i32, + pub minimum_sdk: Option, /// The application label. #[serde(rename="applicationLabel")] - pub application_label: String, + pub application_label: Option, /// The package name. #[serde(rename="packageName")] - pub package_name: String, + pub package_name: Option, } impl Part for ExternallyHostedApk {} @@ -789,11 +789,11 @@ impl ResponseResult for AppDetails {} pub struct InappproductsBatchResponseEntry { /// no description provided #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// no description provided - pub inappproductsinsertresponse: InappproductsInsertResponse, + pub inappproductsinsertresponse: Option, /// no description provided - pub inappproductsupdateresponse: InappproductsUpdateResponse, + pub inappproductsupdateresponse: Option, } impl Part for InappproductsBatchResponseEntry {} @@ -806,7 +806,7 @@ impl Part for InappproductsBatchResponseEntry {} #[derive(Default, Clone, Debug, Serialize)] pub struct InappproductsInsertRequest { /// no description provided - pub inappproduct: InAppProduct, + pub inappproduct: Option, } impl Part for InappproductsInsertRequest {} @@ -820,9 +820,9 @@ impl Part for InappproductsInsertRequest {} pub struct ExternallyHostedApkUsesPermission { /// Optionally, the maximum SDK version for which the permission is required. #[serde(rename="maxSdkVersion")] - pub max_sdk_version: i32, + pub max_sdk_version: Option, /// The name of the permission requested. - pub name: String, + pub name: Option, } impl Part for ExternallyHostedApkUsesPermission {} @@ -836,14 +836,14 @@ impl Part for ExternallyHostedApkUsesPermission {} pub struct InappproductsBatchRequestEntry { /// no description provided #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// no description provided - pub inappproductsinsertrequest: InappproductsInsertRequest, + pub inappproductsinsertrequest: Option, /// no description provided #[serde(rename="methodName")] - pub method_name: String, + pub method_name: Option, /// no description provided - pub inappproductsupdaterequest: InappproductsUpdateRequest, + pub inappproductsupdaterequest: Option, } impl Part for InappproductsBatchRequestEntry {} @@ -861,9 +861,9 @@ impl Part for InappproductsBatchRequestEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TracksListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#tracksListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub tracks: Vec, + pub tracks: Option>, } impl ResponseResult for TracksListResponse {} @@ -882,7 +882,7 @@ impl ResponseResult for TracksListResponse {} pub struct SubscriptionPurchasesDeferResponse { /// The new expiry time for the subscription in milliseconds since the Epoch. #[serde(rename="newExpiryTimeMillis")] - pub new_expiry_time_millis: String, + pub new_expiry_time_millis: Option, } impl ResponseResult for SubscriptionPurchasesDeferResponse {} @@ -900,15 +900,15 @@ impl ResponseResult for SubscriptionPurchasesDeferResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InappproductsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#inappproductsListResponse". - pub kind: String, + pub kind: Option, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option, /// no description provided - pub inappproduct: Vec, + pub inappproduct: Option>, } impl ResponseResult for InappproductsListResponse {} @@ -922,10 +922,10 @@ impl ResponseResult for InappproductsListResponse {} pub struct TokenPagination { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// no description provided #[serde(rename="previousPageToken")] - pub previous_page_token: String, + pub previous_page_token: Option, } impl Part for TokenPagination {} @@ -1018,7 +1018,7 @@ impl ResponseResult for ExpansionFile {} pub struct ApksAddExternallyHostedResponse { /// The definition of the externally-hosted APK and where it is located. #[serde(rename="externallyHostedApk")] - pub externally_hosted_apk: ExternallyHostedApk, + pub externally_hosted_apk: Option, } impl ResponseResult for ApksAddExternallyHostedResponse {} @@ -1037,15 +1037,15 @@ impl ResponseResult for ApksAddExternallyHostedResponse {} pub struct SubscriptionPurchase { /// Whether the subscription will automatically be renewed when it reaches its current expiry time. #[serde(rename="autoRenewing")] - pub auto_renewing: bool, + pub auto_renewing: Option, /// This kind represents a subscriptionPurchase object in the androidpublisher service. - pub kind: String, + pub kind: Option, /// Time at which the subscription will expire, in milliseconds since Epoch. #[serde(rename="expiryTimeMillis")] - pub expiry_time_millis: String, + pub expiry_time_millis: Option, /// Time at which the subscription was granted, in milliseconds since Epoch. #[serde(rename="startTimeMillis")] - pub start_time_millis: String, + pub start_time_millis: Option, } impl ResponseResult for SubscriptionPurchase {} @@ -1088,9 +1088,9 @@ impl ResponseResult for AppEdit {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApksListResponse { /// no description provided - pub apks: Vec, + pub apks: Option>, /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#apksListResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for ApksListResponse {} @@ -1103,7 +1103,7 @@ impl ResponseResult for ApksListResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct InappproductsUpdateRequest { /// no description provided - pub inappproduct: InAppProduct, + pub inappproduct: Option, } impl Part for InappproductsUpdateRequest {} @@ -1117,13 +1117,13 @@ impl Part for InappproductsUpdateRequest {} pub struct PageInfo { /// no description provided #[serde(rename="resultPerPage")] - pub result_per_page: i32, + pub result_per_page: Option, /// no description provided #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option, /// no description provided #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option, } impl Part for PageInfo {} @@ -1141,7 +1141,7 @@ impl Part for PageInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImagesUploadResponse { /// no description provided - pub image: Image, + pub image: Option, } impl ResponseResult for ImagesUploadResponse {} @@ -1160,9 +1160,9 @@ impl ResponseResult for ImagesUploadResponse {} pub struct Apk { /// The version code of the APK, as specified in the APK's manifest file. #[serde(rename="versionCode")] - pub version_code: i32, + pub version_code: Option, /// Information about the binary payload of this APK. - pub binary: ApkBinary, + pub binary: Option, } impl ResponseResult for Apk {} @@ -1180,9 +1180,9 @@ impl ResponseResult for Apk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InappproductsBatchResponse { /// no description provided - pub entrys: Vec, + pub entrys: Option>, /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#inappproductsBatchResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for InappproductsBatchResponse {} @@ -1195,11 +1195,11 @@ impl ResponseResult for InappproductsBatchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Image { /// A URL that will serve a preview of the image. - pub url: String, + pub url: Option, /// A sha1 hash of the image that was uploaded. - pub sha1: String, + pub sha1: Option, /// A unique id representing this image. - pub id: String, + pub id: Option, } impl Part for Image {} @@ -1231,7 +1231,7 @@ impl RequestValue for ApksAddExternallyHostedRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApkBinary { /// A sha1 hash of the APK payload, encoded as a hex string and matching the output of the sha1sum command. - pub sha1: String, + pub sha1: Option, } impl Part for ApkBinary {} @@ -1244,10 +1244,10 @@ impl Part for ApkBinary {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Price { /// 3 letter Currency code, as defined by ISO 4217. - pub currency: String, + pub currency: Option, /// The price in millionths of the currency base unit represented as a string. #[serde(rename="priceMicros")] - pub price_micros: String, + pub price_micros: Option, } impl Part for Price {} @@ -1265,9 +1265,9 @@ impl Part for Price {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListingsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "androidpublisher#listingsListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub listings: Vec, + pub listings: Option>, } impl ResponseResult for ListingsListResponse {} @@ -2589,16 +2589,20 @@ impl<'a, C, A> PurchaseSubscriptionRevokeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2833,16 +2837,20 @@ impl<'a, C, A> PurchaseProductGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3087,16 +3095,20 @@ impl<'a, C, A> PurchaseSubscriptionGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3340,16 +3352,20 @@ impl<'a, C, A> PurchaseSubscriptionCancelCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3583,16 +3599,20 @@ impl<'a, C, A> PurchaseSubscriptionRefundCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3742,7 +3762,7 @@ impl<'a, C, A> PurchaseSubscriptionRefundCall<'a, C, A> where C: BorrowMut PurchaseSubscriptionDeferCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4119,16 +4143,20 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, let mut upload_url: Option = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -4395,7 +4423,7 @@ impl<'a, C, A> EditImageUploadCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ExpansionFile = Default::default(); +/// let mut req = ExpansionFile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4493,16 +4521,20 @@ impl<'a, C, A> EditExpansionfileUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4767,16 +4799,20 @@ impl<'a, C, A> EditDetailGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5012,16 +5048,20 @@ impl<'a, C, A> EditApklistingDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5263,16 +5303,20 @@ impl<'a, C, A> EditListingDeleteallCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5412,7 +5456,7 @@ impl<'a, C, A> EditListingDeleteallCall<'a, C, A> where C: BorrowMut EditApkAddexternallyhostedCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5762,16 +5810,20 @@ impl<'a, C, A> EditApklistingDeleteallCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5921,7 +5973,7 @@ impl<'a, C, A> EditApklistingDeleteallCall<'a, C, A> where C: BorrowMut EditDetailUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6272,16 +6328,20 @@ impl<'a, C, A> EditTrackGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6441,7 +6501,7 @@ impl<'a, C, A> EditTrackGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ExpansionFile = Default::default(); +/// let mut req = ExpansionFile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6539,16 +6599,20 @@ impl<'a, C, A> EditExpansionfilePatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6817,16 +6881,20 @@ impl<'a, C, A> EditImageListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6995,7 +7063,7 @@ impl<'a, C, A> EditImageListCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Track = Default::default(); +/// let mut req = Track::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7091,16 +7159,20 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7273,7 +7345,7 @@ impl<'a, C, A> EditTrackUpdateCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Listing = Default::default(); +/// let mut req = Listing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7369,16 +7441,20 @@ impl<'a, C, A> EditListingPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7634,16 +7710,20 @@ impl<'a, C, A> EditGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7881,16 +7961,20 @@ impl<'a, C, A> EditImageDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8152,16 +8236,20 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: let mut upload_url: Option = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -8409,7 +8497,7 @@ impl<'a, C, A> EditApkUploadCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ApkListing = Default::default(); +/// let mut req = ApkListing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8507,16 +8595,20 @@ impl<'a, C, A> EditApklistingUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8780,16 +8872,20 @@ impl<'a, C, A> EditApkListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8939,7 +9035,7 @@ impl<'a, C, A> EditApkListCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ApkListing = Default::default(); +/// let mut req = ApkListing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9037,16 +9133,20 @@ impl<'a, C, A> EditApklistingPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9314,16 +9414,20 @@ impl<'a, C, A> EditListingGetCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9566,16 +9670,20 @@ impl<'a, C, A> EditTesterGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9816,16 +9924,20 @@ impl<'a, C, A> EditDeleteCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10064,16 +10176,20 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -10340,7 +10456,7 @@ impl<'a, C, A> EditExpansionfileUploadCall<'a, C, A> where C: BorrowMut EditInsertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10677,16 +10797,20 @@ impl<'a, C, A> EditListingListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10834,7 +10958,7 @@ impl<'a, C, A> EditListingListCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Testers = Default::default(); +/// let mut req = Testers::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10930,16 +11054,20 @@ impl<'a, C, A> EditTesterPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11194,16 +11322,20 @@ impl<'a, C, A> EditCommitCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11436,16 +11568,20 @@ impl<'a, C, A> EditTrackListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11678,16 +11814,20 @@ impl<'a, C, A> EditValidateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11837,7 +11977,7 @@ impl<'a, C, A> EditValidateCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Listing = Default::default(); +/// let mut req = Listing::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11933,16 +12073,20 @@ impl<'a, C, A> EditListingUpdateCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12202,16 +12346,20 @@ impl<'a, C, A> EditExpansionfileGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12467,16 +12615,20 @@ impl<'a, C, A> EditImageDeleteallCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -12645,7 +12797,7 @@ impl<'a, C, A> EditImageDeleteallCall<'a, C, A> where C: BorrowMut EditDetailPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12911,7 +13067,7 @@ impl<'a, C, A> EditDetailPatchCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Track = Default::default(); +/// let mut req = Track::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13007,16 +13163,20 @@ impl<'a, C, A> EditTrackPatchCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13273,16 +13433,20 @@ impl<'a, C, A> EditListingDeleteCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13519,16 +13683,20 @@ impl<'a, C, A> EditApklistingGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13696,7 +13864,7 @@ impl<'a, C, A> EditApklistingGetCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Testers = Default::default(); +/// let mut req = Testers::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13792,16 +13960,20 @@ impl<'a, C, A> EditTesterUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14058,16 +14230,20 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14225,7 +14401,7 @@ impl<'a, C, A> EditApklistingListCall<'a, C, A> where C: BorrowMut InappproductBatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14539,16 +14719,20 @@ impl<'a, C, A> InappproductListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14706,7 +14890,7 @@ impl<'a, C, A> InappproductListCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InAppProduct = Default::default(); +/// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14803,16 +14987,20 @@ impl<'a, C, A> InappproductInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15054,16 +15242,20 @@ impl<'a, C, A> InappproductDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -15286,16 +15478,20 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15444,7 +15640,7 @@ impl<'a, C, A> InappproductGetCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InAppProduct = Default::default(); +/// let mut req = InAppProduct::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15543,16 +15739,20 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15722,7 +15922,7 @@ impl<'a, C, A> InappproductUpdateCall<'a, C, A> where C: BorrowMut InappproductPatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/appsactivity1-cli/Cargo.toml b/gen/appsactivity1-cli/Cargo.toml index 9a611addd7..40e4f8d2d1 100644 --- a/gen/appsactivity1-cli/Cargo.toml +++ b/gen/appsactivity1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-appsactivity1-cli" version = "0.0.1+20140828" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/google-apps/activity/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/appsactivity1-cli/src/cmn.rs b/gen/appsactivity1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/appsactivity1-cli/src/cmn.rs +++ b/gen/appsactivity1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/appsactivity1-cli/src/main.rs b/gen/appsactivity1-cli/src/main.rs index 7f99587886..4a4b243924 100644 --- a/gen/appsactivity1-cli/src/main.rs +++ b/gen/appsactivity1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -32,6 +33,12 @@ Configuration: 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. "); mod cmn; @@ -55,7 +62,7 @@ impl Engine { -> Option { let mut call = self.hub.activities().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-id" => { call = call.user_id(value.unwrap_or("")); @@ -108,8 +115,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -147,21 +153,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "appsactivity1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "appsactivity1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "appsactivity1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "appsactivity1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Appsactivity::new(hyper::Client::new(), auth), + hub: api::Appsactivity::new(client, auth), }; match engine._doit(true) { @@ -181,12 +203,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/appsactivity1/Cargo.toml b/gen/appsactivity1/Cargo.toml index 7db884e80f..3d23f8434e 100644 --- a/gen/appsactivity1/Cargo.toml +++ b/gen/appsactivity1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-appsactivity1" version = "0.1.5+20140828" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/google-apps/activity/" diff --git a/gen/appsactivity1/src/cmn.rs b/gen/appsactivity1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/appsactivity1/src/cmn.rs +++ b/gen/appsactivity1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/appsactivity1/src/lib.rs b/gen/appsactivity1/src/lib.rs index 9a33b9dea2..d378793c71 100644 --- a/gen/appsactivity1/src/lib.rs +++ b/gen/appsactivity1/src/lib.rs @@ -354,10 +354,10 @@ impl<'a, C, A> Appsactivity pub struct Rename { /// The new title. #[serde(rename="newTitle")] - pub new_title: String, + pub new_title: Option, /// The old title. #[serde(rename="oldTitle")] - pub old_title: String, + pub old_title: Option, } impl Part for Rename {} @@ -371,10 +371,10 @@ impl Part for Rename {} pub struct PermissionChange { /// Lists all Permission objects removed. #[serde(rename="removedPermissions")] - pub removed_permissions: Vec, + pub removed_permissions: Option>, /// Lists all Permission objects added. #[serde(rename="addedPermissions")] - pub added_permissions: Vec, + pub added_permissions: Option>, } impl Part for PermissionChange {} @@ -388,11 +388,11 @@ impl Part for PermissionChange {} pub struct Target { /// The MIME type of the target. #[serde(rename="mimeType")] - pub mime_type: String, + pub mime_type: Option, /// The ID of the target. For example, in Google Drive, this is the file or folder ID. - pub id: String, + pub id: Option, /// The name of the target. For example, in Google Drive, this is the title of the file. - pub name: String, + pub name: Option, } impl Part for Target {} @@ -405,12 +405,12 @@ impl Part for Target {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Parent { /// The parent's ID. - pub id: String, + pub id: Option, /// Whether this is the root folder. #[serde(rename="isRoot")] - pub is_root: bool, + pub is_root: Option, /// The parent's title. - pub title: String, + pub title: Option, } impl Part for Parent {} @@ -424,19 +424,19 @@ impl Part for Parent {} pub struct Permission { /// Whether the permission requires a link to the file. #[serde(rename="withLink")] - pub with_link: bool, + pub with_link: Option, /// The ID for this permission. Corresponds to the Drive API's permission ID returned as part of the Drive Permissions resource. #[serde(rename="permissionId")] - pub permission_id: String, + pub permission_id: Option, /// Indicates the Google Drive permissions role. The role determines a user's ability to read, write, or comment on the file. - pub role: String, + pub role: Option, /// The name of the user or group the permission applies to. - pub name: String, + pub name: Option, /// Indicates how widely permissions are granted. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The user's information if the type is USER. - pub user: User, + pub user: Option, } impl Part for Permission {} @@ -449,7 +449,7 @@ impl Part for Permission {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Photo { /// The URL of the photo. - pub url: String, + pub url: Option, } impl Part for Photo {} @@ -463,10 +463,10 @@ impl Part for Photo {} pub struct Move { /// The removed parent(s). #[serde(rename="removedParents")] - pub removed_parents: Vec, + pub removed_parents: Option>, /// The added parent(s). #[serde(rename="addedParents")] - pub added_parents: Vec, + pub added_parents: Option>, } impl Part for Move {} @@ -485,9 +485,9 @@ impl Part for Move {} pub struct ListActivitiesResponse { /// Token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// List of activities. - pub activities: Vec, + pub activities: Option>, } impl ResponseResult for ListActivitiesResponse {} @@ -500,9 +500,9 @@ impl ResponseResult for ListActivitiesResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct User { /// The profile photo of the user. - pub photo: Photo, + pub photo: Option, /// The displayable name of the user. - pub name: String, + pub name: Option, } impl Part for User {} @@ -516,10 +516,10 @@ impl Part for User {} pub struct Activity { /// The fields common to all of the singleEvents that make up the Activity. #[serde(rename="combinedEvent")] - pub combined_event: Event, + pub combined_event: Option, /// A list of all the Events that make up the Activity. #[serde(rename="singleEvents")] - pub single_events: Vec, + pub single_events: Option>, } impl Part for Activity {} @@ -532,29 +532,29 @@ impl Part for Activity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Event { /// Extra information for rename type events, such as the old and new names. - pub rename: Rename, + pub rename: Option, /// Information specific to the Target object modified by the event. - pub target: Target, + pub target: Option, /// Additional event types. Some events may have multiple types when multiple actions are part of a single event. For example, creating a document, renaming it, and sharing it may be part of a single file-creation event. #[serde(rename="additionalEventTypes")] - pub additional_event_types: Vec, + pub additional_event_types: Option>, /// Extra information for move type events, such as changes in an object's parents. #[serde(rename="move")] - pub move_: Move, + pub move_: Option, /// Extra information for permissionChange type events, such as the user or group the new permission applies to. #[serde(rename="permissionChanges")] - pub permission_changes: Vec, + pub permission_changes: Option>, /// Represents the user responsible for the event. - pub user: User, + pub user: Option, /// The time at which the event occurred formatted as Unix time in milliseconds. #[serde(rename="eventTimeMillis")] - pub event_time_millis: String, + pub event_time_millis: Option, /// The main type of event that occurred. #[serde(rename="primaryEventType")] - pub primary_event_type: String, + pub primary_event_type: Option, /// Whether this event is caused by a user being deleted. #[serde(rename="fromUserDeletion")] - pub from_user_deletion: bool, + pub from_user_deletion: Option, } impl Part for Event {} @@ -748,16 +748,20 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/appstate1-cli/Cargo.toml b/gen/appstate1-cli/Cargo.toml index 7708f7eb8d..0d07d1c0d1 100644 --- a/gen/appstate1-cli/Cargo.toml +++ b/gen/appstate1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-appstate1-cli" -version = "0.0.1+20150326" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/games/services/web/api/states" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/appstate1-cli/mkdocs.yml b/gen/appstate1-cli/mkdocs.yml index 09996fa33b..fa05ee0dee 100644 --- a/gen/appstate1-cli/mkdocs.yml +++ b/gen/appstate1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: App State v0.0.1+20150326 +site_name: App State v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/appstate1-cli/src/cmn.rs +++ b/gen/appstate1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/appstate1-cli/src/main.rs b/gen/appstate1-cli/src/main.rs index 4441e7b652..696705a293 100644 --- a/gen/appstate1-cli/src/main.rs +++ b/gen/appstate1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -36,6 +37,12 @@ Configuration: 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. "); mod cmn; @@ -60,7 +67,7 @@ impl Engine { let state_key: i32 = arg_from_str(&self.opt.arg_state_key, err, "", "integer"); let mut call = self.hub.states().clear(state_key); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "current-data-version" => { call = call.current_data_version(value.unwrap_or("")); @@ -95,8 +102,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -108,7 +114,7 @@ impl Engine { let state_key: i32 = arg_from_str(&self.opt.arg_state_key, err, "", "integer"); let mut call = self.hub.states().delete(state_key); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -139,7 +145,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -151,7 +156,7 @@ impl Engine { let state_key: i32 = arg_from_str(&self.opt.arg_state_key, err, "", "integer"); let mut call = self.hub.states().get(state_key); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -183,8 +188,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -195,7 +199,7 @@ impl Engine { -> Option { let mut call = self.hub.states().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "include-data" => { call = call.include_data(arg_from_str(value.unwrap_or("false"), err, "include-data", "boolean")); @@ -230,8 +234,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -240,11 +243,11 @@ impl Engine { fn _states_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UpdateRequest = Default::default(); + let mut request = api::UpdateRequest::default(); let state_key: i32 = arg_from_str(&self.opt.arg_state_key, err, "", "integer"); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "current-state-version" => { call = call.current_state_version(value.unwrap_or("")); @@ -267,9 +270,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -297,8 +301,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -344,21 +347,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "appstate1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "appstate1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "appstate1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "appstate1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AppState::new(hyper::Client::new(), auth), + hub: api::AppState::new(client, auth), }; match engine._doit(true) { @@ -378,12 +397,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/appstate1/Cargo.toml b/gen/appstate1/Cargo.toml index d943da9629..e770a879e2 100644 --- a/gen/appstate1/Cargo.toml +++ b/gen/appstate1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-appstate1" -version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/games/services/web/api/states" diff --git a/gen/appstate1/README.md b/gen/appstate1/README.md index 5d6657648e..986c6e6340 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+20150326*, where *20150326* 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.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*. 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). @@ -94,7 +94,7 @@ let mut hub = AppState::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: UpdateRequest = Default::default(); +let mut req = UpdateRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/appstate1/src/cmn.rs b/gen/appstate1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/appstate1/src/cmn.rs +++ b/gen/appstate1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/appstate1/src/lib.rs b/gen/appstate1/src/lib.rs index 80d095afb2..365a3ea09d 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+20150326*, where *20150326* 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.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*. //! //! 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). @@ -95,7 +95,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: UpdateRequest = Default::default(); +//! let mut req = UpdateRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -271,7 +271,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UpdateRequest = Default::default(); +/// let mut req = UpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -347,12 +347,12 @@ impl<'a, C, A> AppState #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListResponse { /// The app state data. - pub items: Vec, + pub items: Option>, /// Uniquely identifies the type of this resource. Value is always the fixed string appstate#listResponse. - pub kind: String, + pub kind: Option, /// The maximum number of keys allowed for this user. #[serde(rename="maximumKeyCount")] - pub maximum_key_count: i32, + pub maximum_key_count: Option, } impl ResponseResult for ListResponse {} @@ -370,15 +370,15 @@ impl ResponseResult for ListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GetResponse { /// The requested data. - pub data: String, + pub data: Option, /// Uniquely identifies the type of this resource. Value is always the fixed string appstate#getResponse. - pub kind: String, + pub kind: Option, /// The key for the data. #[serde(rename="stateKey")] - pub state_key: i32, + pub state_key: Option, /// The current app state version. #[serde(rename="currentStateVersion")] - pub current_state_version: String, + pub current_state_version: Option, } impl ResponseResult for GetResponse {} @@ -417,13 +417,13 @@ impl RequestValue for UpdateRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WriteResult { /// Uniquely identifies the type of this resource. Value is always the fixed string appstate#writeResult. - pub kind: String, + pub kind: Option, /// The written key. #[serde(rename="stateKey")] - pub state_key: i32, + pub state_key: Option, /// The version of the data for this key on the server. #[serde(rename="currentStateVersion")] - pub current_state_version: String, + pub current_state_version: Option, } impl ResponseResult for WriteResult {} @@ -673,16 +673,20 @@ impl<'a, C, A> StateDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -893,16 +897,20 @@ impl<'a, C, A> StateGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1128,16 +1136,20 @@ impl<'a, C, A> StateClearCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1344,16 +1356,20 @@ impl<'a, C, A> StateListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1490,7 +1506,7 @@ impl<'a, C, A> StateListCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UpdateRequest = Default::default(); +/// let mut req = UpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1587,16 +1603,20 @@ impl<'a, C, A> StateUpdateCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/audit1-cli/Cargo.toml b/gen/audit1-cli/Cargo.toml deleted file mode 100644 index 5392beeea5..0000000000 --- a/gen/audit1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-audit1-cli" -version = "0.0.1+20130108" -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" -homepage = "https://developers.google.com/google-apps/admin-audit/get_started" -documentation = "http://byron.github.io/google-apis-rs/google_audit1_cli" -license = "MIT" -keywords = ["audit", "google", "cli"] - -[[bin]] -name = "audit1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-audit1] -path = "../audit1" diff --git a/gen/audit1-cli/LICENSE.md b/gen/audit1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/audit1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/audit1-cli/README.md b/gen/audit1-cli/README.md deleted file mode 100644 index a997937649..0000000000 --- a/gen/audit1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO AUDIT:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/audit1-cli/mkdocs.yml b/gen/audit1-cli/mkdocs.yml deleted file mode 100644 index 382f806e92..0000000000 --- a/gen/audit1-cli/mkdocs.yml +++ /dev/null @@ -1,17 +0,0 @@ -site_name: audit v0.0.1+20130108 -site_url: http://byron.github.io/google-apis-rs/google-audit1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/audit1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['activities_list.md', 'Activities', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/audit1-cli/src/cmn.rs b/gen/audit1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/audit1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/audit1-cli/src/main.rs b/gen/audit1-cli/src/main.rs deleted file mode 100644 index 55a67d0534..0000000000 --- a/gen/audit1-cli/src/main.rs +++ /dev/null @@ -1,196 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_audit1 as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - audit1 [options] activities list [-p ]... [-o ] - audit1 --help - -All documentation details can be found TODO: - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Audit>, -} - - -impl Engine { - fn _activities_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.activities().list(&self.opt.arg_customer_id, &self.opt.arg_application_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-time" => { - call = call.start_time(value.unwrap_or("")); - }, - "max-results" => { - call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); - }, - "event-name" => { - call = call.event_name(value.unwrap_or("")); - }, - "end-time" => { - call = call.end_time(value.unwrap_or("")); - }, - "continuation-token" => { - call = call.continuation_token(value.unwrap_or("")); - }, - "caller" => { - call = call.caller(value.unwrap_or("")); - }, - "actor-ip-address" => { - call = call.actor_ip_address(value.unwrap_or("")); - }, - "actor-email" => { - call = call.actor_email(value.unwrap_or("")); - }, - "actor-application-id" => { - call = call.actor_application_id(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option, Option) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option; - let mut err_opt: Option = None; - - if self.opt.cmd_activities { - if self.opt.cmd_list { - call_result = self._activities_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "audit1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "audit1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Audit::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/audit1/Cargo.toml b/gen/audit1/Cargo.toml index 16080b778c..6565b13823 100644 --- a/gen/audit1/Cargo.toml +++ b/gen/audit1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-audit1" -version = "0.1.5+20130108" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/google-apps/admin-audit/get_started" diff --git a/gen/audit1/README.md b/gen/audit1/README.md index b48b7ed3e4..70a1b07533 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+20130108*, where *20130108* 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.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*. 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). diff --git a/gen/audit1/src/cmn.rs b/gen/audit1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/audit1/src/cmn.rs +++ b/gen/audit1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/audit1/src/lib.rs b/gen/audit1/src/lib.rs index 71085373e1..05635d541a 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+20130108*, where *20130108* 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.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*. //! //! 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). @@ -328,11 +328,11 @@ impl<'a, C, A> Audit #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Activities { /// Each record in read response. - pub items: Vec, + pub items: Option>, /// Kind of list response this is. - pub kind: String, + pub kind: Option, /// Next page URL. - pub next: String, + pub next: Option, } impl ResponseResult for Activities {} @@ -346,14 +346,14 @@ impl ResponseResult for Activities {} pub struct ActivityActor { /// ID of application which interacted on behalf of the user. #[serde(rename="applicationId")] - pub application_id: String, + pub application_id: Option, /// Email address of the user. - pub email: String, + pub email: Option, /// For OAuth 2LO API requests, consumer_key of the requestor. - pub key: String, + pub key: Option, /// User or OAuth 2LO request. #[serde(rename="callerType")] - pub caller_type: String, + pub caller_type: Option, } impl NestedType for ActivityActor {} @@ -368,15 +368,15 @@ impl Part for ActivityActor {} pub struct ActivityId { /// Unique qualifier if multiple events have the same time. #[serde(rename="uniqQualifier")] - pub uniq_qualifier: String, + pub uniq_qualifier: Option, /// Application ID of the source application. #[serde(rename="applicationId")] - pub application_id: String, + pub application_id: Option, /// Obfuscated customer ID of the source customer. #[serde(rename="customerId")] - pub customer_id: String, + pub customer_id: Option, /// Time of occurrence of the activity. - pub time: String, + pub time: Option, } impl NestedType for ActivityId {} @@ -390,19 +390,19 @@ impl Part for ActivityId {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Activity { /// Kind of resource this is. - pub kind: String, + pub kind: Option, /// Activity events. - pub events: Vec, + pub events: Option>, /// IP Address of the user doing the action. #[serde(rename="ipAddress")] - pub ip_address: String, + pub ip_address: Option, /// Domain of source customer. #[serde(rename="ownerDomain")] - pub owner_domain: String, + pub owner_domain: Option, /// User doing the action. - pub actor: ActivityActor, + pub actor: Option, /// Unique identifier for each activity record. - pub id: ActivityId, + pub id: Option, } impl Part for Activity {} @@ -415,9 +415,9 @@ impl Part for Activity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityEventsParameters { /// Name of the parameter. - pub name: String, + pub name: Option, /// Value of the parameter. - pub value: String, + pub value: Option, } impl NestedType for ActivityEventsParameters {} @@ -432,11 +432,11 @@ impl Part for ActivityEventsParameters {} pub struct ActivityEvents { /// Type of event. #[serde(rename="eventType")] - pub event_type: String, + pub event_type: Option, /// Name of event. - pub name: String, + pub name: Option, /// Event parameters. - pub parameters: Vec, + pub parameters: Option>, } impl NestedType for ActivityEvents {} diff --git a/gen/autoscaler1_beta2-cli/Cargo.toml b/gen/autoscaler1_beta2-cli/Cargo.toml index 4e17b50d2b..ba64f6bf26 100644 --- a/gen/autoscaler1_beta2-cli/Cargo.toml +++ b/gen/autoscaler1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-autoscaler1_beta2-cli" version = "0.0.1+20141112" -authors = ["Sebastian Thiel "] +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" homepage = "http://developers.google.com/compute/docs/autoscaler" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/autoscaler1_beta2-cli/src/cmn.rs b/gen/autoscaler1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/autoscaler1_beta2-cli/src/cmn.rs +++ b/gen/autoscaler1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/autoscaler1_beta2-cli/src/main.rs b/gen/autoscaler1_beta2-cli/src/main.rs index 912011986e..2fc9d24cdd 100644 --- a/gen/autoscaler1_beta2-cli/src/main.rs +++ b/gen/autoscaler1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -41,6 +42,12 @@ Configuration: 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. "); mod cmn; @@ -64,7 +71,7 @@ impl Engine { -> Option { let mut call = self.hub.autoscalers().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -96,8 +103,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -108,7 +114,7 @@ impl Engine { -> Option { let mut call = self.hub.autoscalers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -140,8 +146,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -150,10 +155,10 @@ impl Engine { fn _autoscalers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Autoscaler = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -173,18 +178,33 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.autoscaling_policy.as_mut().unwrap().cpu_utilization = Some(Default::default()); + } + } + fn request_autoscaling_policy_init(request: &mut api::Autoscaler) { if request.autoscaling_policy.is_none() { request.autoscaling_policy = Some(Default::default()); } } + fn request_autoscaling_policy_load_balancing_utilization_init(request: &mut api::Autoscaler) { + request_autoscaling_policy_init(request); + if request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.is_none() { + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -194,23 +214,23 @@ impl Engine { }, "autoscaling-policy.max-num-replicas" => { request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().max_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer"); + request.autoscaling_policy.as_mut().unwrap().max_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer")); }, "autoscaling-policy.cpu-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cpu_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cpu_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number")); }, "autoscaling-policy.min-num-replicas" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().min_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().min_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer")); }, "autoscaling-policy.cool-down-period-sec" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer")); }, "autoscaling-policy.load-balancing-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number"); + request_autoscaling_policy_load_balancing_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number")); }, "target" => { request_autoscaling_policy_init(&mut request); @@ -249,8 +269,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -261,7 +280,7 @@ impl Engine { -> Option { let mut call = self.hub.autoscalers().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -302,8 +321,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -312,10 +330,10 @@ impl Engine { fn _autoscalers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Autoscaler = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -335,18 +353,33 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.autoscaling_policy.as_mut().unwrap().cpu_utilization = Some(Default::default()); + } + } + fn request_autoscaling_policy_init(request: &mut api::Autoscaler) { if request.autoscaling_policy.is_none() { request.autoscaling_policy = Some(Default::default()); } } + fn request_autoscaling_policy_load_balancing_utilization_init(request: &mut api::Autoscaler) { + request_autoscaling_policy_init(request); + if request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.is_none() { + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -356,23 +389,23 @@ impl Engine { }, "autoscaling-policy.max-num-replicas" => { request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().max_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer"); + request.autoscaling_policy.as_mut().unwrap().max_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer")); }, "autoscaling-policy.cpu-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cpu_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cpu_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number")); }, "autoscaling-policy.min-num-replicas" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().min_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().min_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer")); }, "autoscaling-policy.cool-down-period-sec" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer")); }, "autoscaling-policy.load-balancing-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number"); + request_autoscaling_policy_load_balancing_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number")); }, "target" => { request_autoscaling_policy_init(&mut request); @@ -411,8 +444,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -421,10 +453,10 @@ impl Engine { fn _autoscalers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Autoscaler = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -444,18 +476,33 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.autoscaling_policy.as_mut().unwrap().cpu_utilization = Some(Default::default()); + } + } + fn request_autoscaling_policy_init(request: &mut api::Autoscaler) { if request.autoscaling_policy.is_none() { request.autoscaling_policy = Some(Default::default()); } } + fn request_autoscaling_policy_load_balancing_utilization_init(request: &mut api::Autoscaler) { + request_autoscaling_policy_init(request); + if request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.is_none() { + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -465,23 +512,23 @@ impl Engine { }, "autoscaling-policy.max-num-replicas" => { request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().max_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer"); + request.autoscaling_policy.as_mut().unwrap().max_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.max-num-replicas", "integer")); }, "autoscaling-policy.cpu-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cpu_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cpu_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.cpu-utilization.utilization-target", "number")); }, "autoscaling-policy.min-num-replicas" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().min_num_replicas = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().min_num_replicas = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.min-num-replicas", "integer")); }, "autoscaling-policy.cool-down-period-sec" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer"); + request_autoscaling_policy_cpu_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().cool_down_period_sec = Some(arg_from_str(value.unwrap_or("-0"), err, "autoscaling-policy.cool-down-period-sec", "integer")); }, "autoscaling-policy.load-balancing-utilization.utilization-target" => { - request_autoscaling_policy_init(&mut request); - request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.utilization_target = arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number"); + request_autoscaling_policy_load_balancing_utilization_init(&mut request); + request.autoscaling_policy.as_mut().unwrap().load_balancing_utilization.as_mut().unwrap().utilization_target = Some(arg_from_str(value.unwrap_or("0.0"), err, "autoscaling-policy.load-balancing-utilization.utilization-target", "number")); }, "target" => { request_autoscaling_policy_init(&mut request); @@ -520,8 +567,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -532,7 +578,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().delete(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -563,7 +609,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -574,7 +619,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -606,8 +651,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -618,7 +662,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -659,8 +703,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -671,7 +714,7 @@ impl Engine { -> Option { let mut call = self.hub.zones().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -712,8 +755,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -741,7 +783,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zone_operations { + } + else if self.opt.cmd_zone_operations { if self.opt.cmd_delete { call_result = self._zone_operations_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -751,7 +794,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zones { + } + else if self.opt.cmd_zones { if self.opt.cmd_list { call_result = self._zones_list(dry_run, &mut err); } else { @@ -777,21 +821,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "autoscaler1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "autoscaler1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "autoscaler1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "autoscaler1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::AutoscalerHub::new(hyper::Client::new(), auth), + hub: api::AutoscalerHub::new(client, auth), }; match engine._doit(true) { @@ -811,12 +871,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 eaa1e84a48..77b103c9f2 100644 --- a/gen/autoscaler1_beta2/Cargo.toml +++ b/gen/autoscaler1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-autoscaler1_beta2" version = "0.1.5+20141112" -authors = ["Sebastian Thiel "] +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" homepage = "http://developers.google.com/compute/docs/autoscaler" diff --git a/gen/autoscaler1_beta2/src/cmn.rs b/gen/autoscaler1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/autoscaler1_beta2/src/cmn.rs +++ b/gen/autoscaler1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/autoscaler1_beta2/src/lib.rs b/gen/autoscaler1_beta2/src/lib.rs index fa1febab83..b7240cc3c1 100644 --- a/gen/autoscaler1_beta2/src/lib.rs +++ b/gen/autoscaler1_beta2/src/lib.rs @@ -352,15 +352,15 @@ impl<'a, C, A> AutoscalerHub #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeprecationStatus { /// no description provided - pub deleted: String, + pub deleted: Option, /// no description provided - pub deprecated: String, + pub deprecated: Option, /// no description provided - pub state: String, + pub state: Option, /// no description provided - pub obsolete: String, + pub obsolete: Option, /// no description provided - pub replacement: String, + pub replacement: Option, } impl Part for DeprecationStatus {} @@ -373,9 +373,9 @@ impl Part for DeprecationStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// no description provided - pub key: String, + pub key: Option, /// no description provided - pub value: String, + pub value: Option, } impl NestedType for OperationWarningsData {} @@ -428,11 +428,11 @@ impl Resource for Zone {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// no description provided - pub message: String, + pub message: Option, /// no description provided - pub code: String, + pub code: Option, /// no description provided - pub data: Vec, + pub data: Option>, } impl NestedType for OperationWarnings {} @@ -452,16 +452,16 @@ impl Part for OperationWarnings {} pub struct OperationList { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// no description provided - pub items: Vec, + pub items: Option>, /// Type of resource. Always compute#operations for Operations resource. - pub kind: String, + pub kind: Option, /// no description provided - pub id: String, + pub id: Option, /// no description provided #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for OperationList {} @@ -475,14 +475,14 @@ impl ResponseResult for OperationList {} pub struct ZoneMaintenanceWindows { /// no description provided #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// no description provided - pub description: String, + pub description: Option, /// no description provided #[serde(rename="beginTime")] - pub begin_time: String, + pub begin_time: Option, /// no description provided - pub name: String, + pub name: Option, } impl NestedType for ZoneMaintenanceWindows {} @@ -496,13 +496,13 @@ impl Part for ZoneMaintenanceWindows {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AutoscalingPolicyCustomMetricUtilization { /// Identifier of the metric. It should be a Cloud Monitoring metric. The metric can not have negative values. The metric should be an utilization metric (increasing number of VMs handling requests x times should reduce average value of the metric roughly x times). For example you could use: compute.googleapis.com/instance/network/received_bytes_count. - pub metric: String, + pub metric: Option, /// Defines type in which utilization_target is expressed. #[serde(rename="utilizationTargetType")] - pub utilization_target_type: String, + pub utilization_target_type: Option, /// Target value of the metric which Autoscaler should maintain. Must be a positive value. #[serde(rename="utilizationTarget")] - pub utilization_target: f64, + pub utilization_target: Option, } impl Part for AutoscalingPolicyCustomMetricUtilization {} @@ -515,11 +515,11 @@ impl Part for AutoscalingPolicyCustomMetricUtilization {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// no description provided - pub message: String, + pub message: Option, /// no description provided - pub code: String, + pub code: Option, /// no description provided - pub location: String, + pub location: Option, } impl NestedType for OperationErrorErrors {} @@ -534,22 +534,22 @@ impl Part for OperationErrorErrors {} pub struct AutoscalingPolicy { /// Configuration parameters of autoscaling based on custom metric. #[serde(rename="customMetricUtilizations")] - pub custom_metric_utilizations: Vec, + pub custom_metric_utilizations: Option>, /// The maximum number of replicas that the Autoscaler can scale up to. #[serde(rename="maxNumReplicas")] - pub max_num_replicas: i32, + pub max_num_replicas: Option, /// Exactly one utilization policy should be provided. Configuration parameters of CPU based autoscaling policy. #[serde(rename="cpuUtilization")] - pub cpu_utilization: AutoscalingPolicyCpuUtilization, + pub cpu_utilization: Option, /// The minimum number of replicas that the Autoscaler can scale down to. #[serde(rename="minNumReplicas")] - pub min_num_replicas: i32, + pub min_num_replicas: Option, /// The number of seconds that the Autoscaler should wait between two succeeding changes to the number of virtual machines. You should define an interval that is at least as long as the initialization time of a virtual machine and the time it may take for replica pool to create the virtual machine. The default is 60 seconds. #[serde(rename="coolDownPeriodSec")] - pub cool_down_period_sec: i32, + pub cool_down_period_sec: Option, /// Configuration parameters of autoscaling based on load balancer. #[serde(rename="loadBalancingUtilization")] - pub load_balancing_utilization: AutoscalingPolicyLoadBalancingUtilization, + pub load_balancing_utilization: Option, } impl Part for AutoscalingPolicy {} @@ -562,7 +562,7 @@ impl Part for AutoscalingPolicy {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// no description provided - pub errors: Vec, + pub errors: Option>, } impl NestedType for OperationError {} @@ -577,7 +577,7 @@ impl Part for OperationError {} pub struct AutoscalingPolicyCpuUtilization { /// The target utilization that the Autoscaler should maintain. It is represented as a fraction of used cores. For example: 6 cores used in 8-core VM are represented here as 0.75. Must be a float value between (0, 1]. If not defined, the default is 0.8. #[serde(rename="utilizationTarget")] - pub utilization_target: f64, + pub utilization_target: Option, } impl Part for AutoscalingPolicyCpuUtilization {} @@ -591,7 +591,7 @@ impl Part for AutoscalingPolicyCpuUtilization {} pub struct AutoscalingPolicyLoadBalancingUtilization { /// Fraction of backend capacity utilization (set in HTTP load balancing configuration) that Autoscaler should maintain. Must be a positive float value. If not defined, the default is 0.8. For example if your maxRatePerInstance capacity (in HTTP Load Balancing configuration) is set at 10 and you would like to keep number of instances such that each instance receives 7 QPS on average, set this to 0.7. #[serde(rename="utilizationTarget")] - pub utilization_target: f64, + pub utilization_target: Option, } impl Part for AutoscalingPolicyLoadBalancingUtilization {} @@ -610,11 +610,11 @@ impl Part for AutoscalingPolicyLoadBalancingUtilization {} pub struct AutoscalerListResponse { /// [Output only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Autoscaler resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, } impl ResponseResult for AutoscalerListResponse {} @@ -636,61 +636,61 @@ impl ResponseResult for AutoscalerListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// no description provided - pub status: String, + pub status: Option, /// no description provided #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option, /// no description provided - pub warnings: Vec, + pub warnings: Option>, /// no description provided - pub error: OperationError, + pub error: Option, /// no description provided #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option, /// no description provided #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option, /// no description provided #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option, /// no description provided #[serde(rename="clientOperationId")] - pub client_operation_id: String, + pub client_operation_id: Option, /// no description provided #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// no description provided - pub id: String, + pub id: Option, /// [Output Only] Type of the resource. Always kind#operation for Operation resources. - pub kind: String, + pub kind: Option, /// no description provided - pub name: String, + pub name: Option, /// no description provided - pub zone: String, + pub zone: Option, /// no description provided - pub region: String, + pub region: Option, /// no description provided #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// no description provided #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option, /// no description provided #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option, /// no description provided - pub progress: i32, + pub progress: Option, /// no description provided #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// no description provided #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option, /// no description provided #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option, /// no description provided - pub user: String, + pub user: Option, } impl ResponseResult for Operation {} @@ -709,16 +709,16 @@ impl ResponseResult for Operation {} pub struct ZoneList { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// no description provided - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// no description provided - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for ZoneList {} @@ -1238,16 +1238,20 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1502,16 +1506,20 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1761,16 +1769,20 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2002,16 +2014,20 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2266,16 +2282,20 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2443,7 +2463,7 @@ impl<'a, C, A> AutoscalerListCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Autoscaler = Default::default(); +/// let mut req = Autoscaler::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2539,16 +2559,20 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2721,7 +2745,7 @@ impl<'a, C, A> AutoscalerUpdateCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Autoscaler = Default::default(); +/// let mut req = Autoscaler::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2817,16 +2841,20 @@ impl<'a, C, A> AutoscalerPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3084,16 +3112,20 @@ impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3253,7 +3285,7 @@ impl<'a, C, A> AutoscalerDeleteCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Autoscaler = Default::default(); +/// let mut req = Autoscaler::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3347,16 +3379,20 @@ impl<'a, C, A> AutoscalerInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3604,16 +3640,20 @@ impl<'a, C, A> AutoscalerGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/bigquery2-cli/Cargo.toml b/gen/bigquery2-cli/Cargo.toml index 57df38edc9..81e0ab5750 100644 --- a/gen/bigquery2-cli/Cargo.toml +++ b/gen/bigquery2-cli/Cargo.toml @@ -5,10 +5,10 @@ name = "google-bigquery2-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel "] +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" -homepage = "https://developers.google.com/bigquery/docs/overview" +homepage = "https://cloud.google.com/bigquery/" documentation = "http://byron.github.io/google-apis-rs/google_bigquery2_cli" license = "MIT" keywords = ["bigquery", "google", "cli"] @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/bigquery2-cli/src/cmn.rs b/gen/bigquery2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/bigquery2-cli/src/cmn.rs +++ b/gen/bigquery2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/bigquery2-cli/src/main.rs b/gen/bigquery2-cli/src/main.rs index c1c65a89a4..1c2eae0564 100644 --- a/gen/bigquery2-cli/src/main.rs +++ b/gen/bigquery2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -51,6 +52,12 @@ Configuration: 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. "); mod cmn; @@ -74,7 +81,7 @@ impl Engine { -> Option { let mut call = self.hub.datasets().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "delete-contents" => { call = call.delete_contents(arg_from_str(value.unwrap_or("false"), err, "delete-contents", "boolean")); @@ -108,7 +115,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -119,7 +125,7 @@ impl Engine { -> Option { let mut call = self.hub.datasets().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -151,8 +157,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -161,10 +166,10 @@ impl Engine { fn _datasets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Dataset = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -184,9 +189,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -205,11 +211,11 @@ impl Engine { }, "dataset-reference.project-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "dataset-reference.dataset-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_dataset_reference_init(&mut request); @@ -256,8 +262,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -268,7 +273,7 @@ impl Engine { -> Option { let mut call = self.hub.datasets().list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -309,8 +314,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -319,10 +323,10 @@ impl Engine { fn _datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Dataset = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -342,9 +346,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -363,11 +368,11 @@ impl Engine { }, "dataset-reference.project-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "dataset-reference.dataset-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_dataset_reference_init(&mut request); @@ -414,8 +419,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -424,10 +428,10 @@ impl Engine { fn _datasets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Dataset = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -447,9 +451,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -468,11 +473,11 @@ impl Engine { }, "dataset-reference.project-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "dataset-reference.dataset-id" => { request_dataset_reference_init(&mut request); - request.dataset_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.dataset_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_dataset_reference_init(&mut request); @@ -519,8 +524,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -531,7 +535,7 @@ impl Engine { -> Option { let mut call = self.hub.jobs().get(&self.opt.arg_project_id, &self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -563,8 +567,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -575,7 +578,7 @@ impl Engine { -> Option { let mut call = self.hub.jobs().get_query_results(&self.opt.arg_project_id, &self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "timeout-ms" => { call = call.timeout_ms(arg_from_str(value.unwrap_or("-0"), err, "timeout-ms", "integer")); @@ -619,8 +622,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -629,10 +631,10 @@ impl Engine { fn _jobs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Job = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -652,30 +654,143 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().destination_table = Some(Default::default()); + } + } + + fn request_configuration_copy_init(request: &mut api::Job) { + request_configuration_init(request); + if request.configuration.as_mut().unwrap().copy.is_none() { + request.configuration.as_mut().unwrap().copy = Some(Default::default()); + } + } + + fn request_configuration_copy_source_table_init(request: &mut api::Job) { + request_configuration_copy_init(request); + if request.configuration.as_mut().unwrap().copy.as_mut().unwrap().source_table.is_none() { + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().source_table = Some(Default::default()); + } + } + + fn request_configuration_extract_init(request: &mut api::Job) { + request_configuration_init(request); + if request.configuration.as_mut().unwrap().extract.is_none() { + request.configuration.as_mut().unwrap().extract = Some(Default::default()); + } + } + + fn request_configuration_extract_source_table_init(request: &mut api::Job) { + request_configuration_extract_init(request); + if request.configuration.as_mut().unwrap().extract.as_mut().unwrap().source_table.is_none() { + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().source_table = Some(Default::default()); + } + } + fn request_configuration_init(request: &mut api::Job) { if request.configuration.is_none() { request.configuration = Some(Default::default()); } } + fn request_configuration_link_destination_table_init(request: &mut api::Job) { + request_configuration_link_init(request); + if request.configuration.as_mut().unwrap().link.as_mut().unwrap().destination_table.is_none() { + request.configuration.as_mut().unwrap().link.as_mut().unwrap().destination_table = Some(Default::default()); + } + } + + fn request_configuration_link_init(request: &mut api::Job) { + request_configuration_init(request); + if request.configuration.as_mut().unwrap().link.is_none() { + request.configuration.as_mut().unwrap().link = Some(Default::default()); + } + } + + fn request_configuration_load_destination_table_init(request: &mut api::Job) { + request_configuration_load_init(request); + if request.configuration.as_mut().unwrap().load.as_mut().unwrap().destination_table.is_none() { + request.configuration.as_mut().unwrap().load.as_mut().unwrap().destination_table = Some(Default::default()); + } + } + + fn request_configuration_load_init(request: &mut api::Job) { + request_configuration_init(request); + if request.configuration.as_mut().unwrap().load.is_none() { + request.configuration.as_mut().unwrap().load = Some(Default::default()); + } + } + + fn request_configuration_query_default_dataset_init(request: &mut api::Job) { + request_configuration_query_init(request); + if request.configuration.as_mut().unwrap().query.as_mut().unwrap().default_dataset.is_none() { + request.configuration.as_mut().unwrap().query.as_mut().unwrap().default_dataset = Some(Default::default()); + } + } + + fn request_configuration_query_destination_table_init(request: &mut api::Job) { + request_configuration_query_init(request); + if request.configuration.as_mut().unwrap().query.as_mut().unwrap().destination_table.is_none() { + request.configuration.as_mut().unwrap().query.as_mut().unwrap().destination_table = Some(Default::default()); + } + } + + fn request_configuration_query_init(request: &mut api::Job) { + request_configuration_init(request); + if request.configuration.as_mut().unwrap().query.is_none() { + request.configuration.as_mut().unwrap().query = Some(Default::default()); + } + } + fn request_job_reference_init(request: &mut api::Job) { if request.job_reference.is_none() { request.job_reference = Some(Default::default()); } } + fn request_statistics_extract_init(request: &mut api::Job) { + request_statistics_init(request); + if request.statistics.as_mut().unwrap().extract.is_none() { + request.statistics.as_mut().unwrap().extract = Some(Default::default()); + } + } + fn request_statistics_init(request: &mut api::Job) { if request.statistics.is_none() { request.statistics = Some(Default::default()); } } + fn request_statistics_load_init(request: &mut api::Job) { + request_statistics_init(request); + if request.statistics.as_mut().unwrap().load.is_none() { + request.statistics.as_mut().unwrap().load = Some(Default::default()); + } + } + + fn request_statistics_query_init(request: &mut api::Job) { + request_statistics_init(request); + if request.statistics.as_mut().unwrap().query.is_none() { + request.statistics.as_mut().unwrap().query = Some(Default::default()); + } + } + + fn request_status_error_result_init(request: &mut api::Job) { + request_status_init(request); + if request.status.as_mut().unwrap().error_result.is_none() { + request.status.as_mut().unwrap().error_result = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::Job) { if request.status.is_none() { request.status = Some(Default::default()); @@ -685,79 +800,82 @@ impl Engine { match &field_name.to_string()[..] { "status.state" => { request_status_init(&mut request); - request.status.as_mut().unwrap().state = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().state = Some(value.unwrap_or("").to_string()); }, "status.error-result.debug-info" => { - request_status_init(&mut request); - request.status.as_mut().unwrap().error_result.debug_info = value.unwrap_or("").to_string(); + request_status_error_result_init(&mut request); + request.status.as_mut().unwrap().error_result.as_mut().unwrap().debug_info = Some(value.unwrap_or("").to_string()); }, "status.error-result.message" => { - request_status_init(&mut request); - request.status.as_mut().unwrap().error_result.message = value.unwrap_or("").to_string(); + request_status_error_result_init(&mut request); + request.status.as_mut().unwrap().error_result.as_mut().unwrap().message = Some(value.unwrap_or("").to_string()); }, "status.error-result.reason" => { - request_status_init(&mut request); - request.status.as_mut().unwrap().error_result.reason = value.unwrap_or("").to_string(); + request_status_error_result_init(&mut request); + request.status.as_mut().unwrap().error_result.as_mut().unwrap().reason = Some(value.unwrap_or("").to_string()); }, "status.error-result.location" => { - request_status_init(&mut request); - request.status.as_mut().unwrap().error_result.location = value.unwrap_or("").to_string(); + request_status_error_result_init(&mut request); + request.status.as_mut().unwrap().error_result.as_mut().unwrap().location = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); request.kind = Some(value.unwrap_or("").to_string()); }, "statistics.load.output-rows" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().load.output_rows = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().load.as_mut().unwrap().output_rows = Some(value.unwrap_or("").to_string()); }, "statistics.load.input-files" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().load.input_files = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().load.as_mut().unwrap().input_files = Some(value.unwrap_or("").to_string()); }, "statistics.load.input-file-bytes" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().load.input_file_bytes = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().load.as_mut().unwrap().input_file_bytes = Some(value.unwrap_or("").to_string()); }, "statistics.load.output-bytes" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().load.output_bytes = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().load.as_mut().unwrap().output_bytes = Some(value.unwrap_or("").to_string()); }, "statistics.creation-time" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().creation_time = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().creation_time = Some(value.unwrap_or("").to_string()); }, "statistics.total-bytes-processed" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().total_bytes_processed = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().total_bytes_processed = Some(value.unwrap_or("").to_string()); }, "statistics.start-time" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().start_time = value.unwrap_or("").to_string(); + request_statistics_load_init(&mut request); + request.statistics.as_mut().unwrap().start_time = Some(value.unwrap_or("").to_string()); }, "statistics.query.cache-hit" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().query.cache_hit = arg_from_str(value.unwrap_or("false"), err, "statistics.query.cache-hit", "boolean"); + request_statistics_query_init(&mut request); + request.statistics.as_mut().unwrap().query.as_mut().unwrap().cache_hit = Some(arg_from_str(value.unwrap_or("false"), err, "statistics.query.cache-hit", "boolean")); }, "statistics.query.total-bytes-processed" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().query.total_bytes_processed = value.unwrap_or("").to_string(); + request_statistics_query_init(&mut request); + request.statistics.as_mut().unwrap().query.as_mut().unwrap().total_bytes_processed = Some(value.unwrap_or("").to_string()); }, "statistics.end-time" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().end_time = value.unwrap_or("").to_string(); + request_statistics_query_init(&mut request); + request.statistics.as_mut().unwrap().end_time = Some(value.unwrap_or("").to_string()); }, "statistics.extract.destination-uri-file-counts" => { - request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().extract.destination_uri_file_counts.push(arg_from_str(value.unwrap_or("-0"), err, "statistics.extract.destination-uri-file-counts", "int64")); + request_statistics_extract_init(&mut request); + if request.statistics.as_mut().unwrap().extract.as_mut().unwrap().destination_uri_file_counts.is_none() { + request.statistics.as_mut().unwrap().extract.as_mut().unwrap().destination_uri_file_counts = Some(Default::default()); + } + request.statistics.as_mut().unwrap().extract.as_mut().unwrap().destination_uri_file_counts.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "statistics.extract.destination-uri-file-counts", "int64")); }, "job-reference.project-id" => { request_job_reference_init(&mut request); - request.job_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.job_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "job-reference.job-id" => { request_job_reference_init(&mut request); - request.job_reference.as_mut().unwrap().job_id = value.unwrap_or("").to_string(); + request.job_reference.as_mut().unwrap().job_id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_job_reference_init(&mut request); @@ -768,224 +886,236 @@ impl Engine { request.user_email = Some(value.unwrap_or("").to_string()); }, "configuration.load.encoding" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.encoding = value.unwrap_or("").to_string(); + request_configuration_load_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().encoding = Some(value.unwrap_or("").to_string()); }, "configuration.load.skip-leading-rows" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.skip_leading_rows = arg_from_str(value.unwrap_or("-0"), err, "configuration.load.skip-leading-rows", "integer"); + request_configuration_load_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().skip_leading_rows = Some(arg_from_str(value.unwrap_or("-0"), err, "configuration.load.skip-leading-rows", "integer")); }, "configuration.load.quote" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.quote = value.unwrap_or("").to_string(); + request_configuration_load_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().quote = Some(value.unwrap_or("").to_string()); }, "configuration.load.source-format" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.source_format = value.unwrap_or("").to_string(); + request_configuration_load_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().source_format = Some(value.unwrap_or("").to_string()); }, "configuration.load.destination-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.destination_table.project_id = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().destination_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.load.destination-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.destination_table.table_id = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().destination_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.load.destination-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.destination_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().destination_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.load.max-bad-records" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.max_bad_records = arg_from_str(value.unwrap_or("-0"), err, "configuration.load.max-bad-records", "integer"); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().max_bad_records = Some(arg_from_str(value.unwrap_or("-0"), err, "configuration.load.max-bad-records", "integer")); }, "configuration.load.allow-jagged-rows" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.allow_jagged_rows = arg_from_str(value.unwrap_or("false"), err, "configuration.load.allow-jagged-rows", "boolean"); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().allow_jagged_rows = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.load.allow-jagged-rows", "boolean")); }, "configuration.load.write-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.write_disposition = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().write_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.load.source-uris" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.source_uris.push(value.unwrap_or("").to_string()); + request_configuration_load_destination_table_init(&mut request); + if request.configuration.as_mut().unwrap().load.as_mut().unwrap().source_uris.is_none() { + request.configuration.as_mut().unwrap().load.as_mut().unwrap().source_uris = Some(Default::default()); + } + request.configuration.as_mut().unwrap().load.as_mut().unwrap().source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "configuration.load.field-delimiter" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.field_delimiter = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().field_delimiter = Some(value.unwrap_or("").to_string()); }, "configuration.load.create-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.create_disposition = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().create_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.load.schema-inline-format" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.schema_inline_format = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().schema_inline_format = Some(value.unwrap_or("").to_string()); }, "configuration.load.schema-inline" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.schema_inline = value.unwrap_or("").to_string(); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().schema_inline = Some(value.unwrap_or("").to_string()); }, "configuration.load.allow-quoted-newlines" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.allow_quoted_newlines = arg_from_str(value.unwrap_or("false"), err, "configuration.load.allow-quoted-newlines", "boolean"); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().allow_quoted_newlines = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.load.allow-quoted-newlines", "boolean")); }, "configuration.load.projection-fields" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.projection_fields.push(value.unwrap_or("").to_string()); + request_configuration_load_destination_table_init(&mut request); + if request.configuration.as_mut().unwrap().load.as_mut().unwrap().projection_fields.is_none() { + request.configuration.as_mut().unwrap().load.as_mut().unwrap().projection_fields = Some(Default::default()); + } + request.configuration.as_mut().unwrap().load.as_mut().unwrap().projection_fields.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "configuration.load.ignore-unknown-values" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().load.ignore_unknown_values = arg_from_str(value.unwrap_or("false"), err, "configuration.load.ignore-unknown-values", "boolean"); + request_configuration_load_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().load.as_mut().unwrap().ignore_unknown_values = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.load.ignore-unknown-values", "boolean")); }, "configuration.dry-run" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().dry_run = arg_from_str(value.unwrap_or("false"), err, "configuration.dry-run", "boolean"); + request_configuration_load_init(&mut request); + request.configuration.as_mut().unwrap().dry_run = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.dry-run", "boolean")); }, "configuration.link.create-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.create_disposition = value.unwrap_or("").to_string(); + request_configuration_link_init(&mut request); + request.configuration.as_mut().unwrap().link.as_mut().unwrap().create_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.link.write-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.write_disposition = value.unwrap_or("").to_string(); + request_configuration_link_init(&mut request); + request.configuration.as_mut().unwrap().link.as_mut().unwrap().write_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.link.destination-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.destination_table.project_id = value.unwrap_or("").to_string(); + request_configuration_link_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().link.as_mut().unwrap().destination_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.link.destination-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.destination_table.table_id = value.unwrap_or("").to_string(); + request_configuration_link_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().link.as_mut().unwrap().destination_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.link.destination-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.destination_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_link_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().link.as_mut().unwrap().destination_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.link.source-uri" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().link.source_uri.push(value.unwrap_or("").to_string()); + request_configuration_link_destination_table_init(&mut request); + if request.configuration.as_mut().unwrap().link.as_mut().unwrap().source_uri.is_none() { + request.configuration.as_mut().unwrap().link.as_mut().unwrap().source_uri = Some(Default::default()); + } + request.configuration.as_mut().unwrap().link.as_mut().unwrap().source_uri.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "configuration.query.flatten-results" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.flatten_results = arg_from_str(value.unwrap_or("false"), err, "configuration.query.flatten-results", "boolean"); + request_configuration_query_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().flatten_results = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.query.flatten-results", "boolean")); }, "configuration.query.use-query-cache" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.use_query_cache = arg_from_str(value.unwrap_or("false"), err, "configuration.query.use-query-cache", "boolean"); + request_configuration_query_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().use_query_cache = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.query.use-query-cache", "boolean")); }, "configuration.query.default-dataset.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.default_dataset.project_id = value.unwrap_or("").to_string(); + request_configuration_query_default_dataset_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().default_dataset.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.query.default-dataset.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.default_dataset.dataset_id = value.unwrap_or("").to_string(); + request_configuration_query_default_dataset_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().default_dataset.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.query.destination-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.destination_table.project_id = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().destination_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.query.destination-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.destination_table.table_id = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().destination_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.query.destination-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.destination_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().destination_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.query.priority" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.priority = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().priority = Some(value.unwrap_or("").to_string()); }, "configuration.query.write-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.write_disposition = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().write_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.query.allow-large-results" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.allow_large_results = arg_from_str(value.unwrap_or("false"), err, "configuration.query.allow-large-results", "boolean"); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().allow_large_results = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.query.allow-large-results", "boolean")); }, "configuration.query.create-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.create_disposition = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().create_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.query.query" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.query = value.unwrap_or("").to_string(); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, "configuration.query.preserve-nulls" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().query.preserve_nulls = arg_from_str(value.unwrap_or("false"), err, "configuration.query.preserve-nulls", "boolean"); + request_configuration_query_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().query.as_mut().unwrap().preserve_nulls = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.query.preserve-nulls", "boolean")); }, "configuration.copy.create-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.create_disposition = value.unwrap_or("").to_string(); + request_configuration_copy_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().create_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.copy.write-disposition" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.write_disposition = value.unwrap_or("").to_string(); + request_configuration_copy_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().write_disposition = Some(value.unwrap_or("").to_string()); }, "configuration.copy.destination-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.destination_table.project_id = value.unwrap_or("").to_string(); + request_configuration_copy_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().destination_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.copy.destination-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.destination_table.table_id = value.unwrap_or("").to_string(); + request_configuration_copy_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().destination_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.copy.destination-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.destination_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_copy_destination_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().destination_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.copy.source-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.source_table.project_id = value.unwrap_or("").to_string(); + request_configuration_copy_source_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().source_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.copy.source-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.source_table.table_id = value.unwrap_or("").to_string(); + request_configuration_copy_source_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().source_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.copy.source-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().copy.source_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_copy_source_table_init(&mut request); + request.configuration.as_mut().unwrap().copy.as_mut().unwrap().source_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "configuration.extract.destination-uri" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.destination_uri = value.unwrap_or("").to_string(); + request_configuration_extract_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().destination_uri = Some(value.unwrap_or("").to_string()); }, "configuration.extract.compression" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.compression = value.unwrap_or("").to_string(); + request_configuration_extract_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().compression = Some(value.unwrap_or("").to_string()); }, "configuration.extract.field-delimiter" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.field_delimiter = value.unwrap_or("").to_string(); + request_configuration_extract_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().field_delimiter = Some(value.unwrap_or("").to_string()); }, "configuration.extract.destination-format" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.destination_format = value.unwrap_or("").to_string(); + request_configuration_extract_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().destination_format = Some(value.unwrap_or("").to_string()); }, "configuration.extract.print-header" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.print_header = arg_from_str(value.unwrap_or("false"), err, "configuration.extract.print-header", "boolean"); + request_configuration_extract_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().print_header = Some(arg_from_str(value.unwrap_or("false"), err, "configuration.extract.print-header", "boolean")); }, "configuration.extract.destination-uris" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.destination_uris.push(value.unwrap_or("").to_string()); + request_configuration_extract_init(&mut request); + if request.configuration.as_mut().unwrap().extract.as_mut().unwrap().destination_uris.is_none() { + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().destination_uris = Some(Default::default()); + } + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().destination_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "configuration.extract.source-table.project-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.source_table.project_id = value.unwrap_or("").to_string(); + request_configuration_extract_source_table_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().source_table.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "configuration.extract.source-table.table-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.source_table.table_id = value.unwrap_or("").to_string(); + request_configuration_extract_source_table_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().source_table.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "configuration.extract.source-table.dataset-id" => { - request_configuration_init(&mut request); - request.configuration.as_mut().unwrap().extract.source_table.dataset_id = value.unwrap_or("").to_string(); + request_configuration_extract_source_table_init(&mut request); + request.configuration.as_mut().unwrap().extract.as_mut().unwrap().source_table.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "id" => { request_configuration_init(&mut request); @@ -1022,8 +1152,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1034,7 +1163,7 @@ impl Engine { -> Option { let mut call = self.hub.jobs().list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "state-filter" => { call = call.add_state_filter(value.unwrap_or("")); @@ -1081,8 +1210,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1091,10 +1219,10 @@ impl Engine { fn _jobs_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::QueryRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1114,9 +1242,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1141,11 +1270,11 @@ impl Engine { }, "default-dataset.project-id" => { request_default_dataset_init(&mut request); - request.default_dataset.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.default_dataset.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "default-dataset.dataset-id" => { request_default_dataset_init(&mut request); - request.default_dataset.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.default_dataset.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "max-results" => { request_default_dataset_init(&mut request); @@ -1176,8 +1305,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1188,7 +1316,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1226,8 +1354,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1236,10 +1363,10 @@ impl Engine { fn _tabledata_insert_all(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TableDataInsertAllRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1259,9 +1386,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1292,8 +1420,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1304,7 +1431,7 @@ impl Engine { -> Option { let mut call = self.hub.tabledata().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(value.unwrap_or("")); @@ -1345,8 +1472,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1357,7 +1483,7 @@ impl Engine { -> Option { let mut call = self.hub.tables().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1388,7 +1514,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1399,7 +1524,7 @@ impl Engine { -> Option { let mut call = self.hub.tables().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1431,8 +1556,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1441,10 +1565,10 @@ impl Engine { fn _tables_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1464,9 +1588,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1497,15 +1622,15 @@ impl Engine { }, "table-reference.project-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "table-reference.table-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().table_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "table-reference.dataset-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "num-rows" => { request_table_reference_init(&mut request); @@ -1541,7 +1666,7 @@ impl Engine { }, "view.query" => { request_view_init(&mut request); - request.view.as_mut().unwrap().query = value.unwrap_or("").to_string(); + request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1560,8 +1685,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1572,7 +1696,7 @@ impl Engine { -> Option { let mut call = self.hub.tables().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1610,8 +1734,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1620,10 +1743,10 @@ impl Engine { fn _tables_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1643,9 +1766,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1676,15 +1800,15 @@ impl Engine { }, "table-reference.project-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "table-reference.table-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().table_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "table-reference.dataset-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "num-rows" => { request_table_reference_init(&mut request); @@ -1720,7 +1844,7 @@ impl Engine { }, "view.query" => { request_view_init(&mut request); - request.view.as_mut().unwrap().query = value.unwrap_or("").to_string(); + request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1739,8 +1863,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1749,10 +1872,10 @@ impl Engine { fn _tables_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1772,9 +1895,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1805,15 +1929,15 @@ impl Engine { }, "table-reference.project-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().project_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().project_id = Some(value.unwrap_or("").to_string()); }, "table-reference.table-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().table_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().table_id = Some(value.unwrap_or("").to_string()); }, "table-reference.dataset-id" => { request_table_reference_init(&mut request); - request.table_reference.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.table_reference.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "num-rows" => { request_table_reference_init(&mut request); @@ -1849,7 +1973,7 @@ impl Engine { }, "view.query" => { request_view_init(&mut request); - request.view.as_mut().unwrap().query = value.unwrap_or("").to_string(); + request.view.as_mut().unwrap().query = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1868,8 +1992,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1897,7 +2020,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_jobs { + } + else if self.opt.cmd_jobs { if self.opt.cmd_get { call_result = self._jobs_get(dry_run, &mut err); } else if self.opt.cmd_get_query_results { @@ -1911,13 +2035,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_projects { + } + else if self.opt.cmd_projects { if self.opt.cmd_list { call_result = self._projects_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_tabledata { + } + else if self.opt.cmd_tabledata { if self.opt.cmd_insert_all { call_result = self._tabledata_insert_all(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1925,7 +2051,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_tables { + } + else if self.opt.cmd_tables { if self.opt.cmd_delete { call_result = self._tables_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -1961,21 +2088,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "bigquery2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "bigquery2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "bigquery2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "bigquery2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Bigquery::new(hyper::Client::new(), auth), + hub: api::Bigquery::new(client, auth), }; match engine._doit(true) { @@ -1995,12 +2138,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/bigquery2/Cargo.toml b/gen/bigquery2/Cargo.toml index 0683d6eb94..5cb8d8c3c1 100644 --- a/gen/bigquery2/Cargo.toml +++ b/gen/bigquery2/Cargo.toml @@ -5,10 +5,10 @@ name = "google-bigquery2" version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +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" -homepage = "https://developers.google.com/bigquery/docs/overview" +homepage = "https://cloud.google.com/bigquery/" documentation = "http://byron.github.io/google-apis-rs/google_bigquery2" license = "MIT" keywords = ["bigquery", "google", "protocol", "web", "api"] diff --git a/gen/bigquery2/README.md b/gen/bigquery2/README.md index f2f0e28626..1be8736c57 100644 --- a/gen/bigquery2/README.md +++ b/gen/bigquery2/README.md @@ -8,7 +8,7 @@ The `google-bigquery2` library allows access to all features of the *Google bigq 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*. Everything else about the *bigquery* *v2* API can be found at the -[official documentation site](https://developers.google.com/bigquery/docs/overview). +[official documentation site](https://cloud.google.com/bigquery/). # Features Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_bigquery2/struct.Bigquery.html) ... @@ -110,7 +110,7 @@ let mut hub = Bigquery::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Table = Default::default(); +let mut req = Table::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/bigquery2/src/cmn.rs b/gen/bigquery2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/bigquery2/src/cmn.rs +++ b/gen/bigquery2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/bigquery2/src/lib.rs b/gen/bigquery2/src/lib.rs index 536a06ed57..70234dea8e 100644 --- a/gen/bigquery2/src/lib.rs +++ b/gen/bigquery2/src/lib.rs @@ -5,7 +5,7 @@ //! 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*. //! //! Everything else about the *bigquery* *v2* API can be found at the -//! [official documentation site](https://developers.google.com/bigquery/docs/overview). +//! [official documentation site](https://cloud.google.com/bigquery/). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/bigquery2). //! # Features //! @@ -111,7 +111,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Table = Default::default(); +//! let mut req = Table::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -306,7 +306,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -389,9 +389,9 @@ impl<'a, C, A> Bigquery pub struct TableDataInsertAllRequestRows { /// [Optional] A unique ID for each row. BigQuery uses this property to detect duplicate insertion requests on a best-effort basis. #[serde(rename="insertId")] - pub insert_id: String, + pub insert_id: Option, /// [Required] A JSON object that contains a row of data. The object's properties and values must match the destination table's schema. - pub json: JsonObject, + pub json: Option, } impl NestedType for TableDataInsertAllRequestRows {} @@ -406,7 +406,7 @@ impl Part for TableDataInsertAllRequestRows {} pub struct JobStatistics4 { /// [Experimental] Number of files per destination URI or URI pattern specified in the extract configuration. These values will be in the same order as the URIs specified in the 'destinationUris' field. #[serde(rename="destinationUriFileCounts")] - pub destination_uri_file_counts: Vec, + pub destination_uri_file_counts: Option>, } impl Part for JobStatistics4 {} @@ -458,10 +458,10 @@ impl RequestValue for QueryRequest {} pub struct JobStatistics2 { /// [Output-only] Whether the query result was fetched from the query cache. #[serde(rename="cacheHit")] - pub cache_hit: bool, + pub cache_hit: Option, /// [Output-only] Total bytes processed for this job. #[serde(rename="totalBytesProcessed")] - pub total_bytes_processed: String, + pub total_bytes_processed: Option, } impl Part for JobStatistics2 {} @@ -475,16 +475,16 @@ impl Part for JobStatistics2 {} pub struct JobStatistics3 { /// [Output-only] Number of rows imported in a load job. Note that while an import job is in the running state, this value may change. #[serde(rename="outputRows")] - pub output_rows: String, + pub output_rows: Option, /// [Output-only] Number of source files in a load job. #[serde(rename="inputFiles")] - pub input_files: String, + pub input_files: Option, /// [Output-only] Number of bytes of source data in a joad job. #[serde(rename="inputFileBytes")] - pub input_file_bytes: String, + pub input_file_bytes: Option, /// [Output-only] Size of the loaded data in bytes. Note that while an import job is in the running state, this value may change. #[serde(rename="outputBytes")] - pub output_bytes: String, + pub output_bytes: Option, } impl Part for JobStatistics3 {} @@ -495,7 +495,7 @@ impl Part for JobStatistics3 {} /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize)] -pub struct JsonObject(HashMap); +pub struct JsonObject(Option>); impl Part for JsonObject {} @@ -513,16 +513,16 @@ impl Part for JsonObject {} pub struct ProjectList { /// A token to request the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The total number of projects in the list. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// The type of list. - pub kind: String, + pub kind: Option, /// A hash of the page of results - pub etag: String, + pub etag: Option, /// Projects to which you have at least READ access. - pub projects: Vec, + pub projects: Option>, } impl ResponseResult for ProjectList {} @@ -535,16 +535,16 @@ impl ResponseResult for ProjectList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableFieldSchema { /// [Optional] Describes the nested schema fields if the type property is set to RECORD. - pub fields: Vec, + pub fields: Option>, /// [Optional] The field description. The maximum length is 16K characters. - pub description: String, + pub description: Option, /// [Required] The field data type. Possible values include STRING, INTEGER, FLOAT, BOOLEAN, TIMESTAMP or RECORD (where RECORD indicates that the field contains a nested schema). #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// [Optional] The field mode. Possible values include NULLABLE, REQUIRED and REPEATED. The default value is NULLABLE. - pub mode: String, + pub mode: Option, /// [Required] The field name. The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter or underscore. The maximum length is 128 characters. - pub name: String, + pub name: Option, } impl Part for TableFieldSchema {} @@ -608,9 +608,9 @@ impl ResponseResult for Dataset {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableDataInsertAllResponseInsertErrors { /// The index of the row that error applies to. - pub index: u32, + pub index: Option, /// Error information for the row indicated by the index property. - pub errors: Vec, + pub errors: Option>, } impl NestedType for TableDataInsertAllResponseInsertErrors {} @@ -624,7 +624,7 @@ impl Part for TableDataInsertAllResponseInsertErrors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableCell { /// no description provided - pub v: String, + pub v: Option, } impl Part for TableCell {} @@ -638,10 +638,10 @@ impl Part for TableCell {} pub struct JobReference { /// [Required] The ID of the project containing this job. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option, /// [Required] The ID of the job. The ID must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024 characters. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option, } impl Part for JobReference {} @@ -655,14 +655,14 @@ impl Part for JobReference {} pub struct DatasetListDatasets { /// A descriptive name for the dataset, if one exists. #[serde(rename="friendlyName")] - pub friendly_name: String, + pub friendly_name: Option, /// The resource type. This property always returns the value "bigquery#dataset". - pub kind: String, + pub kind: Option, /// The fully-qualified, unique, opaque ID of the dataset. - pub id: String, + pub id: Option, /// The dataset reference. Use this property to access specific parts of the dataset's ID, such as project ID or dataset ID. #[serde(rename="datasetReference")] - pub dataset_reference: DatasetReference, + pub dataset_reference: Option, } impl NestedType for DatasetListDatasets {} @@ -677,17 +677,17 @@ impl Part for DatasetListDatasets {} pub struct TableListTables { /// The user-friendly name for this table. #[serde(rename="friendlyName")] - pub friendly_name: String, + pub friendly_name: Option, /// The resource type. - pub kind: String, + pub kind: Option, /// The type of table. Possible values are: TABLE, VIEW. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// An opaque ID of the table - pub id: String, + pub id: Option, /// A reference uniquely identifying the table. #[serde(rename="tableReference")] - pub table_reference: TableReference, + pub table_reference: Option, } impl NestedType for TableListTables {} @@ -707,16 +707,16 @@ impl Part for TableListTables {} pub struct TableList { /// A token to request the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Tables in the requested dataset. - pub tables: Vec, + pub tables: Option>, /// The type of list. - pub kind: String, + pub kind: Option, /// A hash of this page of results. - pub etag: String, + pub etag: Option, /// The total number of tables in the dataset. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, } impl ResponseResult for TableList {} @@ -730,7 +730,7 @@ impl ResponseResult for TableList {} pub struct ProjectReference { /// [Required] ID of the project. Can be either the numeric ID or the assigned ID of the project. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option, } impl Part for ProjectReference {} @@ -749,16 +749,16 @@ impl Part for ProjectReference {} pub struct TableDataList { /// A token used for paging results. Providing this token instead of the startIndex parameter can help you retrieve stable results when an underlying table is changing. #[serde(rename="pageToken")] - pub page_token: String, + pub page_token: Option, /// The resource type of the response. - pub kind: String, + pub kind: Option, /// A hash of this page of results. - pub etag: String, + pub etag: Option, /// Rows of results. - pub rows: Vec, + pub rows: Option>, /// The total number of rows in the complete table. #[serde(rename="totalRows")] - pub total_rows: String, + pub total_rows: Option, } impl ResponseResult for TableDataList {} @@ -813,25 +813,25 @@ impl ResponseResult for Job {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobListJobs { /// [Full-projection-only] Describes the state of the job. - pub status: JobStatus, + pub status: Option, /// The resource type. - pub kind: String, + pub kind: Option, /// [Output-only] Information about the job, including starting time and ending time of the job. - pub statistics: JobStatistics, + pub statistics: Option, /// Job reference uniquely identifying the job. #[serde(rename="jobReference")] - pub job_reference: JobReference, + pub job_reference: Option, /// Running state of the job. When the state is DONE, errorResult can be checked to determine whether the job succeeded or failed. - pub state: String, + pub state: Option, /// A result object that will be present only if the job has failed. #[serde(rename="errorResult")] - pub error_result: ErrorProto, + pub error_result: Option, /// [Full-projection-only] Specifies the job configuration. - pub configuration: JobConfiguration, + pub configuration: Option, /// Unique opaque ID of the job. - pub id: String, + pub id: Option, /// [Full-projection-only] Email address of the user who ran the job. - pub user_email: String, + pub user_email: Option, } impl NestedType for JobListJobs {} @@ -845,53 +845,53 @@ impl Part for JobListJobs {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobConfigurationLoad { /// [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split using the values of the quote and fieldDelimiter properties. - pub encoding: String, + pub encoding: Option, /// [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. - pub quote: String, + pub quote: Option, /// [Required] The destination table to load the data into. #[serde(rename="destinationTable")] - pub destination_table: TableReference, + pub destination_table: Option, /// [Required] The fully-qualified URIs that point to your data in Google Cloud Storage. Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. #[serde(rename="sourceUris")] - pub source_uris: Vec, + pub source_uris: Option>, /// Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. #[serde(rename="allowQuotedNewlines")] - pub allow_quoted_newlines: bool, - /// [Experimental] Names(case-sensitive) of properties to keep when importing data. If this is populated, only the specified properties will be imported for each entity. Currently, this is only supported for DATASTORE_BACKUP imports and only top level properties are supported. If any specified property is not found in the Datastore 'Kind' being imported, that is an error. Note: This feature is experimental and can change in the future. + pub allow_quoted_newlines: Option, + /// [Experimental] If sourceFormat is set to "DATASTORE_BACKUP", indicates which entity properties to load into BigQuery from a Cloud Datastore backup. Property names are case sensitive and must be top-level properties. If no properties are specified, BigQuery loads all properties. If any named property isn't found in the Cloud Datastore backup, an invalid error is returned in the job result. #[serde(rename="projectionFields")] - pub projection_fields: Vec, + pub projection_fields: Option>, /// [Optional] Accept rows that are missing trailing optional columns. The missing values are treated as nulls. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. Only applicable to CSV, ignored for other formats. #[serde(rename="allowJaggedRows")] - pub allow_jagged_rows: bool, + pub allow_jagged_rows: Option, /// [Optional] The separator for fields in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). #[serde(rename="fieldDelimiter")] - pub field_delimiter: String, + pub field_delimiter: Option, /// [Optional] The format of the data files. For CSV files, specify "CSV". For datastore backups, specify "DATASTORE_BACKUP". For newline-delimited JSON, specify "NEWLINE_DELIMITED_JSON". The default value is CSV. #[serde(rename="sourceFormat")] - pub source_format: String, + pub source_format: Option, /// [Optional] The maximum number of bad records that BigQuery can ignore when running the job. If the number of bad records exceeds this value, an invalid error is returned in the job result. The default value is 0, which requires that all records are valid. #[serde(rename="maxBadRecords")] - pub max_bad_records: i32, + pub max_bad_records: Option, /// [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns JSON: Named values that don't match any column names #[serde(rename="ignoreUnknownValues")] - pub ignore_unknown_values: bool, + pub ignore_unknown_values: Option, /// [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="writeDisposition")] - pub write_disposition: String, + pub write_disposition: Option, /// [Optional] The number of rows at the top of a CSV file that BigQuery will skip when loading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. #[serde(rename="skipLeadingRows")] - pub skip_leading_rows: i32, + pub skip_leading_rows: Option, /// [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="createDisposition")] - pub create_disposition: String, + pub create_disposition: Option, /// [Deprecated] The format of the schemaInline property. #[serde(rename="schemaInlineFormat")] - pub schema_inline_format: String, + pub schema_inline_format: Option, /// [Deprecated] The inline schema. For CSV schemas, specify as "Field1:Type1[,Field2:Type2]*". For example, "foo:STRING, bar:INTEGER, baz:FLOAT". #[serde(rename="schemaInline")] - pub schema_inline: String, + pub schema_inline: Option, /// [Optional] The schema for the destination table. The schema can be omitted if the destination table already exists or if the schema can be inferred from the loaded data. - pub schema: TableSchema, + pub schema: Option, } impl Part for JobConfigurationLoad {} @@ -910,16 +910,16 @@ impl Part for JobConfigurationLoad {} pub struct JobList { /// A token to request the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Total number of jobs in this collection. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// The resource type of the response. - pub kind: String, + pub kind: Option, /// A hash of this page of results. - pub etag: String, + pub etag: Option, /// List of jobs that were requested. - pub jobs: Vec, + pub jobs: Option>, } impl ResponseResult for JobList {} @@ -933,24 +933,24 @@ impl ResponseResult for JobList {} pub struct JobConfigurationExtract { /// [Pick one] DEPRECATED: Use destinationUris instead, passing only one URI as necessary. The fully-qualified Google Cloud Storage URI where the extracted table should be written. #[serde(rename="destinationUri")] - pub destination_uri: String, + pub destination_uri: Option, /// [Optional] The exported file format. Possible values include CSV, NEWLINE_DELIMITED_JSON and AVRO. The default value is CSV. Tables with nested or repeated fields cannot be exported as CSV. #[serde(rename="destinationFormat")] - pub destination_format: String, + pub destination_format: Option, /// [Optional] The compression type to use for exported files. Possible values include GZIP and NONE. The default value is NONE. - pub compression: String, + pub compression: Option, /// [Pick one] A list of fully-qualified Google Cloud Storage URIs where the extracted table should be written. #[serde(rename="destinationUris")] - pub destination_uris: Vec, + pub destination_uris: Option>, /// [Optional] Whether to print out a header row in the results. Default is true. #[serde(rename="printHeader")] - pub print_header: bool, + pub print_header: Option, /// [Optional] Delimiter to use between fields in the exported data. Default is ',' #[serde(rename="fieldDelimiter")] - pub field_delimiter: String, + pub field_delimiter: Option, /// [Required] A reference to the table being exported. #[serde(rename="sourceTable")] - pub source_table: TableReference, + pub source_table: Option, } impl Part for JobConfigurationExtract {} @@ -968,31 +968,31 @@ impl Part for JobConfigurationExtract {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GetQueryResultsResponse { /// The resource type of the response. - pub kind: String, + pub kind: Option, /// An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. Present only when the query completes successfully. - pub rows: Vec, + pub rows: Option>, /// Reference to the BigQuery Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). #[serde(rename="jobReference")] - pub job_reference: JobReference, + pub job_reference: Option, /// Whether the query result was fetched from the query cache. #[serde(rename="cacheHit")] - pub cache_hit: bool, + pub cache_hit: Option, /// Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. #[serde(rename="jobComplete")] - pub job_complete: bool, + pub job_complete: Option, /// The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. Present only when the query completes successfully. #[serde(rename="totalRows")] - pub total_rows: String, + pub total_rows: Option, /// The total number of bytes processed for this query. #[serde(rename="totalBytesProcessed")] - pub total_bytes_processed: String, + pub total_bytes_processed: Option, /// A token used for paging results. #[serde(rename="pageToken")] - pub page_token: String, + pub page_token: Option, /// A hash of this response. - pub etag: String, + pub etag: Option, /// The schema of the results. Present only when the query completes successfully. - pub schema: TableSchema, + pub schema: Option, } impl ResponseResult for GetQueryResultsResponse {} @@ -1006,20 +1006,20 @@ impl ResponseResult for GetQueryResultsResponse {} pub struct CsvOptions { /// [Optional] Indicates if BigQuery should accept rows that are missing trailing optional columns. If true, BigQuery treats missing trailing columns as null values. If false, records with missing trailing columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. #[serde(rename="allowJaggedRows")] - pub allow_jagged_rows: bool, + pub allow_jagged_rows: Option, /// [Optional] The number of rows at the top of a CSV file that BigQuery will skip when reading the data. The default value is 0. This property is useful if you have header rows in the file that should be skipped. #[serde(rename="skipLeadingRows")] - pub skip_leading_rows: i32, + pub skip_leading_rows: Option, /// [Optional] The separator for fields in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. BigQuery also supports the escape sequence "\t" to specify a tab separator. The default value is a comma (','). #[serde(rename="fieldDelimiter")] - pub field_delimiter: String, + pub field_delimiter: Option, /// [Optional] The character encoding of the data. The supported values are UTF-8 or ISO-8859-1. The default value is UTF-8. BigQuery decodes the data after the raw, binary data has been split using the values of the quote and fieldDelimiter properties. - pub encoding: String, + pub encoding: Option, /// [Optional] The value that is used to quote data sections in a CSV file. BigQuery converts the string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split the data in its raw, binary state. The default value is a double-quote ('"'). If your data does not contain quoted sections, set the property value to an empty string. If your data contains quoted newline characters, you must also set the allowQuotedNewlines property to true. - pub quote: String, + pub quote: Option, /// [Optional] Indicates if BigQuery should allow quoted data sections that contain newline characters in a CSV file. The default value is false. #[serde(rename="allowQuotedNewlines")] - pub allow_quoted_newlines: bool, + pub allow_quoted_newlines: Option, } impl Part for CsvOptions {} @@ -1033,23 +1033,23 @@ impl Part for CsvOptions {} pub struct ExternalDataConfiguration { /// [Optional] Indicates if BigQuery should allow extra values that are not represented in the table schema. If true, the extra values are ignored. If false, records with extra columns are treated as bad records, and if there are too many bad records, an invalid error is returned in the job result. The default value is false. The sourceFormat property determines what BigQuery treats as an extra value: CSV: Trailing columns #[serde(rename="ignoreUnknownValues")] - pub ignore_unknown_values: bool, + pub ignore_unknown_values: Option, /// [Required] The fully-qualified URIs that point to your data in Google Cloud Storage. Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. CSV limits related to load jobs apply to external data sources, plus an additional limit of 10 GB maximum size across all URIs. #[serde(rename="sourceUris")] - pub source_uris: Vec, + pub source_uris: Option>, /// [Optional] The compression type of the data source. Possible values include GZIP and NONE. The default value is NONE. - pub compression: String, + pub compression: Option, /// Additional properties to set if sourceFormat is set to CSV. #[serde(rename="csvOptions")] - pub csv_options: CsvOptions, + pub csv_options: Option, /// [Optional] The data format. External data sources must be in CSV format. The default value is CSV. #[serde(rename="sourceFormat")] - pub source_format: String, + pub source_format: Option, /// [Optional] The maximum number of bad records that BigQuery can ignore when reading data. If the number of bad records exceeds this value, an invalid error is returned in the job result. The default value is 0, which requires that all records are valid. #[serde(rename="maxBadRecords")] - pub max_bad_records: i32, + pub max_bad_records: Option, /// [Required] The schema for the data. - pub schema: TableSchema, + pub schema: Option, } impl Part for ExternalDataConfiguration {} @@ -1063,13 +1063,13 @@ impl Part for ExternalDataConfiguration {} pub struct ErrorProto { /// Debugging information. This property is internal to Google and should not be used. #[serde(rename="debugInfo")] - pub debug_info: String, + pub debug_info: Option, /// A human-readable description of the error. - pub message: String, + pub message: Option, /// A short error code that summarizes the error. - pub reason: String, + pub reason: Option, /// Specifies where the error occurred, if present. - pub location: String, + pub location: Option, } impl Part for ErrorProto {} @@ -1083,16 +1083,16 @@ impl Part for ErrorProto {} pub struct JobConfigurationLink { /// [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="createDisposition")] - pub create_disposition: String, + pub create_disposition: Option, /// [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="writeDisposition")] - pub write_disposition: String, + pub write_disposition: Option, /// [Required] The destination table of the link job. #[serde(rename="destinationTable")] - pub destination_table: TableReference, + pub destination_table: Option, /// [Required] URI of source table to link. #[serde(rename="sourceUri")] - pub source_uri: Vec, + pub source_uri: Option>, } impl Part for JobConfigurationLink {} @@ -1105,7 +1105,7 @@ impl Part for JobConfigurationLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ViewDefinition { /// [Required] A query that BigQuery executes when the view is referenced. - pub query: String, + pub query: Option, } impl Part for ViewDefinition {} @@ -1118,20 +1118,20 @@ impl Part for ViewDefinition {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatasetAccess { /// [Pick one] A domain to grant access to. Any users signed in with the domain specified will be granted the specified access. Example: "example.com". - pub domain: String, + pub domain: Option, /// [Required] Describes the rights granted to the user specified by the other member of the access object. The following string values are supported: READER, WRITER, OWNER. - pub role: String, + pub role: Option, /// [Pick one] An email address of a user to grant access to. For example: fred@example.com. #[serde(rename="userByEmail")] - pub user_by_email: String, + pub user_by_email: Option, /// [Pick one] A special group to grant access to. Possible values include: projectOwners: Owners of the enclosing project. projectReaders: Readers of the enclosing project. projectWriters: Writers of the enclosing project. allAuthenticatedUsers: All authenticated BigQuery users. #[serde(rename="specialGroup")] - pub special_group: String, + pub special_group: Option, /// [Pick one] An email address of a Google Group to grant access to. #[serde(rename="groupByEmail")] - pub group_by_email: String, + pub group_by_email: Option, /// [Pick one] A view from a different dataset to grant access to. Queries executed against that view will have read access to tables in this dataset. The role field is not required when this field is set. If that view is updated by any user, access to the view needs to be granted again via an update operation. - pub view: TableReference, + pub view: Option, } impl NestedType for DatasetAccess {} @@ -1145,12 +1145,12 @@ impl Part for DatasetAccess {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobStatus { /// [Output-only] Running state of the job. - pub state: String, + pub state: Option, /// [Output-only] All errors encountered during the running of the job. Errors here do not necessarily mean that the job has completed or was unsuccessful. - pub errors: Vec, + pub errors: Option>, /// [Output-only] Final error result of the job. If present, indicates that the job has completed and was unsuccessful. #[serde(rename="errorResult")] - pub error_result: ErrorProto, + pub error_result: Option, } impl Part for JobStatus {} @@ -1163,7 +1163,7 @@ impl Part for JobStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableSchema { /// Describes the fields in a table. - pub fields: Vec, + pub fields: Option>, } impl Part for TableSchema {} @@ -1226,13 +1226,13 @@ impl RequestValue for TableDataInsertAllRequest {} pub struct DatasetList { /// A token that can be used to request the next results page. This property is omitted on the final results page. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The list type. This property always returns the value "bigquery#datasetList". - pub kind: String, + pub kind: Option, /// An array of the dataset resources in the project. Each resource contains basic information. For full information about a particular dataset resource, use the Datasets: get method. This property is omitted when there are no datasets in the project. - pub datasets: Vec, + pub datasets: Option>, /// A hash value of the results page. You can use this property to determine if the page has changed since the last request. - pub etag: String, + pub etag: Option, } impl ResponseResult for DatasetList {} @@ -1245,23 +1245,23 @@ impl ResponseResult for DatasetList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobStatistics { /// [Output-only] Statistics for a load job. - pub load: JobStatistics3, + pub load: Option, /// [Output-only] Statistics for an extract job. - pub extract: JobStatistics4, + pub extract: Option, /// [Output-only] Start time of this job, in milliseconds since the epoch. This field will be present when the job transitions from the PENDING state to either RUNNING or DONE. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option, /// [Output-only] Statistics for a query job. - pub query: JobStatistics2, + pub query: Option, /// [Output-only] End time of this job, in milliseconds since the epoch. This field will be present whenever a job is in the DONE state. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// [Output-only] Creation time of this job, in milliseconds since the epoch. This field will be present on all jobs. #[serde(rename="creationTime")] - pub creation_time: String, + pub creation_time: Option, /// [Output-only] [Deprecated] Use the bytes processed in the query statistics instead. #[serde(rename="totalBytesProcessed")] - pub total_bytes_processed: String, + pub total_bytes_processed: Option, } impl Part for JobStatistics {} @@ -1273,37 +1273,37 @@ impl Part for JobStatistics {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobConfigurationQuery { - /// [Experimental] Flattens all nested and repeated fields in the query results. The default value is true. allowLargeResults must be true if this is set to false. + /// [Optional] Flattens all nested and repeated fields in the query results. The default value is true. allowLargeResults must be true if this is set to false. #[serde(rename="flattenResults")] - pub flatten_results: bool, + pub flatten_results: Option, /// [Optional] Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. Moreover, the query cache is only available when a query does not have a destination table specified. #[serde(rename="useQueryCache")] - pub use_query_cache: bool, + pub use_query_cache: Option, /// [Optional] Specifies the default dataset to use for unqualified table names in the query. #[serde(rename="defaultDataset")] - pub default_dataset: DatasetReference, + pub default_dataset: Option, /// [Optional] Describes the table where the query results should be stored. If not present, a new table will be created to store the results. #[serde(rename="destinationTable")] - pub destination_table: TableReference, + pub destination_table: Option, /// [Optional] Specifies a priority for the query. Possible values include INTERACTIVE and BATCH. The default value is INTERACTIVE. - pub priority: String, + pub priority: Option, /// [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="writeDisposition")] - pub write_disposition: String, + pub write_disposition: Option, /// If true, allows the query to produce arbitrarily large result tables at a slight cost in performance. Requires destinationTable to be set. #[serde(rename="allowLargeResults")] - pub allow_large_results: bool, + pub allow_large_results: Option, /// [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="createDisposition")] - pub create_disposition: String, + pub create_disposition: Option, /// [Required] BigQuery SQL query to execute. - pub query: String, + pub query: Option, /// [Deprecated] This property is deprecated. #[serde(rename="preserveNulls")] - pub preserve_nulls: bool, + pub preserve_nulls: Option, /// [Experimental] If querying an external data source outside of BigQuery, describes the data format, location and other properties of the data source. By defining these properties, the data source can then be queried as if it were a standard BigQuery table. #[serde(rename="tableDefinitions")] - pub table_definitions: HashMap, + pub table_definitions: Option>, } impl Part for JobConfigurationQuery {} @@ -1317,10 +1317,10 @@ impl Part for JobConfigurationQuery {} pub struct DatasetReference { /// [Optional] The ID of the project containing this dataset. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option, /// [Required] A unique ID for this dataset, without the project name. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. #[serde(rename="datasetId")] - pub dataset_id: String, + pub dataset_id: Option, } impl Part for DatasetReference {} @@ -1333,7 +1333,7 @@ impl Part for DatasetReference {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableRow { /// no description provided - pub f: Vec, + pub f: Option>, } impl Part for TableRow {} @@ -1346,18 +1346,18 @@ impl Part for TableRow {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobConfiguration { /// [Pick one] Configures a load job. - pub load: JobConfigurationLoad, + pub load: Option, /// [Optional] If set, don't actually run this job. A valid query will return a mostly empty response with some processing statistics, while an invalid query will return the same error it would if it wasn't a dry run. Behavior of non-query jobs is undefined. #[serde(rename="dryRun")] - pub dry_run: bool, + pub dry_run: Option, /// [Pick one] Configures a query job. - pub query: JobConfigurationQuery, + pub query: Option, /// [Pick one] Configures a link job. - pub link: JobConfigurationLink, + pub link: Option, /// [Pick one] Copies a table. - pub copy: JobConfigurationTableCopy, + pub copy: Option, /// [Pick one] Configures an extract job. - pub extract: JobConfigurationExtract, + pub extract: Option, } impl Part for JobConfiguration {} @@ -1371,17 +1371,17 @@ impl Part for JobConfiguration {} pub struct ProjectListProjects { /// A descriptive name for this project. #[serde(rename="friendlyName")] - pub friendly_name: String, + pub friendly_name: Option, /// The resource type. - pub kind: String, + pub kind: Option, /// The numeric ID of this project. #[serde(rename="numericId")] - pub numeric_id: String, + pub numeric_id: Option, /// An opaque ID of this project. - pub id: String, + pub id: Option, /// A unique reference to this project. #[serde(rename="projectReference")] - pub project_reference: ProjectReference, + pub project_reference: Option, } impl NestedType for ProjectListProjects {} @@ -1396,13 +1396,13 @@ impl Part for ProjectListProjects {} pub struct TableReference { /// [Required] The ID of the project containing this table. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option, /// [Required] The ID of the table. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters. #[serde(rename="tableId")] - pub table_id: String, + pub table_id: Option, /// [Required] The ID of the dataset containing this table. #[serde(rename="datasetId")] - pub dataset_id: String, + pub dataset_id: Option, } impl Part for TableReference {} @@ -1482,10 +1482,10 @@ impl ResponseResult for Table {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TableDataInsertAllResponse { /// The resource type of the response. - pub kind: String, + pub kind: Option, /// An array of errors for rows that were not inserted. #[serde(rename="insertErrors")] - pub insert_errors: Vec, + pub insert_errors: Option>, } impl ResponseResult for TableDataInsertAllResponse {} @@ -1503,29 +1503,29 @@ impl ResponseResult for TableDataInsertAllResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct QueryResponse { /// The resource type. - pub kind: String, + pub kind: Option, /// An object with as many results as can be contained within the maximum permitted reply size. To get any additional rows, you can call GetQueryResults and specify the jobReference returned above. - pub rows: Vec, + pub rows: Option>, /// Reference to the Job that was created to run the query. This field will be present even if the original request timed out, in which case GetQueryResults can be used to read the results once the query has completed. Since this API only returns the first page of results, subsequent pages can be fetched via the same mechanism (GetQueryResults). #[serde(rename="jobReference")] - pub job_reference: JobReference, + pub job_reference: Option, /// Whether the query result was fetched from the query cache. #[serde(rename="cacheHit")] - pub cache_hit: bool, + pub cache_hit: Option, /// Whether the query has completed or not. If rows or totalRows are present, this will always be true. If this is false, totalRows will not be available. #[serde(rename="jobComplete")] - pub job_complete: bool, + pub job_complete: Option, /// The total number of rows in the complete query result set, which can be more than the number of rows in this single page of results. #[serde(rename="totalRows")] - pub total_rows: String, + pub total_rows: Option, /// The total number of bytes processed for this query. If this query was a dry run, this is the number of bytes that would be processed if the query were run. #[serde(rename="totalBytesProcessed")] - pub total_bytes_processed: String, + pub total_bytes_processed: Option, /// A token used for paging results. #[serde(rename="pageToken")] - pub page_token: String, + pub page_token: Option, /// The schema of the results. Present only when the query completes successfully. - pub schema: TableSchema, + pub schema: Option, } impl ResponseResult for QueryResponse {} @@ -1539,19 +1539,19 @@ impl ResponseResult for QueryResponse {} pub struct JobConfigurationTableCopy { /// [Optional] Specifies whether the job is allowed to create new tables. The following values are supported: CREATE_IF_NEEDED: If the table does not exist, BigQuery creates the table. CREATE_NEVER: The table must already exist. If it does not, a 'notFound' error is returned in the job result. The default value is CREATE_IF_NEEDED. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="createDisposition")] - pub create_disposition: String, + pub create_disposition: Option, /// [Pick one] Source tables to copy. #[serde(rename="sourceTables")] - pub source_tables: Vec, + pub source_tables: Option>, /// [Optional] Specifies the action that occurs if the destination table already exists. The following values are supported: WRITE_TRUNCATE: If the table already exists, BigQuery overwrites the table data. WRITE_APPEND: If the table already exists, BigQuery appends the data to the table. WRITE_EMPTY: If the table already exists and contains data, a 'duplicate' error is returned in the job result. The default value is WRITE_EMPTY. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Creation, truncation and append actions occur as one atomic update upon job completion. #[serde(rename="writeDisposition")] - pub write_disposition: String, + pub write_disposition: Option, /// [Required] The destination table #[serde(rename="destinationTable")] - pub destination_table: TableReference, + pub destination_table: Option, /// [Pick one] Source table to copy. #[serde(rename="sourceTable")] - pub source_table: TableReference, + pub source_table: Option, } impl Part for JobConfigurationTableCopy {} @@ -1646,7 +1646,7 @@ impl<'a, C, A> TableMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all tables in the specified dataset. + /// Lists all tables in the specified dataset. Requires the READER dataset role. /// /// # Arguments /// @@ -1813,7 +1813,7 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all the datasets in the specified project to which the caller has read access; however, a project owner can list (but not necessarily get) all datasets in his project. + /// Lists all datasets in the specified project to which you have been granted the READER dataset role. /// /// # Arguments /// @@ -1976,7 +1976,7 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists all the Jobs in the specified project that were started by the user. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created. + /// Lists all jobs that you started in the specified project. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created. Requires the Can View project role, or the Is Owner project role if you set the allUsers property. /// /// # Arguments /// @@ -1998,7 +1998,7 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the specified job by ID. + /// Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. /// /// # Arguments /// @@ -2017,7 +2017,7 @@ impl<'a, C, A> JobMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Starts a new asynchronous job. + /// Starts a new asynchronous job. Requires the Can View project role. /// /// # Arguments /// @@ -2077,7 +2077,7 @@ impl<'a, C, A> TabledataMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Streams data into BigQuery one record at a time without needing to run a load job. + /// Streams data into BigQuery one record at a time without needing to run a load job. Requires the WRITER dataset role. /// /// # Arguments /// @@ -2100,7 +2100,7 @@ impl<'a, C, A> TabledataMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves table data from a specified set of rows. + /// Retrieves table data from a specified set of rows. Requires the READER dataset role. /// /// # Arguments /// @@ -2165,7 +2165,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Lists the projects to which you have at least read access. + /// Lists all projects to which you have been granted any project role. pub fn list(&self) -> ProjectListCall<'a, C, A> { ProjectListCall { hub: self.hub, @@ -2213,7 +2213,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2309,16 +2309,20 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2491,7 +2495,7 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2585,16 +2589,20 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2730,7 +2738,7 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut, A: o } -/// Lists all tables in the specified dataset. +/// Lists all tables in the specified dataset. Requires the READER dataset role. /// /// A builder for the *list* method supported by a *table* resource. /// It is not used directly, but through a `TableMethods` instance. @@ -2850,16 +2858,20 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3107,16 +3119,20 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3351,16 +3367,20 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3520,7 +3540,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3616,16 +3636,20 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3798,7 +3822,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3892,16 +3916,20 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4147,16 +4175,20 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4279,7 +4311,7 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut, A: oa } -/// Lists all the datasets in the specified project to which the caller has read access; however, a project owner can list (but not necessarily get) all datasets in his project. +/// Lists all datasets in the specified project to which you have been granted the READER dataset role. /// /// A builder for the *list* method supported by a *dataset* resource. /// It is not used directly, but through a `DatasetMethods` instance. @@ -4402,16 +4434,20 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4572,7 +4608,7 @@ impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4666,16 +4702,20 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4925,16 +4965,20 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5081,7 +5125,7 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5173,16 +5217,20 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5335,7 +5383,7 @@ impl<'a, C, A> DatasetInsertCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: QueryRequest = Default::default(); +/// let mut req = QueryRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5427,16 +5475,20 @@ impl<'a, C, A> JobQueryCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5692,16 +5744,20 @@ impl<'a, C, A> JobGetQueryResultCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5852,7 +5908,7 @@ impl<'a, C, A> JobGetQueryResultCall<'a, C, A> where C: BorrowMut } -/// Lists all the Jobs in the specified project that were started by the user. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created. +/// Lists all jobs that you started in the specified project. The job list returns in reverse chronological order of when the jobs were created, starting with the most recent job created. Requires the Can View project role, or the Is Owner project role if you set the allUsers property. /// /// A builder for the *list* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. @@ -5989,16 +6045,20 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6147,7 +6207,7 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut, A: oauth } -/// Retrieves the specified job by ID. +/// Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. /// /// A builder for the *get* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. @@ -6257,16 +6317,20 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6389,7 +6453,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 } -/// Starts a new asynchronous job. +/// Starts a new asynchronous job. Requires the Can View project role. /// /// A builder for the *insert* method supported by a *job* resource. /// It is not used directly, but through a `JobMethods` instance. @@ -6417,7 +6481,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut, A: oauth2 /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Job = Default::default(); +/// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -6520,16 +6584,20 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau let mut upload_url: Option = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -6754,7 +6822,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau } -/// Streams data into BigQuery one record at a time without needing to run a load job. +/// Streams data into BigQuery one record at a time without needing to run a load job. Requires the WRITER dataset role. /// /// A builder for the *insertAll* method supported by a *tabledata* resource. /// It is not used directly, but through a `TabledataMethods` instance. @@ -6781,7 +6849,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TableDataInsertAllRequest = Default::default(); +/// let mut req = TableDataInsertAllRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6877,16 +6945,20 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7032,7 +7104,7 @@ impl<'a, C, A> TabledataInsertAllCall<'a, C, A> where C: BorrowMut TabledataListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7322,7 +7398,7 @@ impl<'a, C, A> TabledataListCall<'a, C, A> where C: BorrowMut, A: } -/// Lists the projects to which you have at least read access. +/// Lists all projects to which you have been granted any project role. /// /// A builder for the *list* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. @@ -7414,16 +7490,20 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/blogger3-cli/Cargo.toml b/gen/blogger3-cli/Cargo.toml index acf4ea5257..8b7435e5c6 100644 --- a/gen/blogger3-cli/Cargo.toml +++ b/gen/blogger3-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-blogger3-cli" -version = "0.0.1+20150208" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/blogger/docs/3.0/getting_started" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/blogger3-cli/mkdocs.yml b/gen/blogger3-cli/mkdocs.yml index 2166dc0af3..bc359d567f 100644 --- a/gen/blogger3-cli/mkdocs.yml +++ b/gen/blogger3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: blogger v0.0.1+20150208 +site_name: blogger v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/blogger3-cli/src/cmn.rs +++ b/gen/blogger3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/blogger3-cli/src/main.rs b/gen/blogger3-cli/src/main.rs index 621cc9b6d2..201aa876a5 100644 --- a/gen/blogger3-cli/src/main.rs +++ b/gen/blogger3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -64,6 +65,12 @@ Configuration: 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. "); mod cmn; @@ -87,7 +94,7 @@ impl Engine { -> Option { let mut call = self.hub.blog_user_infos().get(&self.opt.arg_user_id, &self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "max-posts" => { call = call.max_posts(arg_from_str(value.unwrap_or("-0"), err, "max-posts", "integer")); @@ -122,8 +129,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -134,7 +140,7 @@ impl Engine { -> Option { let mut call = self.hub.blogs().get(&self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -172,8 +178,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -184,7 +189,7 @@ impl Engine { -> Option { let mut call = self.hub.blogs().get_by_url(&self.opt.arg_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -219,8 +224,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -231,7 +235,7 @@ impl Engine { -> Option { let mut call = self.hub.blogs().list_by_user(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -275,8 +279,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -287,7 +290,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().approve(&self.opt.arg_blog_id, &self.opt.arg_post_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -319,8 +322,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -331,7 +333,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().delete(&self.opt.arg_blog_id, &self.opt.arg_post_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -362,7 +364,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -373,7 +374,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().get(&self.opt.arg_blog_id, &self.opt.arg_post_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -408,8 +409,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -420,7 +420,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -473,8 +473,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -485,7 +484,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().list_by_blog(&self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "status" => { call = call.add_status(value.unwrap_or("")); @@ -535,8 +534,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -547,7 +545,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().mark_as_spam(&self.opt.arg_blog_id, &self.opt.arg_post_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -579,8 +577,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -591,7 +588,7 @@ impl Engine { -> Option { let mut call = self.hub.comments().remove_content(&self.opt.arg_blog_id, &self.opt.arg_post_id, &self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -623,8 +620,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -635,7 +631,7 @@ impl Engine { -> Option { let mut call = self.hub.page_views().get(&self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "range" => { call = call.add_range(value.unwrap_or("")); @@ -670,8 +666,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -682,7 +677,7 @@ impl Engine { -> Option { let mut call = self.hub.pages().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -713,7 +708,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -724,7 +718,7 @@ impl Engine { -> Option { let mut call = self.hub.pages().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -759,8 +753,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -769,10 +762,10 @@ impl Engine { fn _pages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Page = Default::default(); + 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); + 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")); @@ -795,12 +788,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Page) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Page) { if request.author.is_none() { request.author = Some(Default::default()); @@ -825,19 +826,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -853,7 +854,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -888,8 +889,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -900,7 +900,7 @@ impl Engine { -> Option { let mut call = self.hub.pages().list(&self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -947,8 +947,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -957,10 +956,10 @@ impl Engine { fn _pages_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Page = Default::default(); + 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); + 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")); @@ -986,12 +985,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Page) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Page) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1016,19 +1023,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -1044,7 +1051,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -1079,8 +1086,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1091,7 +1097,7 @@ impl Engine { -> Option { let mut call = self.hub.pages().publish(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1123,8 +1129,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1135,7 +1140,7 @@ impl Engine { -> Option { let mut call = self.hub.pages().revert(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1167,8 +1172,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1177,10 +1181,10 @@ impl Engine { fn _pages_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Page = Default::default(); + 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); + 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")); @@ -1206,12 +1210,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Page) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Page) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1236,19 +1248,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -1264,7 +1276,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -1299,8 +1311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1311,7 +1322,7 @@ impl Engine { -> Option { let mut call = self.hub.post_user_infos().get(&self.opt.arg_user_id, &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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "max-comments" => { call = call.max_comments(arg_from_str(value.unwrap_or("-0"), err, "max-comments", "integer")); @@ -1346,8 +1357,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1358,7 +1368,7 @@ impl Engine { -> Option { let mut call = self.hub.post_user_infos().list(&self.opt.arg_user_id, &self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -1417,8 +1427,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1429,7 +1438,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1460,7 +1469,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1471,7 +1479,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -1515,8 +1523,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1527,7 +1534,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().get_by_path(&self.opt.arg_blog_id, &self.opt.arg_path); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -1565,8 +1572,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1575,10 +1581,10 @@ impl Engine { fn _posts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Post = Default::default(); + 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); + 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")); @@ -1607,12 +1613,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Post) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Post) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1652,19 +1666,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -1677,9 +1691,9 @@ impl Engine { "labels" => { request_author_init(&mut request); if request.labels.is_none() { - request.labels = Some(Default::default()); + request.labels = Some(Default::default()); } - request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "custom-meta-data" => { request_author_init(&mut request); @@ -1691,7 +1705,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -1699,27 +1713,27 @@ impl Engine { }, "location.lat" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lat = arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number"); + request.location.as_mut().unwrap().lat = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number")); }, "location.lng" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lng = arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number"); + request.location.as_mut().unwrap().lng = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number")); }, "location.span" => { request_location_init(&mut request); - request.location.as_mut().unwrap().span = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().span = Some(value.unwrap_or("").to_string()); }, "location.name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "replies.total-items" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().total_items = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().total_items = Some(value.unwrap_or("").to_string()); }, "replies.self-link" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "title" => { request_replies_init(&mut request); @@ -1754,8 +1768,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1766,7 +1779,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().list(&self.opt.arg_blog_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "view" => { call = call.view(value.unwrap_or("")); @@ -1828,8 +1841,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1838,10 +1850,10 @@ impl Engine { fn _posts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Post = Default::default(); + 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); + 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")); @@ -1876,12 +1888,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Post) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Post) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1921,19 +1941,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -1946,9 +1966,9 @@ impl Engine { "labels" => { request_author_init(&mut request); if request.labels.is_none() { - request.labels = Some(Default::default()); + request.labels = Some(Default::default()); } - request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "custom-meta-data" => { request_author_init(&mut request); @@ -1960,7 +1980,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -1968,27 +1988,27 @@ impl Engine { }, "location.lat" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lat = arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number"); + request.location.as_mut().unwrap().lat = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number")); }, "location.lng" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lng = arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number"); + request.location.as_mut().unwrap().lng = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number")); }, "location.span" => { request_location_init(&mut request); - request.location.as_mut().unwrap().span = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().span = Some(value.unwrap_or("").to_string()); }, "location.name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "replies.total-items" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().total_items = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().total_items = Some(value.unwrap_or("").to_string()); }, "replies.self-link" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "title" => { request_replies_init(&mut request); @@ -2023,8 +2043,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2035,7 +2054,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().publish(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "publish-date" => { call = call.publish_date(value.unwrap_or("")); @@ -2070,8 +2089,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2082,7 +2100,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().revert(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2114,8 +2132,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2126,7 +2143,7 @@ impl Engine { -> Option { let mut call = self.hub.posts().search(&self.opt.arg_blog_id, &self.opt.arg_q); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "order-by" => { call = call.order_by(value.unwrap_or("")); @@ -2164,8 +2181,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2174,10 +2190,10 @@ impl Engine { fn _posts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Post = Default::default(); + 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); + 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")); @@ -2212,12 +2228,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Post) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Post) { if request.author.is_none() { request.author = Some(Default::default()); @@ -2257,19 +2281,19 @@ impl Engine { }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -2282,9 +2306,9 @@ impl Engine { "labels" => { request_author_init(&mut request); if request.labels.is_none() { - request.labels = Some(Default::default()); + request.labels = Some(Default::default()); } - request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "custom-meta-data" => { request_author_init(&mut request); @@ -2296,7 +2320,7 @@ impl Engine { }, "blog.id" => { request_blog_init(&mut request); - request.blog.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.blog.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "etag" => { request_blog_init(&mut request); @@ -2304,27 +2328,27 @@ impl Engine { }, "location.lat" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lat = arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number"); + request.location.as_mut().unwrap().lat = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lat", "number")); }, "location.lng" => { request_location_init(&mut request); - request.location.as_mut().unwrap().lng = arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number"); + request.location.as_mut().unwrap().lng = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.lng", "number")); }, "location.span" => { request_location_init(&mut request); - request.location.as_mut().unwrap().span = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().span = Some(value.unwrap_or("").to_string()); }, "location.name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "replies.total-items" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().total_items = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().total_items = Some(value.unwrap_or("").to_string()); }, "replies.self-link" => { request_replies_init(&mut request); - request.replies.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.replies.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "title" => { request_replies_init(&mut request); @@ -2359,8 +2383,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2371,7 +2394,7 @@ impl Engine { -> Option { let mut call = self.hub.users().get(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2403,8 +2426,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2422,7 +2444,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_blogs { + } + else if self.opt.cmd_blogs { if self.opt.cmd_get { call_result = self._blogs_get(dry_run, &mut err); } else if self.opt.cmd_get_by_url { @@ -2432,7 +2455,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_comments { + } + else if self.opt.cmd_comments { if self.opt.cmd_approve { call_result = self._comments_approve(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -2450,13 +2474,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_page_views { + } + else if self.opt.cmd_page_views { if self.opt.cmd_get { call_result = self._page_views_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_pages { + } + else if self.opt.cmd_pages { if self.opt.cmd_delete { call_result = self._pages_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2476,7 +2502,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_post_user_infos { + } + else if self.opt.cmd_post_user_infos { if self.opt.cmd_get { call_result = self._post_user_infos_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2484,7 +2511,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_posts { + } + else if self.opt.cmd_posts { if self.opt.cmd_delete { call_result = self._posts_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2508,7 +2536,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_users { + } + else if self.opt.cmd_users { if self.opt.cmd_get { call_result = self._users_get(dry_run, &mut err); } else { @@ -2534,21 +2563,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "blogger3-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "blogger3-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "blogger3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "blogger3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Blogger::new(hyper::Client::new(), auth), + hub: api::Blogger::new(client, auth), }; match engine._doit(true) { @@ -2568,12 +2613,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/blogger3/Cargo.toml b/gen/blogger3/Cargo.toml index 70cf42e24d..7399a22a8c 100644 --- a/gen/blogger3/Cargo.toml +++ b/gen/blogger3/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-blogger3" -version = "0.1.5+20150208" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/blogger/docs/3.0/getting_started" diff --git a/gen/blogger3/README.md b/gen/blogger3/README.md index 2ef4731e71..208f92275e 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+20150208*, where *20150208* 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.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*. 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). diff --git a/gen/blogger3/src/cmn.rs b/gen/blogger3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/blogger3/src/cmn.rs +++ b/gen/blogger3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/blogger3/src/lib.rs b/gen/blogger3/src/lib.rs index 681117251d..1160f79540 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+20150208*, where *20150208* 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.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*. //! //! 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). @@ -395,7 +395,7 @@ impl<'a, C, A> Blogger #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostBlog { /// The identifier of the Blog that contains this Post. - pub id: String, + pub id: Option, } impl NestedType for PostBlog {} @@ -410,20 +410,20 @@ impl Part for PostBlog {} pub struct BlogPerUserInfo { /// True if the user has Admin level access to the blog. #[serde(rename="hasAdminAccess")] - pub has_admin_access: bool, + pub has_admin_access: Option, /// The kind of this entity. Always blogger#blogPerUserInfo - pub kind: String, + pub kind: Option, /// Access permissions that the user has for the blog (ADMIN, AUTHOR, or READER). - pub role: String, + pub role: Option, /// The Photo Album Key for the user when adding photos to the blog #[serde(rename="photosAlbumKey")] - pub photos_album_key: String, + pub photos_album_key: Option, /// ID of the User #[serde(rename="userId")] - pub user_id: String, + pub user_id: Option, /// ID of the Blog resource #[serde(rename="blogId")] - pub blog_id: String, + pub blog_id: Option, } impl Part for BlogPerUserInfo {} @@ -436,19 +436,19 @@ impl Part for BlogPerUserInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostPerUserInfo { /// The kind of this entity. Always blogger#postPerUserInfo - pub kind: String, + pub kind: Option, /// ID of the Post resource. #[serde(rename="postId")] - pub post_id: String, + pub post_id: Option, /// ID of the User. #[serde(rename="userId")] - pub user_id: String, + pub user_id: Option, /// ID of the Blog that the post resource belongs to. #[serde(rename="blogId")] - pub blog_id: String, + pub blog_id: Option, /// True if the user has Author level access to the post. #[serde(rename="hasEditAccess")] - pub has_edit_access: bool, + pub has_edit_access: Option, } impl Part for PostPerUserInfo {} @@ -468,33 +468,33 @@ impl Part for PostPerUserInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Blog { /// The status of the blog. - pub status: String, + pub status: Option, /// The kind of this entry. Always blogger#blog - pub kind: String, + pub kind: Option, /// The description of this blog. This is displayed underneath the title. - pub description: String, + pub description: Option, /// The locale this Blog is set to. - pub locale: BlogLocale, + pub locale: Option, /// The JSON custom meta-data for the Blog #[serde(rename="customMetaData")] - pub custom_meta_data: String, + pub custom_meta_data: Option, /// The container of posts in this blog. - pub posts: BlogPosts, + pub posts: Option, /// RFC 3339 date-time when this blog was last updated. - pub updated: String, + pub updated: Option, /// The identifier for this resource. - pub id: String, + pub id: Option, /// The URL where this blog is published. - pub url: String, + pub url: Option, /// RFC 3339 date-time when this blog was published. - pub published: String, + pub published: Option, /// The container of pages in this blog. - pub pages: BlogPages, + pub pages: Option, /// The API REST URL to fetch this resource from. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// The name of this blog. This is displayed as the title. - pub name: String, + pub name: Option, } impl Resource for Blog {} @@ -514,11 +514,11 @@ impl ResponseResult for Blog {} pub struct PostUserInfosList { /// Pagination token to fetch the next page, if one exists. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The list of Posts with User information for the post, for this Blog. - pub items: Vec, + pub items: Option>, /// The kind of this entity. Always blogger#postList - pub kind: String, + pub kind: Option, } impl ResponseResult for PostUserInfosList {} @@ -536,11 +536,11 @@ impl ResponseResult for PostUserInfosList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BlogUserInfo { /// The Blog resource. - pub blog: Blog, + pub blog: Option, /// The kind of this entity. Always blogger#blogUserInfo - pub kind: String, + pub kind: Option, /// Information about a User for the Blog. - pub blog_user_info: BlogPerUserInfo, + pub blog_user_info: Option, } impl Resource for BlogUserInfo {} @@ -554,7 +554,7 @@ impl ResponseResult for BlogUserInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentInReplyTo { /// The identified of the parent of this comment. - pub id: String, + pub id: Option, } impl NestedType for CommentInReplyTo {} @@ -568,14 +568,14 @@ impl Part for CommentInReplyTo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentAuthor { /// The URL of the Comment creator's Profile page. - pub url: String, + pub url: Option, /// The comment creator's avatar. - pub image: CommentAuthorImage, + pub image: Option, /// The display name. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The identifier of the Comment creator. - pub id: String, + pub id: Option, } impl NestedType for CommentAuthor {} @@ -589,7 +589,7 @@ impl Part for CommentAuthor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PageAuthorImage { /// The page author's avatar URL. - pub url: String, + pub url: Option, } impl NestedType for PageAuthorImage {} @@ -603,7 +603,7 @@ impl Part for PageAuthorImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentPost { /// The identifier of the post containing this comment. - pub id: String, + pub id: Option, } impl NestedType for CommentPost {} @@ -618,7 +618,7 @@ impl Part for CommentPost {} pub struct UserBlogs { /// The URL of the Blogs for this user. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl NestedType for UserBlogs {} @@ -633,12 +633,12 @@ impl Part for UserBlogs {} pub struct PostReplies { /// The count of comments on this post. #[serde(rename="totalItems")] - pub total_items: String, + pub total_items: Option, /// The List of Comments for this Post. - pub items: Vec, + pub items: Option>, /// The URL of the comments on this post. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl NestedType for PostReplies {} @@ -652,10 +652,10 @@ impl Part for PostReplies {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PageviewsCounts { /// Count of page views for the given time range - pub count: String, + pub count: Option, /// Time range the given count applies to #[serde(rename="timeRange")] - pub time_range: String, + pub time_range: Option, } impl NestedType for PageviewsCounts {} @@ -674,12 +674,12 @@ impl Part for PageviewsCounts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BlogList { /// The list of Blogs this user has Authorship or Admin rights over. - pub items: Vec, + pub items: Option>, /// The kind of this entity. Always blogger#blogList - pub kind: String, + pub kind: Option, /// Admin level list of blog per-user information #[serde(rename="blogUserInfos")] - pub blog_user_infos: Vec, + pub blog_user_infos: Option>, } impl ResponseResult for BlogList {} @@ -697,25 +697,25 @@ impl ResponseResult for BlogList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct User { /// Profile summary information. - pub about: String, + pub about: Option, /// The display name. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The timestamp of when this profile was created, in seconds since epoch. - pub created: String, + pub created: Option, /// This user's locale - pub locale: UserLocale, + pub locale: Option, /// The container of blogs for this user. - pub blogs: UserBlogs, + pub blogs: Option, /// The kind of this entity. Always blogger#user - pub kind: String, + pub kind: Option, /// The user's profile page. - pub url: String, + pub url: Option, /// The identifier for this User. - pub id: String, + pub id: Option, /// The API REST URL to fetch this resource from. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl Resource for User {} @@ -729,7 +729,7 @@ impl ResponseResult for User {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostAuthorImage { /// The Post author's avatar URL. - pub url: String, + pub url: Option, } impl NestedType for PostAuthorImage {} @@ -812,13 +812,13 @@ impl ResponseResult for Post {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostLocation { /// Location's latitude. - pub lat: f64, + pub lat: Option, /// Location's longitude. - pub lng: f64, + pub lng: Option, /// Location's viewport span. Can be used when rendering a map preview. - pub span: String, + pub span: Option, /// Location name. - pub name: String, + pub name: Option, } impl NestedType for PostLocation {} @@ -832,14 +832,14 @@ impl Part for PostLocation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostAuthor { /// The URL of the Post creator's Profile page. - pub url: String, + pub url: Option, /// The Post author's avatar. - pub image: PostAuthorImage, + pub image: Option, /// The display name. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The identifier of the Post creator. - pub id: String, + pub id: Option, } impl NestedType for PostAuthor {} @@ -860,14 +860,16 @@ impl Part for PostAuthor {} pub struct CommentList { /// Pagination token to fetch the next page, if one exists. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The List of Comments for a Post. - pub items: Vec, + pub items: Option>, /// The kind of this entry. Always blogger#commentList - pub kind: String, + pub kind: Option, + /// Etag of the response. + pub etag: Option, /// Pagination token to fetch the previous page, if one exists. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option, } impl ResponseResult for CommentList {} @@ -880,7 +882,7 @@ impl ResponseResult for CommentList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostImages { /// no description provided - pub url: String, + pub url: Option, } impl NestedType for PostImages {} @@ -901,11 +903,13 @@ impl Part for PostImages {} pub struct PostList { /// Pagination token to fetch the next page, if one exists. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The list of Posts for this Blog. - pub items: Vec, + pub items: Option>, /// The kind of this entity. Always blogger#postList - pub kind: String, + pub kind: Option, + /// Etag of the response. + pub etag: Option, } impl ResponseResult for PostList {} @@ -918,7 +922,7 @@ impl ResponseResult for PostList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentAuthorImage { /// The comment creator's avatar URL. - pub url: String, + pub url: Option, } impl NestedType for CommentAuthorImage {} @@ -933,10 +937,10 @@ impl Part for CommentAuthorImage {} pub struct BlogPages { /// The count of pages in this blog. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// The URL of the container for pages in this blog. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl NestedType for BlogPages {} @@ -951,12 +955,12 @@ impl Part for BlogPages {} pub struct BlogPosts { /// The count of posts in this blog. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// The List of Posts for this Blog. - pub items: Vec, + pub items: Option>, /// The URL of the container for posts in this blog. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl NestedType for BlogPosts {} @@ -1031,29 +1035,29 @@ impl ResponseResult for Page {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Comment { /// The status of the comment (only populated for admin users) - pub status: String, + pub status: Option, /// Data about the comment this is in reply to. #[serde(rename="inReplyTo")] - pub in_reply_to: CommentInReplyTo, + pub in_reply_to: Option, /// The kind of this entry. Always blogger#comment - pub kind: String, + pub kind: Option, /// The author of this Comment. - pub author: CommentAuthor, + pub author: Option, /// RFC 3339 date-time when this comment was last updated. - pub updated: String, + pub updated: Option, /// Data about the blog containing this comment. - pub blog: CommentBlog, + pub blog: Option, /// RFC 3339 date-time when this comment was published. - pub published: String, + pub published: Option, /// Data about the post containing this comment. - pub post: CommentPost, + pub post: Option, /// The actual content of the comment. May include HTML markup. - pub content: String, + pub content: Option, /// The identifier for this resource. - pub id: String, + pub id: Option, /// The API REST URL to fetch this resource from. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl Resource for Comment {} @@ -1073,11 +1077,11 @@ impl ResponseResult for Comment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostUserInfo { /// The kind of this entity. Always blogger#postUserInfo - pub kind: String, + pub kind: Option, /// The Post resource. - pub post: Post, + pub post: Option, /// Information about a User for the Post. - pub post_user_info: PostPerUserInfo, + pub post_user_info: Option, } impl Resource for PostUserInfo {} @@ -1096,12 +1100,12 @@ impl ResponseResult for PostUserInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Pageviews { /// The container of posts in this blog. - pub counts: Vec, + pub counts: Option>, /// Blog Id #[serde(rename="blogId")] - pub blog_id: String, + pub blog_id: Option, /// The kind of this entry. Always blogger#page_views - pub kind: String, + pub kind: Option, } impl ResponseResult for Pageviews {} @@ -1114,14 +1118,14 @@ impl ResponseResult for Pageviews {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PageAuthor { /// The URL of the Page creator's Profile page. - pub url: String, + pub url: Option, /// The page author's avatar. - pub image: PageAuthorImage, + pub image: Option, /// The display name. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The identifier of the Page creator. - pub id: String, + pub id: Option, } impl NestedType for PageAuthor {} @@ -1141,11 +1145,13 @@ impl Part for PageAuthor {} pub struct PageList { /// Pagination token to fetch the next page, if one exists. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The list of Pages for a Blog. - pub items: Vec, + pub items: Option>, /// The kind of this entity. Always blogger#pageList - pub kind: String, + pub kind: Option, + /// Etag of the response. + pub etag: Option, } impl ResponseResult for PageList {} @@ -1158,11 +1164,11 @@ impl ResponseResult for PageList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserLocale { /// The user's country setting. - pub country: String, + pub country: Option, /// The user's language variant setting. - pub variant: String, + pub variant: Option, /// The user's language setting. - pub language: String, + pub language: Option, } impl NestedType for UserLocale {} @@ -1176,7 +1182,7 @@ impl Part for UserLocale {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentBlog { /// The identifier of the blog containing this comment. - pub id: String, + pub id: Option, } impl NestedType for CommentBlog {} @@ -1190,7 +1196,7 @@ impl Part for CommentBlog {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PageBlog { /// The identifier of the blog containing this page. - pub id: String, + pub id: Option, } impl NestedType for PageBlog {} @@ -1204,11 +1210,11 @@ impl Part for PageBlog {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BlogLocale { /// The country this blog's locale is set to. - pub country: String, + pub country: Option, /// The language variant this blog is authored in. - pub variant: String, + pub variant: Option, /// The language this blog is authored in. - pub language: String, + pub language: Option, } impl NestedType for BlogLocale {} @@ -2378,16 +2384,20 @@ impl<'a, C, A> PageViewGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2615,16 +2625,20 @@ impl<'a, C, A> UserGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2873,16 +2887,20 @@ impl<'a, C, A> BlogListByUserCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3143,16 +3161,20 @@ impl<'a, C, A> BlogGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3368,16 +3390,20 @@ impl<'a, C, A> BlogGetByUrlCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3524,7 +3550,7 @@ impl<'a, C, A> BlogGetByUrlCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Post = Default::default(); +/// let mut req = Post::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3643,16 +3669,20 @@ impl<'a, C, A> PostUpdateCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3943,16 +3973,20 @@ impl<'a, C, A> PostGetByPathCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4219,16 +4253,20 @@ impl<'a, C, A> PostGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4406,7 +4444,7 @@ impl<'a, C, A> PostGetCall<'a, C, A> where C: BorrowMut, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Post = Default::default(); +/// let mut req = Post::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4513,16 +4551,20 @@ impl<'a, C, A> PostInsertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4784,16 +4826,20 @@ impl<'a, C, A> PostPublishCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5032,16 +5078,20 @@ impl<'a, C, A> PostDeleteCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5264,16 +5314,20 @@ impl<'a, C, A> PostRevertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5516,16 +5570,20 @@ impl<'a, C, A> PostSearchCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5689,7 +5747,7 @@ impl<'a, C, A> PostSearchCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Post = Default::default(); +/// let mut req = Post::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5808,16 +5866,20 @@ impl<'a, C, A> PostPatchCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6150,16 +6212,20 @@ impl<'a, C, A> PostListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6460,16 +6526,20 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6721,16 +6791,20 @@ impl<'a, C, A> CommentRemoveContentCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7005,16 +7079,20 @@ impl<'a, C, A> CommentListByBlogCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7281,16 +7359,20 @@ impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7572,16 +7654,20 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7865,16 +7951,20 @@ impl<'a, C, A> CommentApproveCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -8118,16 +8208,20 @@ impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8367,16 +8461,20 @@ impl<'a, C, A> PostUserInfoGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8675,16 +8773,20 @@ impl<'a, C, A> PostUserInfoListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8985,16 +9087,20 @@ impl<'a, C, A> BlogUserInfoGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9239,16 +9345,20 @@ impl<'a, C, A> PageGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9514,16 +9624,20 @@ impl<'a, C, A> PageListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9781,16 +9895,20 @@ impl<'a, C, A> PageRevertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -9940,7 +10058,7 @@ impl<'a, C, A> PageRevertCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Page = Default::default(); +/// let mut req = Page::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10037,16 +10155,20 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10206,7 +10328,7 @@ impl<'a, C, A> PageInsertCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Page = Default::default(); +/// let mut req = Page::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10310,16 +10432,20 @@ impl<'a, C, A> PagePatchCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10579,16 +10705,20 @@ impl<'a, C, A> PagePublishCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -10738,7 +10868,7 @@ impl<'a, C, A> PagePublishCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Page = Default::default(); +/// let mut req = Page::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10842,16 +10972,20 @@ impl<'a, C, A> PageUpdateCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11110,16 +11244,20 @@ impl<'a, C, A> PageDeleteCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) diff --git a/gen/books1-cli/Cargo.toml b/gen/books1-cli/Cargo.toml index ee1bb44d52..09857322b3 100644 --- a/gen/books1-cli/Cargo.toml +++ b/gen/books1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-books1-cli" -version = "0.0.1+20150309" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/books/docs/v1/getting_started" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/books1-cli/mkdocs.yml b/gen/books1-cli/mkdocs.yml index ffefb03fb9..59b2893e1d 100644 --- a/gen/books1-cli/mkdocs.yml +++ b/gen/books1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: books v0.0.1+20150309 +site_name: books v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/books1-cli/src/cmn.rs +++ b/gen/books1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/books1-cli/src/main.rs b/gen/books1-cli/src/main.rs index d93a9c594b..f02f488470 100644 --- a/gen/books1-cli/src/main.rs +++ b/gen/books1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -32,14 +33,14 @@ Usage: 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 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-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 ]... @@ -75,6 +76,12 @@ Configuration: 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. "); mod cmn; @@ -98,7 +105,7 @@ impl Engine { -> Option { let mut call = self.hub.bookshelves().get(&self.opt.arg_user_id, &self.opt.arg_shelf); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -133,8 +140,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -145,7 +151,7 @@ impl Engine { -> Option { let mut call = self.hub.bookshelves().list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -180,8 +186,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -192,7 +197,7 @@ impl Engine { -> Option { let mut call = self.hub.bookshelves().volumes_list(&self.opt.arg_user_id, &self.opt.arg_shelf); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -236,8 +241,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -248,7 +252,7 @@ impl Engine { -> Option { let mut call = self.hub.cloudloading().add_book(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "upload-client-token" => { call = call.upload_client_token(value.unwrap_or("")); @@ -292,8 +296,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -304,7 +307,7 @@ impl Engine { -> Option { let mut call = self.hub.cloudloading().delete_book(&self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -335,7 +338,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -344,10 +346,10 @@ impl Engine { fn _cloudloading_update_book(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::BooksCloudloadingResource = Default::default(); + let mut request = api::BooksCloudloadingResource::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -367,9 +369,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -403,8 +406,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -415,7 +417,7 @@ impl Engine { -> Option { let mut call = self.hub.dictionary().list_offline_metadata(&self.opt.arg_cpksver); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -447,8 +449,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -459,7 +460,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().annotation_data_get(&self.opt.arg_volume_id, &self.opt.arg_layer_id, &self.opt.arg_annotation_data_id, &self.opt.arg_content_version); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "w" => { call = call.w(arg_from_str(value.unwrap_or("-0"), err, "w", "integer")); @@ -509,8 +510,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -521,7 +521,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().annotation_data_list(&self.opt.arg_volume_id, &self.opt.arg_layer_id, &self.opt.arg_content_version); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "w" => { call = call.w(arg_from_str(value.unwrap_or("-0"), err, "w", "integer")); @@ -583,8 +583,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -595,7 +594,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().get(&self.opt.arg_volume_id, &self.opt.arg_summary_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -633,8 +632,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -645,7 +643,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().list(&self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -689,8 +687,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -701,7 +698,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().volume_annotations_get(&self.opt.arg_volume_id, &self.opt.arg_layer_id, &self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -739,8 +736,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -751,7 +747,7 @@ impl Engine { -> Option { let mut call = self.hub.layers().volume_annotations_list(&self.opt.arg_volume_id, &self.opt.arg_layer_id, &self.opt.arg_content_version); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "volume-annotations-version" => { call = call.volume_annotations_version(value.unwrap_or("")); @@ -819,8 +815,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -831,7 +826,7 @@ impl Engine { -> Option { let mut call = self.hub.myconfig().get_user_settings(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -863,8 +858,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -875,7 +869,7 @@ impl Engine { -> Option { let mut call = self.hub.myconfig().release_download_access(&self.opt.arg_volume_ids, &self.opt.arg_cpksver); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -913,8 +907,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -925,7 +918,7 @@ impl Engine { -> Option { let mut call = self.hub.myconfig().request_access(&self.opt.arg_source, &self.opt.arg_volume_id, &self.opt.arg_nonce, &self.opt.arg_cpksver); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "locale" => { call = call.locale(value.unwrap_or("")); @@ -963,8 +956,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -975,7 +967,7 @@ impl Engine { -> Option { let mut call = self.hub.myconfig().sync_volume_licenses(&self.opt.arg_source, &self.opt.arg_nonce, &self.opt.arg_cpksver); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "volume-ids" => { call = call.add_volume_ids(value.unwrap_or("")); @@ -1019,8 +1011,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1029,10 +1020,10 @@ impl Engine { fn _myconfig_update_user_settings(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Usersettings = Default::default(); + let mut request = api::Usersettings::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1052,9 +1043,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1070,11 +1062,11 @@ impl Engine { }, "notes-export.is-enabled" => { request_notes_export_init(&mut request); - request.notes_export.as_mut().unwrap().is_enabled = arg_from_str(value.unwrap_or("false"), err, "notes-export.is-enabled", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -1093,8 +1085,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1105,7 +1096,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().annotations_delete(&self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1139,7 +1130,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1148,10 +1138,10 @@ impl Engine { fn _mylibrary_annotations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Annotation = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1180,18 +1170,75 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.client_version_ranges.as_mut().unwrap().cfi_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_gb_image_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().gb_image_range.is_none() { + request.client_version_ranges.as_mut().unwrap().gb_image_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_gb_text_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().gb_text_range.is_none() { + request.client_version_ranges.as_mut().unwrap().gb_text_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_image_cfi_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().image_cfi_range.is_none() { + request.client_version_ranges.as_mut().unwrap().image_cfi_range = Some(Default::default()); + } + } + fn request_client_version_ranges_init(request: &mut api::Annotation) { if request.client_version_ranges.is_none() { request.client_version_ranges = Some(Default::default()); } } + fn request_current_version_ranges_cfi_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().cfi_range.is_none() { + request.current_version_ranges.as_mut().unwrap().cfi_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_gb_image_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().gb_image_range.is_none() { + request.current_version_ranges.as_mut().unwrap().gb_image_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_gb_text_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().gb_text_range.is_none() { + request.current_version_ranges.as_mut().unwrap().gb_text_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_image_cfi_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().image_cfi_range.is_none() { + request.current_version_ranges.as_mut().unwrap().image_cfi_range = Some(Default::default()); + } + } + fn request_current_version_ranges_init(request: &mut api::Annotation) { if request.current_version_ranges.is_none() { request.current_version_ranges = Some(Default::default()); @@ -1210,9 +1257,9 @@ impl Engine { }, "page-ids" => { if request.page_ids.is_none() { - request.page_ids = Some(Default::default()); + request.page_ids = Some(Default::default()); } - request.page_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.page_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "created" => { request.created = Some(value.unwrap_or("").to_string()); @@ -1224,72 +1271,72 @@ impl Engine { request.before_selected_text = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.content-version" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().content_version = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().content_version = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "after-selected-text" => { request_current_version_ranges_init(&mut request); @@ -1305,87 +1352,87 @@ impl Engine { }, "layer-summary.limit-type" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().limit_type = value.unwrap_or("").to_string(); + request.layer_summary.as_mut().unwrap().limit_type = Some(value.unwrap_or("").to_string()); }, "layer-summary.remaining-character-count" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().remaining_character_count = arg_from_str(value.unwrap_or("-0"), err, "layer-summary.remaining-character-count", "integer"); + request.layer_summary.as_mut().unwrap().remaining_character_count = Some(arg_from_str(value.unwrap_or("-0"), err, "layer-summary.remaining-character-count", "integer")); }, "layer-summary.allowed-character-count" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().allowed_character_count = arg_from_str(value.unwrap_or("-0"), err, "layer-summary.allowed-character-count", "integer"); + request.layer_summary.as_mut().unwrap().allowed_character_count = Some(arg_from_str(value.unwrap_or("-0"), err, "layer-summary.allowed-character-count", "integer")); }, "selected-text" => { request_layer_summary_init(&mut request); request.selected_text = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.content-version" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().content_version = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().content_version = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "layer-id" => { request_client_version_ranges_init(&mut request); @@ -1424,8 +1471,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1436,7 +1482,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().annotations_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "volume-id" => { call = call.volume_id(value.unwrap_or("")); @@ -1498,8 +1544,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1510,7 +1555,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().annotations_summary(&self.opt.arg_layer_ids, &self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1542,8 +1587,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1552,10 +1596,10 @@ impl Engine { fn _mylibrary_annotations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Annotation = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1578,18 +1622,75 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.client_version_ranges.as_mut().unwrap().cfi_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_gb_image_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().gb_image_range.is_none() { + request.client_version_ranges.as_mut().unwrap().gb_image_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_gb_text_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().gb_text_range.is_none() { + request.client_version_ranges.as_mut().unwrap().gb_text_range = Some(Default::default()); + } + } + + fn request_client_version_ranges_image_cfi_range_init(request: &mut api::Annotation) { + request_client_version_ranges_init(request); + if request.client_version_ranges.as_mut().unwrap().image_cfi_range.is_none() { + request.client_version_ranges.as_mut().unwrap().image_cfi_range = Some(Default::default()); + } + } + fn request_client_version_ranges_init(request: &mut api::Annotation) { if request.client_version_ranges.is_none() { request.client_version_ranges = Some(Default::default()); } } + fn request_current_version_ranges_cfi_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().cfi_range.is_none() { + request.current_version_ranges.as_mut().unwrap().cfi_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_gb_image_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().gb_image_range.is_none() { + request.current_version_ranges.as_mut().unwrap().gb_image_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_gb_text_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().gb_text_range.is_none() { + request.current_version_ranges.as_mut().unwrap().gb_text_range = Some(Default::default()); + } + } + + fn request_current_version_ranges_image_cfi_range_init(request: &mut api::Annotation) { + request_current_version_ranges_init(request); + if request.current_version_ranges.as_mut().unwrap().image_cfi_range.is_none() { + request.current_version_ranges.as_mut().unwrap().image_cfi_range = Some(Default::default()); + } + } + fn request_current_version_ranges_init(request: &mut api::Annotation) { if request.current_version_ranges.is_none() { request.current_version_ranges = Some(Default::default()); @@ -1608,9 +1709,9 @@ impl Engine { }, "page-ids" => { if request.page_ids.is_none() { - request.page_ids = Some(Default::default()); + request.page_ids = Some(Default::default()); } - request.page_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.page_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "created" => { request.created = Some(value.unwrap_or("").to_string()); @@ -1622,72 +1723,72 @@ impl Engine { request.before_selected_text = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.image-cfi-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().image_cfi_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_image_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-text-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_text_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.content-version" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().content_version = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_text_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().content_version = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.cfi-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().cfi_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_cfi_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.start-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.start_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.end-position" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.end_position = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.start-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.start_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "current-version-ranges.gb-image-range.end-offset" => { - request_current_version_ranges_init(&mut request); - request.current_version_ranges.as_mut().unwrap().gb_image_range.end_offset = value.unwrap_or("").to_string(); + request_current_version_ranges_gb_image_range_init(&mut request); + request.current_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "after-selected-text" => { request_current_version_ranges_init(&mut request); @@ -1703,87 +1804,87 @@ impl Engine { }, "layer-summary.limit-type" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().limit_type = value.unwrap_or("").to_string(); + request.layer_summary.as_mut().unwrap().limit_type = Some(value.unwrap_or("").to_string()); }, "layer-summary.remaining-character-count" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().remaining_character_count = arg_from_str(value.unwrap_or("-0"), err, "layer-summary.remaining-character-count", "integer"); + request.layer_summary.as_mut().unwrap().remaining_character_count = Some(arg_from_str(value.unwrap_or("-0"), err, "layer-summary.remaining-character-count", "integer")); }, "layer-summary.allowed-character-count" => { request_layer_summary_init(&mut request); - request.layer_summary.as_mut().unwrap().allowed_character_count = arg_from_str(value.unwrap_or("-0"), err, "layer-summary.allowed-character-count", "integer"); + request.layer_summary.as_mut().unwrap().allowed_character_count = Some(arg_from_str(value.unwrap_or("-0"), err, "layer-summary.allowed-character-count", "integer")); }, "selected-text" => { request_layer_summary_init(&mut request); request.selected_text = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.image-cfi-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().image_cfi_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_image_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().image_cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-text-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_text_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_text_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.content-version" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().content_version = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_text_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().content_version = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.cfi-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().cfi_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_cfi_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().cfi_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.start-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.start_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.end-position" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.end_position = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_position = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.start-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.start_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().start_offset = Some(value.unwrap_or("").to_string()); }, "client-version-ranges.gb-image-range.end-offset" => { - request_client_version_ranges_init(&mut request); - request.client_version_ranges.as_mut().unwrap().gb_image_range.end_offset = value.unwrap_or("").to_string(); + request_client_version_ranges_gb_image_range_init(&mut request); + request.client_version_ranges.as_mut().unwrap().gb_image_range.as_mut().unwrap().end_offset = Some(value.unwrap_or("").to_string()); }, "layer-id" => { request_client_version_ranges_init(&mut request); @@ -1822,8 +1923,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1834,7 +1934,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_add_volume(&self.opt.arg_shelf, &self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1871,7 +1971,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1882,7 +1981,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_clear_volumes(&self.opt.arg_shelf); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1916,7 +2015,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1927,7 +2025,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_get(&self.opt.arg_shelf); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -1962,8 +2060,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1974,7 +2071,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2009,8 +2106,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2022,7 +2118,7 @@ impl Engine { let volume_position: i32 = arg_from_str(&self.opt.arg_volume_position, err, "", "integer"); let mut call = self.hub.mylibrary().bookshelves_move_volume(&self.opt.arg_shelf, &self.opt.arg_volume_id, volume_position); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2056,7 +2152,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2067,7 +2162,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_remove_volume(&self.opt.arg_shelf, &self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2104,7 +2199,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2115,7 +2209,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().bookshelves_volumes_list(&self.opt.arg_shelf); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2168,8 +2262,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2180,7 +2273,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().readingpositions_get(&self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2218,8 +2311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2230,7 +2322,7 @@ impl Engine { -> Option { let mut call = self.hub.mylibrary().readingpositions_set_position(&self.opt.arg_volume_id, &self.opt.arg_timestamp, &self.opt.arg_position); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2273,7 +2365,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2284,7 +2375,7 @@ impl Engine { -> Option { let mut call = self.hub.onboarding().list_categories(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "locale" => { call = call.locale(value.unwrap_or("")); @@ -2319,8 +2410,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2331,7 +2421,7 @@ impl Engine { -> Option { let mut call = self.hub.onboarding().list_category_volumes(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2375,8 +2465,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2387,7 +2476,7 @@ impl Engine { -> Option { let mut call = self.hub.promooffer().accept(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "volume-id" => { call = call.volume_id(value.unwrap_or("")); @@ -2442,7 +2531,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2453,7 +2541,7 @@ impl Engine { -> Option { let mut call = self.hub.promooffer().dismiss(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "serial" => { call = call.serial(value.unwrap_or("")); @@ -2505,7 +2593,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2516,7 +2603,7 @@ impl Engine { -> Option { let mut call = self.hub.promooffer().get(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "serial" => { call = call.serial(value.unwrap_or("")); @@ -2566,8 +2653,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2578,7 +2664,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().associated_list(&self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2619,8 +2705,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2631,7 +2716,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().get(&self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-library-consistent-read" => { call = call.user_library_consistent_read(arg_from_str(value.unwrap_or("false"), err, "user-library-consistent-read", "boolean")); @@ -2678,8 +2763,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2690,7 +2774,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().list(&self.opt.arg_q); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2758,8 +2842,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2770,7 +2853,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().mybooks_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2820,8 +2903,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2832,7 +2914,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().recommended_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2870,8 +2952,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2882,7 +2963,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().recommended_rate(&self.opt.arg_rating, &self.opt.arg_volume_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -2920,8 +3001,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2932,7 +3012,7 @@ impl Engine { -> Option { let mut call = self.hub.volumes().useruploaded_list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "volume-id" => { call = call.add_volume_id(value.unwrap_or("")); @@ -2982,8 +3062,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3005,7 +3084,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_cloudloading { + } + else if self.opt.cmd_cloudloading { if self.opt.cmd_add_book { call_result = self._cloudloading_add_book(dry_run, &mut err); } else if self.opt.cmd_delete_book { @@ -3015,13 +3095,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_dictionary { + } + else if self.opt.cmd_dictionary { if self.opt.cmd_list_offline_metadata { call_result = self._dictionary_list_offline_metadata(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_layers { + } + else if self.opt.cmd_layers { if self.opt.cmd_annotation_data_get { call_result = self._layers_annotation_data_get(dry_run, &mut err); } else if self.opt.cmd_annotation_data_list { @@ -3037,7 +3119,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_myconfig { + } + else if self.opt.cmd_myconfig { if self.opt.cmd_get_user_settings { call_result = self._myconfig_get_user_settings(dry_run, &mut err); } else if self.opt.cmd_release_download_access { @@ -3051,7 +3134,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_mylibrary { + } + else if self.opt.cmd_mylibrary { if self.opt.cmd_annotations_delete { call_result = self._mylibrary_annotations_delete(dry_run, &mut err); } else if self.opt.cmd_annotations_insert { @@ -3083,7 +3167,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_onboarding { + } + else if self.opt.cmd_onboarding { if self.opt.cmd_list_categories { call_result = self._onboarding_list_categories(dry_run, &mut err); } else if self.opt.cmd_list_category_volumes { @@ -3091,7 +3176,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_promooffer { + } + else if self.opt.cmd_promooffer { if self.opt.cmd_accept { call_result = self._promooffer_accept(dry_run, &mut err); } else if self.opt.cmd_dismiss { @@ -3101,7 +3187,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_volumes { + } + else if self.opt.cmd_volumes { if self.opt.cmd_associated_list { call_result = self._volumes_associated_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3139,21 +3226,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "books1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "books1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "books1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "books1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Books::new(hyper::Client::new(), auth), + hub: api::Books::new(client, auth), }; match engine._doit(true) { @@ -3173,12 +3276,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/books1/Cargo.toml b/gen/books1/Cargo.toml index 0238e1852a..e72093dcdf 100644 --- a/gen/books1/Cargo.toml +++ b/gen/books1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-books1" -version = "0.1.5+20150309" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/books/docs/v1/getting_started" diff --git a/gen/books1/README.md b/gen/books1/README.md index 469c9a2510..326140e794 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+20150309*, where *20150309* 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.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*. Everything else about the *books* *v1* API can be found at the [official documentation site](https://developers.google.com/books/docs/v1/getting_started). diff --git a/gen/books1/src/cmn.rs b/gen/books1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/books1/src/cmn.rs +++ b/gen/books1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/books1/src/lib.rs b/gen/books1/src/lib.rs index 8eff6e3974..7f675a05dd 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+20150309*, where *20150309* 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.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*. //! //! Everything else about the *books* *v1* API can be found at the //! [official documentation site](https://developers.google.com/books/docs/v1/getting_started). @@ -403,9 +403,9 @@ impl<'a, C, A> Books #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Category { /// A list of onboarding categories. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Category {} @@ -419,12 +419,12 @@ impl ResponseResult for Category {} pub struct CategoryItems { /// no description provided #[serde(rename="badgeUrl")] - pub badge_url: String, + pub badge_url: Option, /// no description provided #[serde(rename="categoryId")] - pub category_id: String, + pub category_id: Option, /// no description provided - pub name: String, + pub name: Option, } impl NestedType for CategoryItems {} @@ -438,32 +438,32 @@ impl Part for CategoryItems {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConcurrentAccessRestriction { /// Client nonce for verification. Download access and client-validation only. - pub nonce: String, + pub nonce: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// Whether this volume has any concurrent access restrictions. - pub restricted: bool, + pub restricted: Option, /// Identifies the volume for which this entry applies. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// The maximum number of concurrent access licenses for this volume. #[serde(rename="maxConcurrentDevices")] - pub max_concurrent_devices: i32, + pub max_concurrent_devices: Option, /// Whether access is granted for this (user, device, volume). #[serde(rename="deviceAllowed")] - pub device_allowed: bool, + pub device_allowed: Option, /// Client app identifier for verification. Download access and client-validation only. - pub source: String, + pub source: Option, /// Time in seconds for license auto-expiration. #[serde(rename="timeWindowSeconds")] - pub time_window_seconds: i32, + pub time_window_seconds: Option, /// Response signature. - pub signature: String, + pub signature: Option, /// Error/warning reason code. #[serde(rename="reasonCode")] - pub reason_code: String, + pub reason_code: Option, /// Error/warning message. - pub message: String, + pub message: Option, } impl Part for ConcurrentAccessRestriction {} @@ -476,11 +476,11 @@ impl Part for ConcurrentAccessRestriction {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeVolumeInfoDimensions { /// Width of this volume (in cm). - pub width: String, + pub width: Option, /// Height or length of this volume (in cm). - pub height: String, + pub height: Option, /// Thickness of this volume (in cm). - pub thickness: String, + pub thickness: Option, } impl NestedType for VolumeVolumeInfoDimensions {} @@ -494,66 +494,69 @@ impl Part for VolumeVolumeInfoDimensions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeVolumeInfo { /// Volume subtitle. (In LITE projection.) - pub subtitle: String, + pub subtitle: Option, /// A synopsis of the volume. The text of the description is formatted in HTML and includes simple formatting elements, such as b, i, and br tags. (In LITE projection.) - pub description: String, + pub description: Option, /// Total number of pages as per publisher metadata. #[serde(rename="pageCount")] - pub page_count: i32, + pub page_count: Option, /// A list of image links for all the sizes that are available. (In LITE projection.) #[serde(rename="imageLinks")] - pub image_links: VolumeVolumeInfoImageLinks, + pub image_links: Option, /// The number of review ratings for this volume. #[serde(rename="ratingsCount")] - pub ratings_count: i32, + pub ratings_count: Option, /// The main category to which this volume belongs. It will be the category from the categories list returned below that has the highest weight. #[serde(rename="mainCategory")] - pub main_category: String, + pub main_category: Option, /// The names of the authors and/or editors for this volume. (In LITE projection) - pub authors: Vec, + pub authors: Option>, /// A list of subject categories, such as "Fiction", "Suspense", etc. - pub categories: Vec, + pub categories: Option>, /// Publisher of this volume. (In LITE projection.) - pub publisher: String, + pub publisher: Option, /// Physical dimensions of this volume. - pub dimensions: VolumeVolumeInfoDimensions, + pub dimensions: Option, /// Best language for this volume (based on content). It is the two-letter ISO 639-1 code such as 'fr', 'en', etc. - pub language: String, + pub language: Option, /// URL to preview this volume on the Google Books site. #[serde(rename="previewLink")] - pub preview_link: String, - /// The reading modes available for this volume. - #[serde(rename="readingModes")] - pub reading_modes: String, + pub preview_link: Option, + /// no description provided + #[serde(rename="maturityRating")] + pub maturity_rating: Option, /// Date of publication. (In LITE projection.) #[serde(rename="publishedDate")] - pub published_date: String, + pub published_date: Option, /// Type of publication of this volume. Possible values are BOOK or MAGAZINE. #[serde(rename="printType")] - pub print_type: String, + pub print_type: Option, /// Total number of sample pages as per publisher metadata. #[serde(rename="samplePageCount")] - pub sample_page_count: i32, + pub sample_page_count: Option, + /// The reading modes available for this volume. + #[serde(rename="readingModes")] + pub reading_modes: Option, /// An identifier for the version of the volume content (text & images). (In LITE projection) #[serde(rename="contentVersion")] - pub content_version: String, + pub content_version: Option, /// Total number of printed pages in generated pdf representation. #[serde(rename="printedPageCount")] - pub printed_page_count: i32, + pub printed_page_count: Option, /// Industry standard identifiers for this volume. #[serde(rename="industryIdentifiers")] - pub industry_identifiers: Vec, + pub industry_identifiers: Option>, /// Volume title. (In LITE projection.) - pub title: String, + pub title: Option, /// The mean review rating for this volume. (min = 1.0, max = 5.0) #[serde(rename="averageRating")] - pub average_rating: f64, + pub average_rating: Option, /// URL to view information about this volume on the Google Books site. (In LITE projection) #[serde(rename="infoLink")] - pub info_link: String, + pub info_link: Option, /// Canonical URL for a volume. (In LITE projection.) #[serde(rename="canonicalVolumeLink")] - pub canonical_volume_link: String, + pub canonical_volume_link: Option, } impl NestedType for VolumeVolumeInfo {} @@ -568,19 +571,19 @@ impl Part for VolumeVolumeInfo {} pub struct AnnotationClientVersionRanges { /// Range in image CFI format for this annotation sent by client. #[serde(rename="imageCfiRange")] - pub image_cfi_range: BooksAnnotationsRange, + pub image_cfi_range: Option, /// Range in GB text format for this annotation sent by client. #[serde(rename="gbTextRange")] - pub gb_text_range: BooksAnnotationsRange, + pub gb_text_range: Option, /// Content version the client sent in. #[serde(rename="contentVersion")] - pub content_version: String, + pub content_version: Option, /// Range in CFI format for this annotation sent by client. #[serde(rename="cfiRange")] - pub cfi_range: BooksAnnotationsRange, + pub cfi_range: Option, /// Range in GB image format for this annotation sent by client. #[serde(rename="gbImageRange")] - pub gb_image_range: BooksAnnotationsRange, + pub gb_image_range: Option, } impl NestedType for AnnotationClientVersionRanges {} @@ -600,12 +603,12 @@ impl Part for AnnotationClientVersionRanges {} pub struct RequestAccess { /// A download access response. #[serde(rename="downloadAccess")] - pub download_access: DownloadAccessRestriction, + pub download_access: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// A concurrent access response. #[serde(rename="concurrentAccess")] - pub concurrent_access: ConcurrentAccessRestriction, + pub concurrent_access: Option, } impl ResponseResult for RequestAccess {} @@ -618,20 +621,20 @@ impl ResponseResult for RequestAccess {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OffersItemsItems { /// no description provided - pub description: String, + pub description: Option, /// no description provided - pub author: String, + pub author: Option, /// no description provided - pub title: String, + pub title: Option, /// no description provided #[serde(rename="coverUrl")] - pub cover_url: String, + pub cover_url: Option, /// no description provided #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// no description provided #[serde(rename="canonicalVolumeLink")] - pub canonical_volume_link: String, + pub canonical_volume_link: Option, } impl NestedType for OffersItemsItems {} @@ -651,14 +654,14 @@ impl Part for OffersItemsItems {} pub struct Annotations { /// Token to pass in for pagination for the next page. This will not be present if this request does not have more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of annotations. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, /// Total number of annotations found. This may be greater than the number of notes returned in this response if results have been paginated. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, } impl ResponseResult for Annotations {} @@ -672,16 +675,16 @@ impl ResponseResult for Annotations {} pub struct VolumeSaleInfoOffers { /// The rental duration (for rental offers only). #[serde(rename="rentalDuration")] - pub rental_duration: VolumeSaleInfoOffersRentalDuration, + pub rental_duration: Option, /// Offer retail (=discounted) price in Micros #[serde(rename="retailPrice")] - pub retail_price: VolumeSaleInfoOffersRetailPrice, + pub retail_price: Option, /// Offer list (=undiscounted) price in Micros. #[serde(rename="listPrice")] - pub list_price: VolumeSaleInfoOffersListPrice, + pub list_price: Option, /// The finsky offer type (e.g., PURCHASE=0 RENTAL=3) #[serde(rename="finskyOfferType")] - pub finsky_offer_type: i32, + pub finsky_offer_type: Option, } impl NestedType for VolumeSaleInfoOffers {} @@ -700,9 +703,9 @@ impl Part for VolumeSaleInfoOffers {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metadata { /// A list of offline dictionary metadata. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Metadata {} @@ -726,35 +729,35 @@ impl ResponseResult for Metadata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Volume { /// Resource type for a volume. (In LITE projection.) - pub kind: String, + pub kind: Option, /// Any information about a volume related to reading or obtaining that volume text. This information can depend on country (books may be public domain in one country but not in another, e.g.). #[serde(rename="accessInfo")] - pub access_info: VolumeAccessInfo, + pub access_info: Option, /// Search result information related to this volume. #[serde(rename="searchInfo")] - pub search_info: VolumeSearchInfo, + pub search_info: Option, /// Any information about a volume related to the eBookstore and/or purchaseability. This information can depend on the country where the request originates from (i.e. books may not be for sale in certain countries). #[serde(rename="saleInfo")] - pub sale_info: VolumeSaleInfo, + pub sale_info: Option, /// Opaque identifier for a specific version of a volume resource. (In LITE projection) - pub etag: String, + pub etag: Option, /// What layers exist in this volume and high level information about them. #[serde(rename="layerInfo")] - pub layer_info: VolumeLayerInfo, + pub layer_info: Option, /// General volume information. #[serde(rename="volumeInfo")] - pub volume_info: VolumeVolumeInfo, + pub volume_info: Option, /// Recommendation related information for this volume. #[serde(rename="recommendedInfo")] - pub recommended_info: VolumeRecommendedInfo, + pub recommended_info: Option, /// Unique identifier for a volume. (In LITE projection.) - pub id: String, + pub id: Option, /// URL to this resource. (In LITE projection.) #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// User specific information related to this volume. (e.g. page this user last read or whether they purchased this book) #[serde(rename="userInfo")] - pub user_info: VolumeUserInfo, + pub user_info: Option, } impl Resource for Volume {} @@ -768,7 +771,7 @@ impl ResponseResult for Volume {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeLayerInfo { /// A layer should appear here if and only if the layer exists for this book. - pub layers: Vec, + pub layers: Option>, } impl NestedType for VolumeLayerInfo {} @@ -805,7 +808,7 @@ impl ResponseResult for Usersettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeRecommendedInfo { /// A text explaining why this volume is recommended. - pub explanation: String, + pub explanation: Option, } impl NestedType for VolumeRecommendedInfo {} @@ -819,15 +822,15 @@ impl Part for VolumeRecommendedInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetadataItems { /// no description provided - pub encrypted_key: String, + pub encrypted_key: Option, /// no description provided - pub version: String, + pub version: Option, /// no description provided - pub download_url: String, + pub download_url: Option, /// no description provided - pub language: String, + pub language: Option, /// no description provided - pub size: String, + pub size: Option, } impl NestedType for MetadataItems {} @@ -842,7 +845,7 @@ impl Part for MetadataItems {} pub struct ReviewAuthor { /// Name of this person. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, } impl NestedType for ReviewAuthor {} @@ -862,28 +865,28 @@ impl Part for ReviewAuthor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Bookshelf { /// Resource type for bookshelf metadata. - pub kind: String, + pub kind: Option, /// Description of this bookshelf. - pub description: String, + pub description: Option, /// Title of this bookshelf. - pub title: String, + pub title: Option, /// Number of volumes in this bookshelf. #[serde(rename="volumeCount")] - pub volume_count: i32, + pub volume_count: Option, /// Created time for this bookshelf (formatted UTC timestamp with millisecond resolution). - pub created: String, + pub created: Option, /// Last modified time of this bookshelf (formatted UTC timestamp with millisecond resolution). - pub updated: String, + pub updated: Option, /// Whether this bookshelf is PUBLIC or PRIVATE. - pub access: String, + pub access: Option, /// Last time a volume was added or removed from this bookshelf (formatted UTC timestamp with millisecond resolution). #[serde(rename="volumesLastUpdated")] - pub volumes_last_updated: String, + pub volumes_last_updated: Option, /// Id of this bookshelf, only unique by user. - pub id: i32, + pub id: Option, /// URL to this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for Bookshelf {} @@ -897,10 +900,10 @@ impl ResponseResult for Bookshelf {} pub struct UsersettingsNotesExport { /// no description provided #[serde(rename="isEnabled")] - pub is_enabled: bool, + pub is_enabled: Option, /// no description provided #[serde(rename="folderName")] - pub folder_name: String, + pub folder_name: Option, } impl NestedType for UsersettingsNotesExport {} @@ -977,28 +980,28 @@ impl ResponseResult for Annotation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Review { /// Star rating for this review. Possible values are ONE, TWO, THREE, FOUR, FIVE or NOT_RATED. - pub rating: String, + pub rating: Option, /// Resource type for a review. - pub kind: String, + pub kind: Option, /// Title for this review. - pub title: String, + pub title: Option, /// Author of this review. - pub author: ReviewAuthor, + pub author: Option, /// Volume that this review is for. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// Review text. - pub content: String, + pub content: Option, /// Information regarding the source of this review, when the review is not from a Google Books user. - pub source: ReviewSource, + pub source: Option, /// Date of this review. - pub date: String, + pub date: Option, /// Source type for this review. Possible values are EDITORIAL, WEB_USER or GOOGLE_USER. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// URL for the full review text, for reviews gathered from the web. #[serde(rename="fullTextUrl")] - pub full_text_url: String, + pub full_text_url: Option, } impl Part for Review {} @@ -1011,35 +1014,35 @@ impl Part for Review {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DownloadAccessRestriction { /// Client nonce for verification. Download access and client-validation only. - pub nonce: String, + pub nonce: Option, /// Resource type. - pub kind: String, + pub kind: Option, /// If deviceAllowed, whether access was just acquired with this request. #[serde(rename="justAcquired")] - pub just_acquired: bool, + pub just_acquired: Option, /// If restricted, the maximum number of content download licenses for this volume. #[serde(rename="maxDownloadDevices")] - pub max_download_devices: i32, + pub max_download_devices: Option, /// If restricted, the number of content download licenses already acquired (including the requesting client, if licensed). #[serde(rename="downloadsAcquired")] - pub downloads_acquired: i32, + pub downloads_acquired: Option, /// Identifies the volume for which this entry applies. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// If restricted, whether access is granted for this (user, device, volume). #[serde(rename="deviceAllowed")] - pub device_allowed: bool, + pub device_allowed: Option, /// Client app identifier for verification. Download access and client-validation only. - pub source: String, + pub source: Option, /// Response signature. - pub signature: String, + pub signature: Option, /// Error/warning reason code. Additional codes may be added in the future. 0 OK 100 ACCESS_DENIED_PUBLISHER_LIMIT 101 ACCESS_DENIED_LIMIT 200 WARNING_USED_LAST_ACCESS #[serde(rename="reasonCode")] - pub reason_code: String, + pub reason_code: Option, /// Error/warning message. - pub message: String, + pub message: Option, /// Whether this volume has any download access restrictions. - pub restricted: bool, + pub restricted: Option, } impl Part for DownloadAccessRestriction {} @@ -1058,9 +1061,9 @@ impl Part for DownloadAccessRestriction {} pub struct DownloadAccesses { /// A list of download access responses. #[serde(rename="downloadAccessList")] - pub download_access_list: Vec, + pub download_access_list: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for DownloadAccesses {} @@ -1074,11 +1077,11 @@ impl ResponseResult for DownloadAccesses {} pub struct ReviewSource { /// Extra text about the source of the review. #[serde(rename="extraDescription")] - pub extra_description: String, + pub extra_description: Option, /// URL of the source of the review. - pub url: String, + pub url: Option, /// Name of the source. - pub description: String, + pub description: Option, } impl NestedType for ReviewSource {} @@ -1098,23 +1101,23 @@ impl Part for ReviewSource {} pub struct ReadingPosition { /// Position in a PDF file. #[serde(rename="pdfPosition")] - pub pdf_position: String, + pub pdf_position: Option, /// Resource type for a reading position. - pub kind: String, + pub kind: Option, /// Position in a volume for image-based content. #[serde(rename="gbImagePosition")] - pub gb_image_position: String, + pub gb_image_position: Option, /// Position in a volume for text-based content. #[serde(rename="gbTextPosition")] - pub gb_text_position: String, + pub gb_text_position: Option, /// Position in an EPUB as a CFI. #[serde(rename="epubCfiPosition")] - pub epub_cfi_position: String, + pub epub_cfi_position: Option, /// Timestamp when this reading position was last updated (formatted UTC timestamp with millisecond resolution). - pub updated: String, + pub updated: Option, /// Volume id associated with this reading position. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, } impl ResponseResult for ReadingPosition {} @@ -1128,10 +1131,10 @@ impl ResponseResult for ReadingPosition {} pub struct VolumeSaleInfoOffersRetailPrice { /// no description provided #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, /// no description provided #[serde(rename="amountInMicros")] - pub amount_in_micros: f64, + pub amount_in_micros: Option, } impl NestedType for VolumeSaleInfoOffersRetailPrice {} @@ -1146,7 +1149,7 @@ impl Part for VolumeSaleInfoOffersRetailPrice {} pub struct VolumeSearchInfo { /// A text snippet containing the search query. #[serde(rename="textSnippet")] - pub text_snippet: String, + pub text_snippet: Option, } impl NestedType for VolumeSearchInfo {} @@ -1161,18 +1164,18 @@ impl Part for VolumeSearchInfo {} pub struct AnnotationsSummaryLayers { /// no description provided #[serde(rename="limitType")] - pub limit_type: String, + pub limit_type: Option, /// no description provided #[serde(rename="remainingCharacterCount")] - pub remaining_character_count: i32, + pub remaining_character_count: Option, /// no description provided - pub updated: String, + pub updated: Option, /// no description provided #[serde(rename="allowedCharacterCount")] - pub allowed_character_count: i32, + pub allowed_character_count: Option, /// no description provided #[serde(rename="layerId")] - pub layer_id: String, + pub layer_id: Option, } impl NestedType for AnnotationsSummaryLayers {} @@ -1192,26 +1195,26 @@ impl Part for AnnotationsSummaryLayers {} pub struct Annotationdata { /// The type of annotation this data is for. #[serde(rename="annotationType")] - pub annotation_type: String, + pub annotation_type: Option, /// Resource Type - pub kind: String, + pub kind: Option, /// Timestamp for the last time this data was updated. (RFC 3339 UTC date-time format). - pub updated: String, + pub updated: Option, /// The volume id for this data. * #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// Base64 encoded data for this annotation data. - pub encoded_data: String, + pub encoded_data: Option, /// The Layer id for this data. * #[serde(rename="layerId")] - pub layer_id: String, + pub layer_id: Option, /// no description provided - pub data: String, + pub data: Option, /// Unique id for this annotation data. - pub id: String, + pub id: Option, /// URL for this resource. * #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for Annotationdata {} @@ -1224,19 +1227,19 @@ impl ResponseResult for Annotationdata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeVolumeInfoImageLinks { /// Image link for large size (width of ~800 pixels). (In LITE projection) - pub large: String, + pub large: Option, /// Image link for extra large size (width of ~1280 pixels). (In LITE projection) #[serde(rename="extraLarge")] - pub extra_large: String, + pub extra_large: Option, /// Image link for medium size (width of ~575 pixels). (In LITE projection) - pub medium: String, + pub medium: Option, /// Image link for small thumbnail size (width of ~80 pixels). (In LITE projection) #[serde(rename="smallThumbnail")] - pub small_thumbnail: String, + pub small_thumbnail: Option, /// Image link for small size (width of ~300 pixels). (In LITE projection) - pub small: String, + pub small: Option, /// Image link for thumbnail size (width of ~128 pixels). (In LITE projection) - pub thumbnail: String, + pub thumbnail: Option, } impl NestedType for VolumeVolumeInfoImageLinks {} @@ -1250,10 +1253,10 @@ impl Part for VolumeVolumeInfoImageLinks {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeSaleInfoRetailPrice { /// Amount in the currency listed below. (In LITE projection.) - pub amount: f64, + pub amount: Option, /// An ISO 4217, three-letter currency code. (In LITE projection.) #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, } impl NestedType for VolumeSaleInfoRetailPrice {} @@ -1272,41 +1275,41 @@ impl Part for VolumeSaleInfoRetailPrice {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Layersummary { /// Resource Type - pub kind: String, + pub kind: Option, /// The number of annotations for this layer. #[serde(rename="annotationCount")] - pub annotation_count: i32, + pub annotation_count: Option, /// The number of data items for this layer. #[serde(rename="dataCount")] - pub data_count: i32, + pub data_count: Option, /// The list of annotation types contained for this layer. #[serde(rename="annotationTypes")] - pub annotation_types: Vec, + pub annotation_types: Option>, /// Timestamp for the last time an item in this layer was updated. (RFC 3339 UTC date-time format). - pub updated: String, + pub updated: Option, /// The volume id this resource is for. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// Link to get data for this annotation. #[serde(rename="annotationsDataLink")] - pub annotations_data_link: String, + pub annotations_data_link: Option, /// The link to get the annotations for this layer. #[serde(rename="annotationsLink")] - pub annotations_link: String, + pub annotations_link: Option, /// The content version this resource is for. #[serde(rename="contentVersion")] - pub content_version: String, + pub content_version: Option, /// The layer id for this summary. #[serde(rename="layerId")] - pub layer_id: String, + pub layer_id: Option, /// The current version of this layer's volume annotations. Note that this version applies only to the data in the books.layers.volumeAnnotations.* responses. The actual annotation data is versioned separately. #[serde(rename="volumeAnnotationsVersion")] - pub volume_annotations_version: String, + pub volume_annotations_version: Option, /// Unique id of this layer summary. - pub id: String, + pub id: Option, /// URL to this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for Layersummary {} @@ -1320,10 +1323,10 @@ impl ResponseResult for Layersummary {} pub struct VolumeSaleInfoOffersListPrice { /// no description provided #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, /// no description provided #[serde(rename="amountInMicros")] - pub amount_in_micros: f64, + pub amount_in_micros: Option, } impl NestedType for VolumeSaleInfoOffersListPrice {} @@ -1343,41 +1346,41 @@ impl Part for VolumeSaleInfoOffersListPrice {} pub struct Volumeannotation { /// The type of annotation this is. #[serde(rename="annotationType")] - pub annotation_type: String, + pub annotation_type: Option, /// Resource Type - pub kind: String, + pub kind: Option, /// Indicates that this annotation is deleted. - pub deleted: bool, + pub deleted: Option, /// The content ranges to identify the selected text. #[serde(rename="contentRanges")] - pub content_ranges: VolumeannotationContentRanges, + pub content_ranges: Option, /// Timestamp for the last time this anntoation was updated. (RFC 3339 UTC date-time format). - pub updated: String, + pub updated: Option, /// The Volume this annotation is for. #[serde(rename="volumeId")] - pub volume_id: String, + pub volume_id: Option, /// The annotation data id for this volume annotation. #[serde(rename="annotationDataId")] - pub annotation_data_id: String, + pub annotation_data_id: Option, /// Link to get data for this annotation. #[serde(rename="annotationDataLink")] - pub annotation_data_link: String, + pub annotation_data_link: Option, /// Pages the annotation spans. #[serde(rename="pageIds")] - pub page_ids: Vec, + pub page_ids: Option>, /// The Layer this annotation is for. #[serde(rename="layerId")] - pub layer_id: String, + pub layer_id: Option, /// Excerpt from the volume. #[serde(rename="selectedText")] - pub selected_text: String, + pub selected_text: Option, /// Data for this annotation. - pub data: String, + pub data: Option, /// Unique id of this volume annotation. - pub id: String, + pub id: Option, /// URL to this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for Volumeannotation {} @@ -1396,16 +1399,16 @@ impl ResponseResult for Volumeannotation {} pub struct Volumeannotations { /// Token to pass in for pagination for the next page. This will not be present if this request does not have more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of volume annotations. - pub items: Vec, + pub items: Option>, /// Resource type - pub kind: String, + pub kind: Option, /// The version string for all of the volume annotations in this layer (not just the ones in this response). Note: the version string doesn't apply to the annotation data, just the information in this response (e.g. the location of annotations in the book). - pub version: String, + pub version: Option, /// The total number of volume annotations found. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, } impl ResponseResult for Volumeannotations {} @@ -1424,14 +1427,14 @@ impl ResponseResult for Volumeannotations {} pub struct Annotationsdata { /// Token to pass in for pagination for the next page. This will not be present if this request does not have more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of Annotation Data. - pub items: Vec, + pub items: Option>, /// Resource type - pub kind: String, + pub kind: Option, /// The total number of volume annotations found. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, } impl ResponseResult for Annotationsdata {} @@ -1444,10 +1447,10 @@ impl ResponseResult for Annotationsdata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeVolumeInfoIndustryIdentifiers { /// Industry specific volume identifier. - pub identifier: String, + pub identifier: Option, /// Identifier type. Possible values are ISBN_10, ISBN_13, ISSN and OTHER. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl NestedType for VolumeVolumeInfoIndustryIdentifiers {} @@ -1462,13 +1465,13 @@ impl Part for VolumeVolumeInfoIndustryIdentifiers {} pub struct AnnotationLayerSummary { /// Type of limitation on this layer. "limited" or "unlimited" for the "copy" layer. #[serde(rename="limitType")] - pub limit_type: String, + pub limit_type: Option, /// Remaining allowed characters on this layer, especially for the "copy" layer. #[serde(rename="remainingCharacterCount")] - pub remaining_character_count: i32, + pub remaining_character_count: Option, /// Maximum allowed characters on this layer, especially for the "copy" layer. #[serde(rename="allowedCharacterCount")] - pub allowed_character_count: i32, + pub allowed_character_count: Option, } impl NestedType for AnnotationLayerSummary {} @@ -1487,9 +1490,9 @@ impl Part for AnnotationLayerSummary {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Offers { /// A list of offers. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Offers {} @@ -1503,13 +1506,13 @@ impl ResponseResult for Offers {} pub struct VolumeAccessInfoEpub { /// Is a flowing text epub available either as public domain or for purchase. (In LITE projection.) #[serde(rename="isAvailable")] - pub is_available: bool, + pub is_available: Option, /// URL to download epub. (In LITE projection.) #[serde(rename="downloadLink")] - pub download_link: String, + pub download_link: Option, /// URL to retrieve ACS token for epub download. (In LITE projection.) #[serde(rename="acsTokenLink")] - pub acs_token_link: String, + pub acs_token_link: Option, } impl NestedType for VolumeAccessInfoEpub {} @@ -1529,11 +1532,11 @@ impl Part for VolumeAccessInfoEpub {} pub struct Volume2 { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of volumes. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Volume2 {} @@ -1547,13 +1550,13 @@ impl ResponseResult for Volume2 {} pub struct VolumeAccessInfoPdf { /// Is a scanned image pdf available either as public domain or for purchase. (In LITE projection.) #[serde(rename="isAvailable")] - pub is_available: bool, + pub is_available: Option, /// URL to download pdf. (In LITE projection.) #[serde(rename="downloadLink")] - pub download_link: String, + pub download_link: Option, /// URL to retrieve ACS token for pdf download. (In LITE projection.) #[serde(rename="acsTokenLink")] - pub acs_token_link: String, + pub acs_token_link: Option, } impl NestedType for VolumeAccessInfoPdf {} @@ -1572,9 +1575,9 @@ impl Part for VolumeAccessInfoPdf {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnnotationsSummary { /// no description provided - pub layers: Vec, + pub layers: Option>, /// no description provided - pub kind: String, + pub kind: Option, } impl ResponseResult for AnnotationsSummary {} @@ -1593,9 +1596,9 @@ impl ResponseResult for AnnotationsSummary {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Bookshelves { /// A list of bookshelves. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Bookshelves {} @@ -1609,10 +1612,10 @@ impl ResponseResult for Bookshelves {} pub struct VolumeLayerInfoLayers { /// The current version of this layer's volume annotations. Note that this version applies only to the data in the books.layers.volumeAnnotations.* responses. The actual annotation data is versioned separately. #[serde(rename="volumeAnnotationsVersion")] - pub volume_annotations_version: String, + pub volume_annotations_version: Option, /// The layer id of this layer (e.g. "geo"). #[serde(rename="layerId")] - pub layer_id: String, + pub layer_id: Option, } impl NestedType for VolumeLayerInfoLayers {} @@ -1632,11 +1635,11 @@ impl Part for VolumeLayerInfoLayers {} pub struct Layersummaries { /// The total number of layer summaries found. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// A list of layer summary items. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Layersummaries {} @@ -1650,14 +1653,14 @@ impl ResponseResult for Layersummaries {} pub struct OffersItems { /// no description provided #[serde(rename="gservicesKey")] - pub gservices_key: String, + pub gservices_key: Option, /// no description provided - pub items: Vec, + pub items: Option>, /// no description provided #[serde(rename="artUrl")] - pub art_url: String, + pub art_url: Option, /// no description provided - pub id: String, + pub id: Option, } impl NestedType for OffersItems {} @@ -1672,15 +1675,15 @@ impl Part for OffersItems {} pub struct VolumeUserInfoCopy { /// no description provided #[serde(rename="limitType")] - pub limit_type: String, + pub limit_type: Option, /// no description provided #[serde(rename="remainingCharacterCount")] - pub remaining_character_count: i32, + pub remaining_character_count: Option, /// no description provided - pub updated: String, + pub updated: Option, /// no description provided #[serde(rename="allowedCharacterCount")] - pub allowed_character_count: i32, + pub allowed_character_count: Option, } impl NestedType for VolumeUserInfoCopy {} @@ -1699,7 +1702,7 @@ impl Part for VolumeUserInfoCopy {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BooksVolumesRecommendedRateResponse { /// no description provided - pub consistency_token: String, + pub consistency_token: Option, } impl ResponseResult for BooksVolumesRecommendedRateResponse {} @@ -1713,34 +1716,34 @@ impl ResponseResult for BooksVolumesRecommendedRateResponse {} pub struct VolumeUserInfo { /// Whether or not this volume is currently in "my books." #[serde(rename="isInMyBooks")] - pub is_in_my_books: bool, + pub is_in_my_books: Option, /// Period during this book is/was a valid rental. #[serde(rename="rentalPeriod")] - pub rental_period: VolumeUserInfoRentalPeriod, + pub rental_period: Option, /// Timestamp when this volume was last modified by a user action, such as a reading position update, volume purchase or writing a review. (RFC 3339 UTC date-time format). - pub updated: String, + pub updated: Option, /// no description provided #[serde(rename="userUploadedVolumeInfo")] - pub user_uploaded_volume_info: VolumeUserInfoUserUploadedVolumeInfo, + pub user_uploaded_volume_info: Option, /// Whether this book is an active or an expired rental. #[serde(rename="rentalState")] - pub rental_state: String, + pub rental_state: Option, /// Whether or not this volume was purchased by the authenticated user making the request. (In LITE projection.) #[serde(rename="isPurchased")] - pub is_purchased: bool, + pub is_purchased: Option, /// The user's current reading position in the volume, if one is available. (In LITE projection.) #[serde(rename="readingPosition")] - pub reading_position: ReadingPosition, + pub reading_position: Option, /// Whether or not this volume was pre-ordered by the authenticated user making the request. (In LITE projection.) #[serde(rename="isPreordered")] - pub is_preordered: bool, + pub is_preordered: Option, /// Copy/Paste accounting information. - pub copy: VolumeUserInfoCopy, + pub copy: Option, /// This user's review of this volume, if one exists. - pub review: Review, + pub review: Option, /// Whether or not this volume was user uploaded. #[serde(rename="isUploaded")] - pub is_uploaded: bool, + pub is_uploaded: Option, } impl NestedType for VolumeUserInfo {} @@ -1783,7 +1786,7 @@ impl ResponseResult for BooksCloudloadingResource {} pub struct VolumeUserInfoUserUploadedVolumeInfo { /// no description provided #[serde(rename="processingState")] - pub processing_state: String, + pub processing_state: Option, } impl NestedType for VolumeUserInfoUserUploadedVolumeInfo {} @@ -1797,10 +1800,10 @@ impl Part for VolumeUserInfoUserUploadedVolumeInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeSaleInfoListPrice { /// Amount in the currency listed below. (In LITE projection.) - pub amount: f64, + pub amount: Option, /// An ISO 4217, three-letter currency code. (In LITE projection.) #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option, } impl NestedType for VolumeSaleInfoListPrice {} @@ -1815,16 +1818,16 @@ impl Part for VolumeSaleInfoListPrice {} pub struct BooksAnnotationsRange { /// The starting position for the range. #[serde(rename="startPosition")] - pub start_position: String, + pub start_position: Option, /// The ending position for the range. #[serde(rename="endPosition")] - pub end_position: String, + pub end_position: Option, /// The offset from the starting position. #[serde(rename="startOffset")] - pub start_offset: String, + pub start_offset: Option, /// The offset from the ending position. #[serde(rename="endOffset")] - pub end_offset: String, + pub end_offset: Option, } impl Part for BooksAnnotationsRange {} @@ -1838,41 +1841,41 @@ impl Part for BooksAnnotationsRange {} pub struct VolumeAccessInfo { /// URL to read this volume on the Google Books site. Link will not allow users to read non-viewable volumes. #[serde(rename="webReaderLink")] - pub web_reader_link: String, + pub web_reader_link: Option, /// Whether or not this book is public domain in the country listed above. #[serde(rename="publicDomain")] - pub public_domain: bool, + pub public_domain: Option, /// Whether this volume requires that the client explicitly request offline download license rather than have it done automatically when loading the content, if the client supports it. #[serde(rename="explicitOfflineLicenseManagement")] - pub explicit_offline_license_management: bool, + pub explicit_offline_license_management: Option, /// Whether this volume can be embedded in a viewport using the Embedded Viewer API. - pub embeddable: bool, + pub embeddable: Option, /// Information about a volume's download license access restrictions. #[serde(rename="downloadAccess")] - pub download_access: DownloadAccessRestriction, + pub download_access: Option, /// The two-letter ISO_3166-1 country code for which this access information is valid. (In LITE projection.) - pub country: String, + pub country: Option, /// For ordered but not yet processed orders, we give a URL that can be used to go to the appropriate Google Wallet page. #[serde(rename="viewOrderUrl")] - pub view_order_url: String, + pub view_order_url: Option, /// Whether text-to-speech is permitted for this volume. Values can be ALLOWED, ALLOWED_FOR_ACCESSIBILITY, or NOT_ALLOWED. #[serde(rename="textToSpeechPermission")] - pub text_to_speech_permission: String, + pub text_to_speech_permission: Option, /// URL to the Google Drive viewer if this volume is uploaded by the user by selecting the file from Google Drive. #[serde(rename="driveImportedContentLink")] - pub drive_imported_content_link: String, + pub drive_imported_content_link: Option, /// Information about pdf content. (In LITE projection.) - pub pdf: VolumeAccessInfoPdf, + pub pdf: Option, /// Whether quote sharing is allowed for this volume. #[serde(rename="quoteSharingAllowed")] - pub quote_sharing_allowed: bool, + pub quote_sharing_allowed: Option, /// The read access of a volume. Possible values are PARTIAL, ALL_PAGES, NO_PAGES or UNKNOWN. This value depends on the country listed above. A value of PARTIAL means that the publisher has allowed some portion of the volume to be viewed publicly, without purchase. This can apply to eBooks as well as non-eBooks. Public domain books will always have a value of ALL_PAGES. - pub viewability: String, + pub viewability: Option, /// Information about epub content. (In LITE projection.) - pub epub: VolumeAccessInfoEpub, + pub epub: Option, /// Combines the access and viewability of this volume into a single status field for this user. Values can be FULL_PURCHASED, FULL_PUBLIC_DOMAIN, SAMPLE or NONE. (In LITE projection.) #[serde(rename="accessViewStatus")] - pub access_view_status: String, + pub access_view_status: Option, } impl NestedType for VolumeAccessInfo {} @@ -1887,19 +1890,19 @@ impl Part for VolumeAccessInfo {} pub struct AnnotationCurrentVersionRanges { /// Range in image CFI format for this annotation for version above. #[serde(rename="imageCfiRange")] - pub image_cfi_range: BooksAnnotationsRange, + pub image_cfi_range: Option, /// Range in GB text format for this annotation for version above. #[serde(rename="gbTextRange")] - pub gb_text_range: BooksAnnotationsRange, + pub gb_text_range: Option, /// Content version applicable to ranges below. #[serde(rename="contentVersion")] - pub content_version: String, + pub content_version: Option, /// Range in CFI format for this annotation for version above. #[serde(rename="cfiRange")] - pub cfi_range: BooksAnnotationsRange, + pub cfi_range: Option, /// Range in GB image format for this annotation for version above. #[serde(rename="gbImageRange")] - pub gb_image_range: BooksAnnotationsRange, + pub gb_image_range: Option, } impl NestedType for AnnotationCurrentVersionRanges {} @@ -1913,26 +1916,26 @@ impl Part for AnnotationCurrentVersionRanges {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeSaleInfo { /// The two-letter ISO_3166-1 country code for which this sale information is valid. (In LITE projection.) - pub country: String, + pub country: Option, /// The actual selling price of the book. This is the same as the suggested retail or list price unless there are offers or discounts on this volume. (In LITE projection.) #[serde(rename="retailPrice")] - pub retail_price: VolumeSaleInfoRetailPrice, + pub retail_price: Option, /// Whether or not this volume is an eBook (can be added to the My eBooks shelf). #[serde(rename="isEbook")] - pub is_ebook: bool, + pub is_ebook: Option, /// Offers available for this volume (sales and rentals). - pub offers: Vec, + pub offers: Option>, /// Whether or not this book is available for sale or offered for free in the Google eBookstore for the country listed above. Possible values are FOR_SALE, FOR_RENTAL_ONLY, FOR_SALE_AND_RENTAL, FREE, NOT_FOR_SALE, or FOR_PREORDER. - pub saleability: String, + pub saleability: Option, /// URL to purchase this volume on the Google Books site. (In LITE projection) #[serde(rename="buyLink")] - pub buy_link: String, + pub buy_link: Option, /// The date on which this book is available for sale. #[serde(rename="onSaleDate")] - pub on_sale_date: String, + pub on_sale_date: Option, /// Suggested retail price. (In LITE projection.) #[serde(rename="listPrice")] - pub list_price: VolumeSaleInfoListPrice, + pub list_price: Option, } impl NestedType for VolumeSaleInfo {} @@ -1959,11 +1962,11 @@ impl Part for VolumeSaleInfo {} pub struct Volumes { /// Total number of volumes found. This might be greater than the number of volumes returned in this response if results have been paginated. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option, /// A list of volumes. - pub items: Vec, + pub items: Option>, /// Resource type. - pub kind: String, + pub kind: Option, } impl ResponseResult for Volumes {} @@ -1977,10 +1980,10 @@ impl ResponseResult for Volumes {} pub struct VolumeUserInfoRentalPeriod { /// no description provided #[serde(rename="startUtcSec")] - pub start_utc_sec: String, + pub start_utc_sec: Option, /// no description provided #[serde(rename="endUtcSec")] - pub end_utc_sec: String, + pub end_utc_sec: Option, } impl NestedType for VolumeUserInfoRentalPeriod {} @@ -1995,16 +1998,16 @@ impl Part for VolumeUserInfoRentalPeriod {} pub struct VolumeannotationContentRanges { /// Range in GB image format for this annotation for version above. #[serde(rename="gbImageRange")] - pub gb_image_range: BooksAnnotationsRange, + pub gb_image_range: Option, /// Range in GB text format for this annotation for version above. #[serde(rename="gbTextRange")] - pub gb_text_range: BooksAnnotationsRange, + pub gb_text_range: Option, /// Content version applicable to ranges below. #[serde(rename="contentVersion")] - pub content_version: String, + pub content_version: Option, /// Range in CFI format for this annotation for version above. #[serde(rename="cfiRange")] - pub cfi_range: BooksAnnotationsRange, + pub cfi_range: Option, } impl NestedType for VolumeannotationContentRanges {} @@ -2018,9 +2021,9 @@ impl Part for VolumeannotationContentRanges {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VolumeSaleInfoOffersRentalDuration { /// no description provided - pub count: f64, + pub count: Option, /// no description provided - pub unit: String, + pub unit: Option, } impl NestedType for VolumeSaleInfoOffersRentalDuration {} @@ -2865,7 +2868,7 @@ impl<'a, C, A> MyconfigMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Sets the settings for the user. Unspecified sub-objects will retain the existing value. + /// Sets the settings for the user. If a sub-object is specified, it will overwrite the existing sub-object stored in the server. Unspecified sub-objects will retain the existing value. /// /// # Arguments /// @@ -3445,16 +3448,20 @@ impl<'a, C, A> LayerAnnotationDataGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3761,16 +3768,20 @@ impl<'a, C, A> LayerVolumeAnnotationGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4045,16 +4056,20 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4315,16 +4330,20 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4633,16 +4652,20 @@ impl<'a, C, A> LayerVolumeAnnotationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5025,16 +5048,20 @@ impl<'a, C, A> LayerAnnotationDataListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5334,16 +5361,20 @@ impl<'a, C, A> VolumeRecommendedRateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5600,16 +5631,20 @@ impl<'a, C, A> VolumeMybookListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5900,16 +5935,20 @@ impl<'a, C, A> VolumeListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6226,16 +6265,20 @@ impl<'a, C, A> VolumeUseruploadedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6505,16 +6548,20 @@ impl<'a, C, A> VolumeAssociatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6781,16 +6828,20 @@ impl<'a, C, A> VolumeGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7029,16 +7080,20 @@ impl<'a, C, A> VolumeRecommendedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7239,16 +7294,20 @@ impl<'a, C, A> DictionaryListOfflineMetadataCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7491,16 +7550,20 @@ impl<'a, C, A> BookshelveVolumeListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7764,16 +7827,20 @@ impl<'a, C, A> BookshelveListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8008,16 +8075,20 @@ impl<'a, C, A> BookshelveGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8268,16 +8339,20 @@ impl<'a, C, A> PromoofferAcceptCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -8541,16 +8616,20 @@ impl<'a, C, A> PromoofferDismisCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -8804,16 +8883,20 @@ impl<'a, C, A> PromoofferGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9045,16 +9128,20 @@ impl<'a, C, A> OnboardingListCategoryCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9270,16 +9357,20 @@ impl<'a, C, A> OnboardingListCategoryVolumeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9511,16 +9602,20 @@ impl<'a, C, A> MyconfigRequestAccesCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -9779,16 +9874,20 @@ impl<'a, C, A> MyconfigReleaseDownloadAccesCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -10042,16 +10141,20 @@ impl<'a, C, A> MyconfigSyncVolumeLicenseCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -10296,16 +10399,20 @@ impl<'a, C, A> MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10408,7 +10515,7 @@ impl<'a, C, A> MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut MyconfigGetUserSettingCall<'a, C, A> where C: BorrowMut MyconfigUpdateUserSettingCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10738,16 +10849,20 @@ impl<'a, C, A> MylibraryBookshelveClearVolumeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -10973,16 +11088,20 @@ impl<'a, C, A> MylibraryBookshelveMoveVolumeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11255,16 +11374,20 @@ impl<'a, C, A> MylibraryBookshelveVolumeListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11518,16 +11641,20 @@ impl<'a, C, A> MylibraryAnnotationSummaryCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11763,16 +11890,20 @@ impl<'a, C, A> MylibraryAnnotationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -12001,16 +12132,20 @@ impl<'a, C, A> MylibraryBookshelveAddVolumeCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -12164,7 +12299,7 @@ impl<'a, C, A> MylibraryBookshelveAddVolumeCall<'a, C, A> where C: BorrowMut MylibraryAnnotationInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12510,16 +12649,20 @@ impl<'a, C, A> MylibraryBookshelveRemoveVolumeCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -12782,16 +12925,20 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12992,7 +13139,7 @@ impl<'a, C, A> MylibraryAnnotationListCall<'a, C, A> where C: BorrowMut MylibraryAnnotationUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13362,16 +13513,20 @@ impl<'a, C, A> MylibraryReadingpositionSetPositionCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -13635,16 +13790,20 @@ impl<'a, C, A> MylibraryBookshelveGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13851,16 +14010,20 @@ impl<'a, C, A> MylibraryBookshelveListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14088,16 +14251,20 @@ impl<'a, C, A> MylibraryReadingpositionGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14326,16 +14493,20 @@ impl<'a, C, A> CloudloadingAddBookCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -14492,7 +14663,7 @@ impl<'a, C, A> CloudloadingAddBookCall<'a, C, A> where C: BorrowMut CloudloadingUpdateBookCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14766,16 +14941,20 @@ impl<'a, C, A> CloudloadingDeleteBookCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) diff --git a/gen/calendar3-cli/Cargo.toml b/gen/calendar3-cli/Cargo.toml index fcee857d47..3c84c3f0ed 100644 --- a/gen/calendar3-cli/Cargo.toml +++ b/gen/calendar3-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-calendar3-cli" -version = "0.0.1+20150303" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/google-apps/calendar/firstapp" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/calendar3-cli/mkdocs.yml b/gen/calendar3-cli/mkdocs.yml index 5697e6a870..658196c492 100644 --- a/gen/calendar3-cli/mkdocs.yml +++ b/gen/calendar3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: calendar v0.0.1+20150303 +site_name: calendar v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/calendar3-cli/src/cmn.rs +++ b/gen/calendar3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/calendar3-cli/src/main.rs b/gen/calendar3-cli/src/main.rs index 9c795f6f67..2664fae3bf 100644 --- a/gen/calendar3-cli/src/main.rs +++ b/gen/calendar3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -68,6 +69,12 @@ Configuration: 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. "); mod cmn; @@ -91,7 +98,7 @@ impl Engine { -> Option { let mut call = self.hub.acl().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -122,7 +129,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -133,7 +139,7 @@ impl Engine { -> Option { let mut call = self.hub.acl().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -165,8 +171,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -175,10 +180,10 @@ impl Engine { fn _acl_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AclRule = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -198,9 +203,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -213,11 +219,11 @@ impl Engine { match &field_name.to_string()[..] { "scope.type" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "scope.value" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "kind" => { request_scope_init(&mut request); @@ -252,8 +258,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -264,7 +269,7 @@ impl Engine { -> Option { let mut call = self.hub.acl().list(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -308,8 +313,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -318,10 +322,10 @@ impl Engine { fn _acl_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AclRule = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -341,9 +345,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -356,11 +361,11 @@ impl Engine { match &field_name.to_string()[..] { "scope.type" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "scope.value" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "kind" => { request_scope_init(&mut request); @@ -395,8 +400,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -405,10 +409,10 @@ impl Engine { fn _acl_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AclRule = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -428,9 +432,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -443,11 +448,11 @@ impl Engine { match &field_name.to_string()[..] { "scope.type" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "scope.value" => { request_scope_init(&mut request); - request.scope.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.scope.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "kind" => { request_scope_init(&mut request); @@ -482,8 +487,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -492,10 +496,10 @@ impl Engine { fn _acl_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Channel = Default::default(); + let mut request = api::Channel::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -527,9 +531,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -551,9 +556,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -584,8 +590,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -596,7 +601,7 @@ impl Engine { -> Option { let mut call = self.hub.calendar_list().delete(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -627,7 +632,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -638,7 +642,7 @@ impl Engine { -> Option { let mut call = self.hub.calendar_list().get(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -670,8 +674,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -680,10 +683,10 @@ impl Engine { fn _calendar_list_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CalendarListEntry = Default::default(); + 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); + 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")); @@ -706,9 +709,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -778,8 +782,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -790,7 +793,7 @@ impl Engine { -> Option { let mut call = self.hub.calendar_list().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -840,8 +843,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -850,10 +852,10 @@ impl Engine { fn _calendar_list_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CalendarListEntry = Default::default(); + 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); + 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")); @@ -876,9 +878,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -948,8 +951,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -958,10 +960,10 @@ impl Engine { fn _calendar_list_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CalendarListEntry = Default::default(); + 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); + 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")); @@ -984,9 +986,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1056,8 +1059,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1066,10 +1068,10 @@ impl Engine { fn _calendar_list_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Channel = Default::default(); + let mut request = api::Channel::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -1107,9 +1109,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1131,9 +1134,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -1164,8 +1168,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1176,7 +1179,7 @@ impl Engine { -> Option { let mut call = self.hub.calendars().clear(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1207,7 +1210,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1218,7 +1220,7 @@ impl Engine { -> Option { let mut call = self.hub.calendars().delete(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1249,7 +1251,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1260,7 +1261,7 @@ impl Engine { -> Option { let mut call = self.hub.calendars().get(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1292,8 +1293,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1302,10 +1302,10 @@ impl Engine { fn _calendars_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Calendar = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1325,9 +1325,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1370,8 +1371,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1380,10 +1380,10 @@ impl Engine { fn _calendars_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Calendar = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1403,9 +1403,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1448,8 +1449,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1458,10 +1458,10 @@ impl Engine { fn _calendars_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Calendar = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1481,9 +1481,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1526,8 +1527,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1536,10 +1536,10 @@ impl Engine { fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Channel = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1559,9 +1559,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1583,9 +1584,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -1615,7 +1617,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1626,7 +1627,7 @@ impl Engine { -> Option { let mut call = self.hub.colors().get(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1658,8 +1659,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1670,7 +1670,7 @@ impl Engine { -> Option { let mut call = self.hub.events().delete(&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); + 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")); @@ -1704,7 +1704,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1715,7 +1714,7 @@ impl Engine { -> Option { let mut call = self.hub.events().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "time-zone" => { call = call.time_zone(value.unwrap_or("")); @@ -1756,8 +1755,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1766,10 +1764,10 @@ impl Engine { fn _events_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Event = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1789,9 +1787,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1852,43 +1851,51 @@ impl Engine { match &field_name.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); - request.extended_properties.as_mut().unwrap().shared.push(value.unwrap_or("").to_string()); + 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); - request.extended_properties.as_mut().unwrap().private.push(value.unwrap_or("").to_string()); + 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_ = arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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_ = arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_organizer_init(&mut request); @@ -1900,23 +1907,23 @@ impl Engine { }, "end.date" => { request_end_init(&mut request); - request.end.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "html-link" => { request_source_init(&mut request); @@ -1925,21 +1932,21 @@ impl Engine { "recurrence" => { request_source_init(&mut request); if request.recurrence.is_none() { - request.recurrence = Some(Default::default()); + request.recurrence = Some(Default::default()); } - request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start.date" => { request_start_init(&mut request); - request.start.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "etag" => { request_start_init(&mut request); @@ -1955,15 +1962,15 @@ impl Engine { }, "original-start-time.date" => { request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "status" => { request_original_start_time_init(&mut request); @@ -1983,35 +1990,39 @@ impl Engine { }, "gadget.preferences" => { request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().preferences.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer"); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer"); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); }, "end-time-unspecified" => { request_gadget_init(&mut request); @@ -2055,7 +2066,7 @@ impl Engine { }, "reminders.use-default" => { request_reminders_init(&mut request); - request.reminders.as_mut().unwrap().use_default = arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean"); + 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); @@ -2094,8 +2105,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2104,10 +2114,10 @@ impl Engine { fn _events_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Event = Default::default(); + let mut request = api::Event::default(); 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); + 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")); @@ -2133,9 +2143,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2196,43 +2207,51 @@ impl Engine { match &field_name.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); - request.extended_properties.as_mut().unwrap().shared.push(value.unwrap_or("").to_string()); + 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); - request.extended_properties.as_mut().unwrap().private.push(value.unwrap_or("").to_string()); + 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_ = arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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_ = arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_organizer_init(&mut request); @@ -2244,23 +2263,23 @@ impl Engine { }, "end.date" => { request_end_init(&mut request); - request.end.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "html-link" => { request_source_init(&mut request); @@ -2269,21 +2288,21 @@ impl Engine { "recurrence" => { request_source_init(&mut request); if request.recurrence.is_none() { - request.recurrence = Some(Default::default()); + request.recurrence = Some(Default::default()); } - request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start.date" => { request_start_init(&mut request); - request.start.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "etag" => { request_start_init(&mut request); @@ -2299,15 +2318,15 @@ impl Engine { }, "original-start-time.date" => { request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "status" => { request_original_start_time_init(&mut request); @@ -2327,35 +2346,39 @@ impl Engine { }, "gadget.preferences" => { request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().preferences.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer"); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer"); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); }, "end-time-unspecified" => { request_gadget_init(&mut request); @@ -2399,7 +2422,7 @@ impl Engine { }, "reminders.use-default" => { request_reminders_init(&mut request); - request.reminders.as_mut().unwrap().use_default = arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean"); + 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); @@ -2438,8 +2461,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2450,7 +2472,7 @@ impl Engine { -> Option { let mut call = self.hub.events().instances(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "time-zone" => { call = call.time_zone(value.unwrap_or("")); @@ -2509,8 +2531,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2521,7 +2542,7 @@ impl Engine { -> Option { let mut call = self.hub.events().list(&self.opt.arg_calendar_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "updated-min" => { call = call.updated_min(value.unwrap_or("")); @@ -2604,8 +2625,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2616,7 +2636,7 @@ impl Engine { -> Option { let mut call = self.hub.events().move_(&self.opt.arg_calendar_id, &self.opt.arg_event_id, &self.opt.arg_destination); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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")); @@ -2651,8 +2671,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2661,10 +2680,10 @@ impl Engine { fn _events_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Event = Default::default(); + 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); + 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")); @@ -2693,9 +2712,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2756,43 +2776,51 @@ impl Engine { match &field_name.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); - request.extended_properties.as_mut().unwrap().shared.push(value.unwrap_or("").to_string()); + 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); - request.extended_properties.as_mut().unwrap().private.push(value.unwrap_or("").to_string()); + 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_ = arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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_ = arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_organizer_init(&mut request); @@ -2804,23 +2832,23 @@ impl Engine { }, "end.date" => { request_end_init(&mut request); - request.end.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "html-link" => { request_source_init(&mut request); @@ -2829,21 +2857,21 @@ impl Engine { "recurrence" => { request_source_init(&mut request); if request.recurrence.is_none() { - request.recurrence = Some(Default::default()); + request.recurrence = Some(Default::default()); } - request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start.date" => { request_start_init(&mut request); - request.start.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "etag" => { request_start_init(&mut request); @@ -2859,15 +2887,15 @@ impl Engine { }, "original-start-time.date" => { request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "status" => { request_original_start_time_init(&mut request); @@ -2887,35 +2915,39 @@ impl Engine { }, "gadget.preferences" => { request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().preferences.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer"); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer"); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); }, "end-time-unspecified" => { request_gadget_init(&mut request); @@ -2959,7 +2991,7 @@ impl Engine { }, "reminders.use-default" => { request_reminders_init(&mut request); - request.reminders.as_mut().unwrap().use_default = arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean"); + 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); @@ -2998,8 +3030,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3010,7 +3041,7 @@ impl Engine { -> Option { let mut call = self.hub.events().quick_add(&self.opt.arg_calendar_id, &self.opt.arg_text); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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")); @@ -3045,8 +3076,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3055,10 +3085,10 @@ impl Engine { fn _events_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Event = Default::default(); + 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); + 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")); @@ -3087,9 +3117,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3150,43 +3181,51 @@ impl Engine { match &field_name.to_string()[..] { "extended-properties.shared" => { request_extended_properties_init(&mut request); - request.extended_properties.as_mut().unwrap().shared.push(value.unwrap_or("").to_string()); + 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); - request.extended_properties.as_mut().unwrap().private.push(value.unwrap_or("").to_string()); + 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_ = arg_from_str(value.unwrap_or("false"), err, "creator.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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_ = arg_from_str(value.unwrap_or("false"), err, "organizer.self", "boolean"); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.organizer.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "id" => { request_organizer_init(&mut request); @@ -3198,23 +3237,23 @@ impl Engine { }, "end.date" => { request_end_init(&mut request); - request.end.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.source.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "html-link" => { request_source_init(&mut request); @@ -3223,21 +3262,21 @@ impl Engine { "recurrence" => { request_source_init(&mut request); if request.recurrence.is_none() { - request.recurrence = Some(Default::default()); + request.recurrence = Some(Default::default()); } - request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.recurrence.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start.date" => { request_start_init(&mut request); - request.start.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.start.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "etag" => { request_start_init(&mut request); @@ -3253,15 +3292,15 @@ impl Engine { }, "original-start-time.date" => { request_original_start_time_init(&mut request); - request.original_start_time.as_mut().unwrap().date = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.original_start_time.as_mut().unwrap().date_time = Some(value.unwrap_or("").to_string()); }, "status" => { request_original_start_time_init(&mut request); @@ -3281,35 +3320,39 @@ impl Engine { }, "gadget.preferences" => { request_gadget_init(&mut request); - request.gadget.as_mut().unwrap().preferences.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.height", "integer"); + 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 = arg_from_str(value.unwrap_or("-0"), err, "gadget.width", "integer"); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.gadget.as_mut().unwrap().icon_link = Some(value.unwrap_or("").to_string()); }, "end-time-unspecified" => { request_gadget_init(&mut request); @@ -3353,7 +3396,7 @@ impl Engine { }, "reminders.use-default" => { request_reminders_init(&mut request); - request.reminders.as_mut().unwrap().use_default = arg_from_str(value.unwrap_or("false"), err, "reminders.use-default", "boolean"); + 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); @@ -3392,8 +3435,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3402,10 +3444,10 @@ impl Engine { fn _events_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Channel = Default::default(); + let mut request = api::Channel::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "updated-min" => { call = call.updated_min(value.unwrap_or("")); @@ -3476,9 +3518,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3500,9 +3543,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -3533,8 +3577,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3543,10 +3586,10 @@ impl Engine { fn _freebusy_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::FreeBusyRequest = Default::default(); + let mut request = api::FreeBusyRequest::default(); let mut call = self.hub.freebusy().query(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3566,9 +3609,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3605,8 +3649,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3617,7 +3660,7 @@ impl Engine { -> Option { let mut call = self.hub.settings().get(&self.opt.arg_setting); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3649,8 +3692,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3661,7 +3703,7 @@ impl Engine { -> Option { let mut call = self.hub.settings().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -3702,8 +3744,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3712,10 +3753,10 @@ impl Engine { fn _settings_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Channel = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sync-token" => { call = call.sync_token(value.unwrap_or("")); @@ -3744,9 +3785,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3768,9 +3810,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -3801,8 +3844,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3832,7 +3874,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_calendar_list { + } + else if self.opt.cmd_calendar_list { if self.opt.cmd_delete { call_result = self._calendar_list_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3850,7 +3893,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_calendars { + } + else if self.opt.cmd_calendars { if self.opt.cmd_clear { call_result = self._calendars_clear(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -3866,19 +3910,22 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_channels { + } + else if self.opt.cmd_channels { if self.opt.cmd_stop { call_result = self._channels_stop(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_colors { + } + else if self.opt.cmd_colors { if self.opt.cmd_get { call_result = self._colors_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_events { + } + else if self.opt.cmd_events { if self.opt.cmd_delete { call_result = self._events_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3904,13 +3951,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_freebusy { + } + else if self.opt.cmd_freebusy { if self.opt.cmd_query { call_result = self._freebusy_query(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_settings { + } + else if self.opt.cmd_settings { if self.opt.cmd_get { call_result = self._settings_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -3940,21 +3989,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "calendar3-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "calendar3-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "calendar3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "calendar3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::CalendarHub::new(hyper::Client::new(), auth), + hub: api::CalendarHub::new(client, auth), }; match engine._doit(true) { @@ -3974,12 +4039,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/calendar3/Cargo.toml b/gen/calendar3/Cargo.toml index 82f337ef24..f198c8b8e8 100644 --- a/gen/calendar3/Cargo.toml +++ b/gen/calendar3/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-calendar3" -version = "0.1.5+20150303" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/google-apps/calendar/firstapp" diff --git a/gen/calendar3/README.md b/gen/calendar3/README.md index 2f3010ad07..292a927f4f 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+20150303*, where *20150303* 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.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*. Everything else about the *calendar* *v3* API can be found at the [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). @@ -129,7 +129,7 @@ let mut hub = CalendarHub::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Channel = Default::default(); +let mut req = Channel::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/calendar3/src/cmn.rs b/gen/calendar3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/calendar3/src/cmn.rs +++ b/gen/calendar3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/calendar3/src/lib.rs b/gen/calendar3/src/lib.rs index 1ceb702dce..0481846a8d 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+20150303*, where *20150303* 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.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*. //! //! Everything else about the *calendar* *v3* API can be found at the //! [official documentation site](https://developers.google.com/google-apps/calendar/firstapp). @@ -130,7 +130,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Channel = Default::default(); +//! let mut req = Channel::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -326,7 +326,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -434,25 +434,25 @@ impl<'a, C, A> CalendarHub #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventGadget { /// Preferences. - pub preferences: HashMap, + pub preferences: Option>, /// The gadget's title. - pub title: String, + pub title: Option, /// The gadget's height in pixels. Optional. - pub height: i32, + pub height: Option, /// The gadget's width in pixels. Optional. - pub width: i32, + pub width: Option, /// The gadget's URL. - pub link: String, + pub link: Option, /// The gadget's type. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The gadget's display mode. Optional. Possible values are: /// - "icon" - The gadget displays next to the event's title in the calendar view. /// - "chip" - The gadget displays when the event is clicked. - pub display: String, + pub display: Option, /// The gadget's icon URL. #[serde(rename="iconLink")] - pub icon_link: String, + pub icon_link: Option, } impl NestedType for EventGadget {} @@ -466,9 +466,9 @@ impl Part for EventGadget {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FreeBusyCalendar { /// List of time ranges during which this calendar should be regarded as busy. - pub busy: Vec, + pub busy: Option>, /// Optional error(s) (if computation for the calendar failed). - pub errors: Vec, + pub errors: Option>, } impl Part for FreeBusyCalendar {} @@ -486,9 +486,9 @@ pub struct AclRuleScope { /// - "group" - Limits the scope to a group. /// - "domain" - Limits the scope to a domain. Note: The permissions granted to the "default", or public, scope apply to any user, authenticated or not. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The email address of a user or group, or the name of a domain, depending on the scope type. Omitted for type "default". - pub value: String, + pub value: Option, } impl NestedType for AclRuleScope {} @@ -508,16 +508,16 @@ impl Part for AclRuleScope {} pub struct Settings { /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// List of user settings. - pub items: Vec, + pub items: Option>, /// Type of the collection ("calendar#settings"). - pub kind: String, + pub kind: Option, /// Etag of the collection. - pub etag: String, + pub etag: Option, /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided. #[serde(rename="nextSyncToken")] - pub next_sync_token: String, + pub next_sync_token: Option, } impl ResponseResult for Settings {} @@ -636,7 +636,7 @@ impl ResponseResult for CalendarListEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CalendarListEntryNotificationSettings { /// The list of notifications set for this calendar. - pub notifications: Vec, + pub notifications: Option>, } impl NestedType for CalendarListEntryNotificationSettings {} @@ -650,9 +650,9 @@ impl Part for CalendarListEntryNotificationSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ColorDefinition { /// The foreground color that can be used to write on top of a background with 'background' color. - pub foreground: String, + pub foreground: Option, /// The background color associated with this color definition. - pub background: String, + pub background: Option, } impl Part for ColorDefinition {} @@ -665,13 +665,13 @@ impl Part for ColorDefinition {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventDateTime { /// The date, in the format "yyyy-mm-dd", if this is an all-day event. - pub date: String, + pub date: Option, /// The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end. #[serde(rename="timeZone")] - pub time_zone: String, + pub time_zone: Option, /// The time, as a combined date-time value (formatted according to RFC 3339). A time zone offset is required unless a time zone is explicitly specified in timeZone. #[serde(rename="dateTime")] - pub date_time: String, + pub date_time: Option, } impl Part for EventDateTime {} @@ -691,13 +691,13 @@ impl Part for EventDateTime {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Setting { /// Type of the resource ("calendar#setting"). - pub kind: String, + pub kind: Option, /// ETag of the resource. - pub etag: String, + pub etag: Option, /// The id of the user setting. - pub id: String, + pub id: Option, /// Value of the user setting. The format of the value depends on the ID of the setting. It must always be a UTF-8 string of length up to 1024 characters. - pub value: String, + pub value: Option, } impl Resource for Setting {} @@ -712,14 +712,14 @@ impl ResponseResult for Setting {} pub struct EventCreator { /// Whether the creator corresponds to the calendar on which this copy of the event appears. Read-only. The default is False. #[serde(rename="self")] - pub self_: bool, + pub self_: Option, /// The creator's name, if available. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The creator's email address, if available. - pub email: String, + pub email: Option, /// The creator's Profile ID, if available. - pub id: String, + pub id: Option, } impl NestedType for EventCreator {} @@ -733,13 +733,13 @@ impl Part for EventCreator {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ErrorType { /// Domain, or broad category, of the error. - pub domain: String, + pub domain: Option, /// Specific reason for the error. Some of the possible values are: /// - "groupTooBig" - The group of users requested is too large for a single query. /// - "tooManyCalendarsRequested" - The number of calendars requested is too large for a single query. /// - "notFound" - The requested resource was not found. /// - "internalError" - The API service has encountered an internal error. Additional error types may be added in the future, so clients should gracefully handle additional error statuses not included in this list. - pub reason: String, + pub reason: Option, } impl Part for ErrorType {} @@ -793,16 +793,16 @@ impl ResponseResult for AclRule {} pub struct Acl { /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// List of rules on the access control list. - pub items: Vec, + pub items: Option>, /// Type of the collection ("calendar#acl"). - pub kind: String, + pub kind: Option, /// ETag of the collection. - pub etag: String, + pub etag: Option, /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided. #[serde(rename="nextSyncToken")] - pub next_sync_token: String, + pub next_sync_token: Option, } impl ResponseResult for Acl {} @@ -822,28 +822,28 @@ impl ResponseResult for Acl {} pub struct Events { /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Type of the collection ("calendar#events"). - pub kind: String, + pub kind: Option, /// The default reminders on the calendar for the authenticated user. These reminders apply to all events on this calendar that do not explicitly override them (i.e. do not have reminders.useDefault set to True). #[serde(rename="defaultReminders")] - pub default_reminders: Vec, + pub default_reminders: Option>, /// Description of the calendar. Read-only. - pub description: String, + pub description: Option, /// List of events on the calendar. - pub items: Vec, + pub items: Option>, /// Last modification time of the calendar (as a RFC 3339 timestamp). Read-only. - pub updated: String, + pub updated: Option, /// Title of the calendar. Read-only. - pub summary: String, + pub summary: Option, /// ETag of the collection. - pub etag: String, + pub etag: Option, /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided. #[serde(rename="nextSyncToken")] - pub next_sync_token: String, + pub next_sync_token: Option, /// The time zone of the calendar. Read-only. #[serde(rename="timeZone")] - pub time_zone: String, + pub time_zone: Option, /// The user's access role for this calendar. Read-only. Possible values are: /// - "none" - The user has no access. /// - "freeBusyReader" - The user has read access to free/busy information. @@ -851,7 +851,7 @@ pub struct Events { /// - "writer" - The user has read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible. /// - "owner" - The user has ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs. #[serde(rename="accessRole")] - pub access_role: String, + pub access_role: Option, } impl ResponseResult for Events {} @@ -909,33 +909,33 @@ impl ResponseResult for Channel {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventAttendee { /// The attendee's response comment. Optional. - pub comment: String, + pub comment: Option, /// The attendee's name, if available. Optional. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// Whether this entry represents the calendar on which this copy of the event appears. Read-only. The default is False. #[serde(rename="self")] - pub self_: bool, + pub self_: Option, /// The attendee's email address, if available. This field must be present when adding an attendee. - pub email: String, + pub email: Option, /// The attendee's Profile ID, if available. - pub id: String, + pub id: Option, /// Number of additional guests. Optional. The default is 0. #[serde(rename="additionalGuests")] - pub additional_guests: i32, + pub additional_guests: Option, /// Whether the attendee is a resource. Read-only. The default is False. - pub resource: bool, + pub resource: Option, /// Whether the attendee is the organizer of the event. Read-only. The default is False. - pub organizer: bool, + pub organizer: Option, /// Whether this is an optional attendee. Optional. The default is False. - pub optional: bool, + pub optional: Option, /// The attendee's response status. Possible values are: /// - "needsAction" - The attendee has not responded to the invitation. /// - "declined" - The attendee has declined the invitation. /// - "tentative" - The attendee has tentatively accepted the invitation. /// - "accepted" - The attendee has accepted the invitation. #[serde(rename="responseStatus")] - pub response_status: String, + pub response_status: Option, } impl Part for EventAttendee {} @@ -948,9 +948,9 @@ impl Part for EventAttendee {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FreeBusyGroup { /// Optional error(s) (if computation for the group failed). - pub errors: Vec, + pub errors: Option>, /// List of calendars' identifiers within a group. - pub calendars: Vec, + pub calendars: Option>, } impl Part for FreeBusyGroup {} @@ -963,10 +963,10 @@ impl Part for FreeBusyGroup {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventReminders { /// If the event doesn't use the default reminders, this lists the reminders specific to the event, or, if not set, indicates that no reminders are set for this event. - pub overrides: Vec, + pub overrides: Option>, /// Whether the default reminders of the calendar apply to the event. #[serde(rename="useDefault")] - pub use_default: bool, + pub use_default: Option, } impl NestedType for EventReminders {} @@ -986,16 +986,16 @@ impl Part for EventReminders {} pub struct CalendarList { /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Calendars that are present on the user's calendar list. - pub items: Vec, + pub items: Option>, /// Type of the collection ("calendar#calendarList"). - pub kind: String, + pub kind: Option, /// ETag of the collection. - pub etag: String, + pub etag: Option, /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided. #[serde(rename="nextSyncToken")] - pub next_sync_token: String, + pub next_sync_token: Option, } impl ResponseResult for CalendarList {} @@ -1008,9 +1008,9 @@ impl ResponseResult for CalendarList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventExtendedProperties { /// Properties that are shared between copies of the event on other attendees' calendars. - pub shared: HashMap, + pub shared: Option>, /// Properties that are private to the copy of the event that appears on this calendar. - pub private: HashMap, + pub private: Option>, } impl NestedType for EventExtendedProperties {} @@ -1024,7 +1024,7 @@ impl Part for EventExtendedProperties {} #[derive(Default, Clone, Debug, Serialize)] pub struct FreeBusyRequestItem { /// The identifier of a calendar or a group. - pub id: String, + pub id: Option, } impl Part for FreeBusyRequestItem {} @@ -1043,16 +1043,16 @@ impl Part for FreeBusyRequestItem {} pub struct FreeBusyResponse { /// The end of the interval. #[serde(rename="timeMax")] - pub time_max: String, + pub time_max: Option, /// Type of the resource ("calendar#freeBusy"). - pub kind: String, + pub kind: Option, /// List of free/busy information for calendars. - pub calendars: HashMap, + pub calendars: Option>, /// Expansion of groups. - pub groups: HashMap, + pub groups: Option>, /// The start of the interval. #[serde(rename="timeMin")] - pub time_min: String, + pub time_min: Option, } impl ResponseResult for FreeBusyResponse {} @@ -1070,13 +1070,13 @@ impl ResponseResult for FreeBusyResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Colors { /// Palette of calendar colors, mapping from the color ID to its definition. A calendarListEntry resource refers to one of these color IDs in its color field. Read-only. - pub calendar: HashMap, + pub calendar: Option>, /// Last modification time of the color palette (as a RFC 3339 timestamp). Read-only. - pub updated: String, + pub updated: Option, /// Type of the resource ("calendar#colors"). - pub kind: String, + pub kind: Option, /// Palette of event colors, mapping from the color ID to its definition. An event resource may refer to one of these color IDs in its color field. Read-only. - pub event: HashMap, + pub event: Option>, } impl ResponseResult for Colors {} @@ -1122,9 +1122,9 @@ impl RequestValue for FreeBusyRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventSource { /// URL of the source pointing to a resource. URL's protocol must be HTTP or HTTPS. - pub url: String, + pub url: Option, /// Title of the source; for example a title of a web page or an email subject. - pub title: String, + pub title: Option, } impl NestedType for EventSource {} @@ -1139,14 +1139,14 @@ impl Part for EventSource {} pub struct EventOrganizer { /// Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False. #[serde(rename="self")] - pub self_: bool, + pub self_: Option, /// The organizer's name, if available. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option, /// The organizer's email address, if available. - pub email: String, + pub email: Option, /// The organizer's Profile ID, if available. - pub id: String, + pub id: Option, } impl NestedType for EventOrganizer {} @@ -1160,12 +1160,12 @@ impl Part for EventOrganizer {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventReminder { /// Number of minutes before the start of the event when the reminder should trigger. - pub minutes: i32, + pub minutes: Option, /// The method used by this reminder. Possible values are: /// - "email" - Reminders are sent via email. /// - "sms" - Reminders are sent via SMS. /// - "popup" - Reminders are sent via a UI popup. - pub method: String, + pub method: Option, } impl Part for EventReminder {} @@ -1178,9 +1178,9 @@ impl Part for EventReminder {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TimePeriod { /// The (inclusive) start of the time period. - pub start: String, + pub start: Option, /// The (exclusive) end of the time period. - pub end: String, + pub end: Option, } impl Part for TimePeriod {} @@ -1199,11 +1199,11 @@ pub struct CalendarNotification { /// - "eventResponse" - Notification sent when an event is changed. /// - "agenda" - An agenda with the events of the day (sent out in the morning). #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The method used to deliver the notification. Possible values are: /// - "email" - Reminders are sent via email. /// - "sms" - Reminders are sent via SMS. This value is read-only and is ignored on inserts and updates. - pub method: String, + pub method: Option, } impl Part for CalendarNotification {} @@ -2451,7 +2451,7 @@ impl<'a, C, A> EventMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FreeBusyRequest = Default::default(); +/// let mut req = FreeBusyRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2517,16 +2517,20 @@ impl<'a, C, A> FreebusyQueryCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2739,16 +2743,20 @@ impl<'a, C, A> SettingListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2902,7 +2910,7 @@ impl<'a, C, A> SettingListCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2983,16 +2991,20 @@ impl<'a, C, A> SettingWatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3240,16 +3252,20 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3389,7 +3405,7 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CalendarListEntry = Default::default(); +/// let mut req = CalendarListEntry::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3486,16 +3502,20 @@ impl<'a, C, A> CalendarListUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3735,16 +3755,20 @@ impl<'a, C, A> CalendarListDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3955,16 +3979,20 @@ impl<'a, C, A> CalendarListGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4189,16 +4217,20 @@ impl<'a, C, A> CalendarListListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4374,7 +4406,7 @@ impl<'a, C, A> CalendarListListCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CalendarListEntry = Default::default(); +/// let mut req = CalendarListEntry::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4445,16 +4477,20 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4604,7 +4640,7 @@ impl<'a, C, A> CalendarListInsertCall<'a, C, A> where C: BorrowMut CalendarListPatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4870,7 +4910,7 @@ impl<'a, C, A> CalendarListPatchCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4966,16 +5006,20 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5164,7 +5208,7 @@ impl<'a, C, A> CalendarListWatchCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Calendar = Default::default(); +/// let mut req = Calendar::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5256,16 +5300,20 @@ impl<'a, C, A> CalendarPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5498,16 +5546,20 @@ impl<'a, C, A> CalendarDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5718,16 +5770,20 @@ impl<'a, C, A> CalendarGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5947,16 +6003,20 @@ impl<'a, C, A> CalendarClearCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6086,7 +6146,7 @@ impl<'a, C, A> CalendarClearCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Calendar = Default::default(); +/// let mut req = Calendar::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6152,16 +6212,20 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6304,7 +6368,7 @@ impl<'a, C, A> CalendarInsertCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Calendar = Default::default(); +/// let mut req = Calendar::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6396,16 +6460,20 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6558,7 +6626,7 @@ impl<'a, C, A> CalendarUpdateCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6670,16 +6738,20 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6863,7 +6935,7 @@ impl<'a, C, A> AclWatchCall<'a, C, A> where C: BorrowMut, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AclRule = Default::default(); +/// let mut req = AclRule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6955,16 +7027,20 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7117,7 +7193,7 @@ impl<'a, C, A> AclInsertCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AclRule = Default::default(); +/// let mut req = AclRule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7211,16 +7287,20 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7383,7 +7463,7 @@ impl<'a, C, A> AclUpdateCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AclRule = Default::default(); +/// let mut req = AclRule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7477,16 +7557,20 @@ impl<'a, C, A> AclPatchCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7750,16 +7834,20 @@ impl<'a, C, A> AclListCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8012,16 +8100,20 @@ impl<'a, C, A> AclDeleteCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8244,16 +8336,20 @@ impl<'a, C, A> AclGetCall<'a, C, A> where C: BorrowMut, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8403,7 +8499,7 @@ impl<'a, C, A> AclGetCall<'a, C, A> where C: BorrowMut, A: oauth2 /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8468,16 +8564,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8665,16 +8765,20 @@ impl<'a, C, A> ColorGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8891,16 +8995,20 @@ impl<'a, C, A> EventDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -9047,7 +9155,7 @@ impl<'a, C, A> EventDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Event = Default::default(); +/// let mut req = Event::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9149,16 +9257,20 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9325,7 +9437,7 @@ impl<'a, C, A> EventInsertCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Event = Default::default(); +/// let mut req = Event::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9417,16 +9529,20 @@ impl<'a, C, A> EventImportCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9707,16 +9823,20 @@ impl<'a, C, A> EventInstanceCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10027,16 +10147,20 @@ impl<'a, C, A> EventGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10381,16 +10505,20 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10664,7 +10792,7 @@ impl<'a, C, A> EventListCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Event = Default::default(); +/// let mut req = Event::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10773,16 +10901,20 @@ impl<'a, C, A> EventPatchCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11056,16 +11188,20 @@ impl<'a, C, A> EventMoveCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11232,7 +11368,7 @@ impl<'a, C, A> EventMoveCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Event = Default::default(); +/// let mut req = Event::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11341,16 +11477,20 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11534,7 +11674,7 @@ impl<'a, C, A> EventUpdateCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11719,16 +11859,20 @@ impl<'a, C, A> EventWatchCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12103,16 +12247,20 @@ impl<'a, C, A> EventQuickAddCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) diff --git a/gen/civicinfo2-cli/Cargo.toml b/gen/civicinfo2-cli/Cargo.toml index e8037df1f0..e22288896c 100644 --- a/gen/civicinfo2-cli/Cargo.toml +++ b/gen/civicinfo2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-civicinfo2-cli" version = "0.0.1+20150302" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/civic-information" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/civicinfo2-cli/src/cmn.rs b/gen/civicinfo2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/civicinfo2-cli/src/cmn.rs +++ b/gen/civicinfo2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/civicinfo2-cli/src/main.rs b/gen/civicinfo2-cli/src/main.rs index 3616811488..d59d8c521d 100644 --- a/gen/civicinfo2-cli/src/main.rs +++ b/gen/civicinfo2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -32,6 +33,12 @@ Configuration: 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. "); mod cmn; @@ -55,7 +62,7 @@ impl Engine { -> Option { let mut call = self.hub.divisions().search(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "query" => { call = call.query(value.unwrap_or("")); @@ -90,8 +97,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -102,7 +108,7 @@ impl Engine { -> Option { let mut call = self.hub.elections().election_query(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -134,8 +140,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -146,7 +151,7 @@ impl Engine { -> Option { let mut call = self.hub.elections().voter_info_query(&self.opt.arg_address); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "official-only" => { call = call.official_only(arg_from_str(value.unwrap_or("false"), err, "official-only", "boolean")); @@ -184,8 +189,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -196,7 +200,7 @@ impl Engine { -> Option { let mut call = self.hub.representatives().representative_info_by_address(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "roles" => { call = call.add_roles(value.unwrap_or("")); @@ -240,8 +244,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -252,7 +255,7 @@ impl Engine { -> Option { let mut call = self.hub.representatives().representative_info_by_division(&self.opt.arg_ocd_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "roles" => { call = call.add_roles(value.unwrap_or("")); @@ -293,8 +296,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -312,7 +314,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_elections { + } + else if self.opt.cmd_elections { if self.opt.cmd_election_query { call_result = self._elections_election_query(dry_run, &mut err); } else if self.opt.cmd_voter_info_query { @@ -320,7 +323,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_representatives { + } + else if self.opt.cmd_representatives { if self.opt.cmd_representative_info_by_address { call_result = self._representatives_representative_info_by_address(dry_run, &mut err); } else if self.opt.cmd_representative_info_by_division { @@ -348,21 +352,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "civicinfo2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "civicinfo2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "civicinfo2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "civicinfo2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::CivicInfo::new(hyper::Client::new(), auth), + hub: api::CivicInfo::new(client, auth), }; match engine._doit(true) { @@ -382,12 +402,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/civicinfo2/Cargo.toml b/gen/civicinfo2/Cargo.toml index 8635b5cb81..f947972afa 100644 --- a/gen/civicinfo2/Cargo.toml +++ b/gen/civicinfo2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-civicinfo2" version = "0.1.5+20150302" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/civic-information" diff --git a/gen/civicinfo2/src/cmn.rs b/gen/civicinfo2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/civicinfo2/src/cmn.rs +++ b/gen/civicinfo2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/civicinfo2/src/lib.rs b/gen/civicinfo2/src/lib.rs index 9a4cd3b286..ef05e5cab3 100644 --- a/gen/civicinfo2/src/lib.rs +++ b/gen/civicinfo2/src/lib.rs @@ -321,15 +321,15 @@ impl<'a, C, A> CivicInfo pub struct AdministrationRegion { /// The election administration body for this area. #[serde(rename="electionAdministrationBody")] - pub election_administration_body: AdministrativeBody, + pub election_administration_body: Option, /// The city or county that provides election information for this voter. This object can have the same elements as state. - pub local_jurisdiction: Option>, + pub local_jurisdiction: Option>>, /// An ID for this object. IDs may change in future requests and should not be cached. Access to this field requires special access that can be requested from the Request more link on the Quotas page. - pub id: String, + pub id: Option, /// The name of the jurisdiction. - pub name: String, + pub name: Option, /// A list of sources for this area. If multiple sources are listed the data has been aggregated from those sources. - pub sources: Vec, + pub sources: Option>, } impl Part for AdministrationRegion {} @@ -342,22 +342,22 @@ impl Part for AdministrationRegion {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Official { /// The official's name. - pub name: String, + pub name: Option, /// A URL for a photo of the official. #[serde(rename="photoUrl")] - pub photo_url: String, + pub photo_url: Option, /// The official's public contact phone numbers. - pub phones: Vec, + pub phones: Option>, /// A list of known (social) media channels for this official. - pub channels: Vec, + pub channels: Option>, /// The official's public website URLs. - pub urls: Vec, + pub urls: Option>, /// Addresses at which to contact the official. - pub address: Vec, + pub address: Option>, /// The full name of the party the official belongs to. - pub party: String, + pub party: Option, /// The direct email addresses for the official. - pub emails: Vec, + pub emails: Option>, } impl Part for Official {} @@ -370,11 +370,11 @@ impl Part for Official {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ElectoralDistrict { /// The geographic scope of this district. If unspecified the district's geography is not known. One of: national, statewide, congressional, stateUpper, stateLower, countywide, judicial, schoolBoard, cityWide, township, countyCouncil, cityCouncil, ward, special - pub scope: String, + pub scope: Option, /// An identifier for this district, relative to its scope. For example, the 34th State Senate district would have id "34" and a scope of stateUpper. - pub id: String, + pub id: Option, /// The name of the district. - pub name: String, + pub name: Option, } impl Part for ElectoralDistrict {} @@ -392,9 +392,9 @@ impl Part for ElectoralDistrict {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DivisionSearchResponse { /// Identifies what kind of resource this is. Value: the fixed string "civicinfo#divisionSearchResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub results: Vec, + pub results: Option>, } impl ResponseResult for DivisionSearchResponse {} @@ -407,24 +407,24 @@ impl ResponseResult for DivisionSearchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Candidate { /// The candidate's name. - pub name: String, + pub name: Option, /// A URL for a photo of the candidate. #[serde(rename="photoUrl")] - pub photo_url: String, + pub photo_url: Option, /// The URL for the candidate's campaign web site. #[serde(rename="candidateUrl")] - pub candidate_url: String, + pub candidate_url: Option, /// A list of known (social) media channels for this candidate. - pub channels: Vec, + pub channels: Option>, /// The voice phone number for the candidate's campaign office. - pub phone: String, + pub phone: Option, /// The order the candidate appears on the ballot for this contest. #[serde(rename="orderOnBallot")] - pub order_on_ballot: String, + pub order_on_ballot: Option, /// The full name of the party the candidate is a member of. - pub party: String, + pub party: Option, /// The email address for the candidate's campaign. - pub email: String, + pub email: Option, } impl Part for Candidate {} @@ -437,48 +437,48 @@ impl Part for Candidate {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Contest { /// The name of the office for this contest. - pub office: String, + pub office: Option, /// A list of sources for this contest. If multiple sources are listed, the data has been aggregated from those sources. - pub sources: Vec, + pub sources: Option>, /// If this is a partisan election, the name of the party it is for. #[serde(rename="primaryParty")] - pub primary_party: String, + pub primary_party: Option, /// A description of any additional eligibility requirements for voting in this contest. #[serde(rename="electorateSpecifications")] - pub electorate_specifications: String, + pub electorate_specifications: Option, /// The number of candidates that will be elected to office in this contest. #[serde(rename="numberElected")] - pub number_elected: String, + pub number_elected: Option, /// A link to the referendum. This field is only populated for contests of type 'Referendum'. #[serde(rename="referendumUrl")] - pub referendum_url: String, + pub referendum_url: Option, /// The title of the referendum (e.g. 'Proposition 42'). This field is only populated for contests of type 'Referendum'. #[serde(rename="referendumTitle")] - pub referendum_title: String, + pub referendum_title: Option, /// An ID for this object. IDs may change in future requests and should not be cached. Access to this field requires special access that can be requested from the Request more link on the Quotas page. - pub id: String, + pub id: Option, /// "Yes" or "No" depending on whether this a contest being held outside the normal election cycle. - pub special: String, + pub special: Option, /// The number of candidates that a voter may vote for in this contest. #[serde(rename="numberVotingFor")] - pub number_voting_for: String, + pub number_voting_for: Option, /// Information about the electoral district that this contest is in. - pub district: ElectoralDistrict, + pub district: Option, /// The roles which this office fulfills. - pub roles: Vec, + pub roles: Option>, /// The levels of government of the office for this contest. There may be more than one in cases where a jurisdiction effectively acts at two different levels of government; for example, the mayor of the District of Columbia acts at "locality" level, but also effectively at both "administrative-area-2" and "administrative-area-1". - pub level: Vec, + pub level: Option>, /// A number specifying the position of this contest on the voter's ballot. #[serde(rename="ballotPlacement")] - pub ballot_placement: String, + pub ballot_placement: Option, /// A brief description of the referendum. This field is only populated for contests of type 'Referendum'. #[serde(rename="referendumSubtitle")] - pub referendum_subtitle: String, + pub referendum_subtitle: Option, /// The candidate choices for this contest. - pub candidates: Vec, + pub candidates: Option>, /// The type of contest. Usually this will be 'General', 'Primary', or 'Run-off' for contests with candidates. For referenda this will be 'Referendum'. #[serde(rename="type")] - pub type_: String, + pub type_: Option, } impl Part for Contest {} @@ -496,9 +496,9 @@ impl Part for Contest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ElectionsQueryResponse { /// Identifies what kind of resource this is. Value: the fixed string "civicinfo#electionsQueryResponse". - pub kind: String, + pub kind: Option, /// A list of available elections - pub elections: Vec, + pub elections: Option>, } impl ResponseResult for ElectionsQueryResponse {} @@ -516,16 +516,16 @@ impl ResponseResult for ElectionsQueryResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RepresentativeInfoResponse { /// Political geographic divisions that contain the requested address. - pub divisions: HashMap, + pub divisions: Option>, /// Identifies what kind of resource this is. Value: the fixed string "civicinfo#representativeInfoResponse". - pub kind: String, + pub kind: Option, /// Officials holding the offices listed above. Will only be present if includeOffices was true in the request. - pub officials: Vec, + pub officials: Option>, /// Elected offices referenced by the divisions listed above. Will only be present if includeOffices was true in the request. - pub offices: Vec, + pub offices: Option>, /// The normalized version of the requested address #[serde(rename="normalizedInput")] - pub normalized_input: SimpleAddressType, + pub normalized_input: Option, } impl ResponseResult for RepresentativeInfoResponse {} @@ -538,9 +538,9 @@ impl ResponseResult for RepresentativeInfoResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Source { /// Whether this data comes from an official government source. - pub official: bool, + pub official: Option, /// The name of the data source. - pub name: String, + pub name: Option, } impl Part for Source {} @@ -554,17 +554,17 @@ impl Part for Source {} pub struct ElectionOfficial { /// The fax number of the election official. #[serde(rename="faxNumber")] - pub fax_number: String, + pub fax_number: Option, /// The email address of the election official. #[serde(rename="emailAddress")] - pub email_address: String, + pub email_address: Option, /// The full name of the election official. - pub name: String, + pub name: Option, /// The office phone number of the election official. #[serde(rename="officePhoneNumber")] - pub office_phone_number: String, + pub office_phone_number: Option, /// The title of the election official. - pub title: String, + pub title: Option, } impl Part for ElectionOfficial {} @@ -578,41 +578,41 @@ impl Part for ElectionOfficial {} pub struct AdministrativeBody { /// A URL provided by this administrative body for information on absentee voting. #[serde(rename="absenteeVotingInfoUrl")] - pub absentee_voting_info_url: String, + pub absentee_voting_info_url: Option, /// A URL provided by this administrative body for looking up where to vote. #[serde(rename="votingLocationFinderUrl")] - pub voting_location_finder_url: String, + pub voting_location_finder_url: Option, /// The name of this election administrative body. - pub name: String, + pub name: Option, /// A URL provided by this administrative body for confirming that the voter is registered to vote. #[serde(rename="electionRegistrationConfirmationUrl")] - pub election_registration_confirmation_url: String, + pub election_registration_confirmation_url: Option, /// A URL provided by this administrative body for looking up general election information. #[serde(rename="electionInfoUrl")] - pub election_info_url: String, + pub election_info_url: Option, /// A URL provided by this administrative body for looking up how to register to vote. #[serde(rename="electionRegistrationUrl")] - pub election_registration_url: String, + pub election_registration_url: Option, /// The election officials for this election administrative body. #[serde(rename="electionOfficials")] - pub election_officials: Vec, + pub election_officials: Option>, /// The mailing address of this administrative body. #[serde(rename="correspondenceAddress")] - pub correspondence_address: SimpleAddressType, + pub correspondence_address: Option, /// A URL provided by this administrative body describing election rules to the voter. #[serde(rename="electionRulesUrl")] - pub election_rules_url: String, + pub election_rules_url: Option, /// A description of the services this administrative body may provide. - pub voter_services: Vec, + pub voter_services: Option>, /// A URL provided by this administrative body to give contest information to the voter. #[serde(rename="ballotInfoUrl")] - pub ballot_info_url: String, + pub ballot_info_url: Option, /// A description of the hours of operation for this administrative body. #[serde(rename="hoursOfOperation")] - pub hours_of_operation: String, + pub hours_of_operation: Option, /// The physical address of this administrative body. #[serde(rename="physicalAddress")] - pub physical_address: SimpleAddressType, + pub physical_address: Option, } impl Part for AdministrativeBody {} @@ -626,9 +626,9 @@ impl Part for AdministrativeBody {} pub struct Channel { /// The type of channel. The following is a list of types of channels, but is not exhaustive. More channel types may be added at a later time. One of: GooglePlus, YouTube, Facebook, Twitter #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The unique public identifier for the candidate's channel. - pub id: String, + pub id: Option, } impl Part for Channel {} @@ -641,19 +641,19 @@ impl Part for Channel {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Office { /// A list of sources for this office. If multiple sources are listed, the data has been aggregated from those sources. - pub sources: Vec, + pub sources: Option>, /// The levels of government of which this office is part. There may be more than one in cases where a jurisdiction effectively acts at two different levels of government; for example, the mayor of the District of Columbia acts at "locality" level, but also effectively at both "administrative-area-2" and "administrative-area-1". - pub levels: Vec, + pub levels: Option>, /// The human-readable name of the office. - pub name: String, + pub name: Option, /// The roles which this office fulfills. Roles are not meant to be exhaustive, or to exactly specify the entire set of responsibilities of a given office, but are meant to be rough categories that are useful for general selection from or sorting of a list of offices. - pub roles: Vec, + pub roles: Option>, /// The OCD ID of the division with which this office is associated. #[serde(rename="divisionId")] - pub division_id: String, + pub division_id: Option, /// List of indices in the officials array of people who presently hold this office. #[serde(rename="officialIndices")] - pub official_indices: Vec, + pub official_indices: Option>, } impl Part for Office {} @@ -667,11 +667,11 @@ impl Part for Office {} pub struct DivisionSearchResult { /// The unique Open Civic Data identifier for this division. #[serde(rename="ocdId")] - pub ocd_id: String, + pub ocd_id: Option, /// The name of the division. - pub name: String, + pub name: Option, /// Other Open Civic Data identifiers that refer to the same division -- for example, those that refer to other political divisions whose boundaries are defined to be coterminous with this one. For example, ocd-division/country:us/state:wy will include an alias of ocd-division/country:us/state:wy/cd:1, since Wyoming has only one Congressional district. - pub aliases: Vec, + pub aliases: Option>, } impl Part for DivisionSearchResult {} @@ -685,19 +685,19 @@ impl Part for DivisionSearchResult {} pub struct SimpleAddressType { /// The name of the location. #[serde(rename="locationName")] - pub location_name: String, + pub location_name: Option, /// The city or town for the address. - pub city: String, + pub city: Option, /// The US two letter state abbreviation of the address. - pub state: String, + pub state: Option, /// The US Postal Zip Code of the address. - pub zip: String, + pub zip: Option, /// The third line of the address, if needed. - pub line3: String, + pub line3: Option, /// The second line the address, if needed. - pub line2: String, + pub line2: Option, /// The street name and number of this address. - pub line1: String, + pub line1: Option, } impl Part for SimpleAddressType {} @@ -711,16 +711,16 @@ impl Part for SimpleAddressType {} pub struct GeographicDivision { /// List of indices in the offices array, one for each office elected from this division. Will only be present if includeOffices was true (or absent) in the request. #[serde(rename="officeIndices")] - pub office_indices: Vec, + pub office_indices: Option>, /// Any other valid OCD IDs that refer to the same division. /// /// Because OCD IDs are meant to be human-readable and at least somewhat predictable, there are occasionally several identifiers for a single division. These identifiers are defined to be equivalent to one another, and one is always indicated as the primary identifier. The primary identifier will be returned in ocd_id above, and any other equivalent valid identifiers will be returned in this list. /// /// For example, if this division's OCD ID is ocd-division/country:us/district:dc, this will contain ocd-division/country:us/state:dc. #[serde(rename="alsoKnownAs")] - pub also_known_as: Vec, + pub also_known_as: Option>, /// The name of the division. - pub name: String, + pub name: Option, } impl Part for GeographicDivision {} @@ -734,26 +734,26 @@ impl Part for GeographicDivision {} pub struct PollingLocation { /// The first date that this early vote site or drop off location may be used. This field is not populated for polling locations. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option, /// A description of when this location is open. #[serde(rename="pollingHours")] - pub polling_hours: String, + pub polling_hours: Option, /// The last date that this early vote site or drop off location may be used. This field is not populated for polling locations. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option, /// The name of the early vote site or drop off location. This field is not populated for polling locations. - pub name: String, + pub name: Option, /// Notes about this location (e.g. accessibility ramp or entrance to use). - pub notes: String, + pub notes: Option, /// The address of the location. - pub address: SimpleAddressType, + pub address: Option, /// A list of sources for this location. If multiple sources are listed the data has been aggregated from those sources. - pub sources: Vec, + pub sources: Option>, /// The services provided by this early vote site or drop off location. This field is not populated for polling locations. #[serde(rename="voterServices")] - pub voter_services: String, + pub voter_services: Option, /// An ID for this object. IDs may change in future requests and should not be cached. Access to this field requires special access that can be requested from the Request more link on the Quotas page. - pub id: String, + pub id: Option, } impl Part for PollingLocation {} @@ -771,11 +771,11 @@ impl Part for PollingLocation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RepresentativeInfoData { /// Political geographic divisions that contain the requested address. - pub divisions: HashMap, + pub divisions: Option>, /// Officials holding the offices listed above. Will only be present if includeOffices was true in the request. - pub officials: Vec, + pub officials: Option>, /// Elected offices referenced by the divisions listed above. Will only be present if includeOffices was true in the request. - pub offices: Vec, + pub offices: Option>, } impl ResponseResult for RepresentativeInfoData {} @@ -794,30 +794,30 @@ impl ResponseResult for RepresentativeInfoData {} pub struct VoterInfoResponse { /// Locations where the voter is eligible to vote early, prior to election day. #[serde(rename="earlyVoteSites")] - pub early_vote_sites: Vec, + pub early_vote_sites: Option>, /// Locations where a voter is eligible to drop off a completed ballot. The voter must have received and completed a ballot prior to arriving at the location. The location may not have ballots available on the premises. These locations could be open on or before election day as indicated in the pollingHours field. #[serde(rename="dropOffLocations")] - pub drop_off_locations: Vec, + pub drop_off_locations: Option>, /// If no election ID was specified in the query, and there was more than one election with data for the given voter, this will contain information about the other elections that could apply. #[serde(rename="otherElections")] - pub other_elections: Vec, + pub other_elections: Option>, /// Identifies what kind of resource this is. Value: the fixed string "civicinfo#voterInfoResponse". - pub kind: String, + pub kind: Option, /// The normalized version of the requested address #[serde(rename="normalizedInput")] - pub normalized_input: SimpleAddressType, + pub normalized_input: Option, /// Local Election Information for the state that the voter votes in. For the US, there will only be one element in this array. - pub state: Vec, + pub state: Option>, /// no description provided #[serde(rename="precinctId")] - pub precinct_id: String, + pub precinct_id: Option, /// The election that was queried. - pub election: Election, + pub election: Option, /// Locations where the voter is eligible to vote on election day. #[serde(rename="pollingLocations")] - pub polling_locations: Vec, + pub polling_locations: Option>, /// Contests that will appear on the voter's ballot. - pub contests: Vec, + pub contests: Option>, } impl ResponseResult for VoterInfoResponse {} diff --git a/gen/cloudlatencytest2-cli/Cargo.toml b/gen/cloudlatencytest2-cli/Cargo.toml index 7d3ef92592..012706f160 100644 --- a/gen/cloudlatencytest2-cli/Cargo.toml +++ b/gen/cloudlatencytest2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-cloudlatencytest2-cli" version = "0.0.1+20150206" -authors = ["Sebastian Thiel "] +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" documentation = "http://byron.github.io/google-apis-rs/google_cloudlatencytest2_cli" @@ -22,6 +22,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/cloudlatencytest2-cli/src/cmn.rs b/gen/cloudlatencytest2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/cloudlatencytest2-cli/src/cmn.rs +++ b/gen/cloudlatencytest2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/cloudlatencytest2-cli/src/main.rs b/gen/cloudlatencytest2-cli/src/main.rs index f135239123..653d715340 100644 --- a/gen/cloudlatencytest2-cli/src/main.rs +++ b/gen/cloudlatencytest2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -33,6 +34,12 @@ Configuration: 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. "); mod cmn; @@ -54,10 +61,10 @@ struct Engine { impl Engine { fn _statscollection_updateaggregatedstats(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AggregatedStats = Default::default(); + let mut request = api::AggregatedStats::default(); let mut call = self.hub.statscollection().updateaggregatedstats(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -77,9 +84,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -101,8 +109,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -111,10 +118,10 @@ impl Engine { fn _statscollection_updatestats(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Stats = Default::default(); + let mut request = api::Stats::default(); let mut call = self.hub.statscollection().updatestats(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -134,9 +141,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -161,8 +169,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -202,21 +209,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "cloudlatencytest2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "cloudlatencytest2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "cloudlatencytest2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "cloudlatencytest2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Cloudlatencytest::new(hyper::Client::new(), auth), + hub: api::Cloudlatencytest::new(client, auth), }; match engine._doit(true) { @@ -236,12 +259,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/cloudlatencytest2/Cargo.toml b/gen/cloudlatencytest2/Cargo.toml index fd30d85078..23bf95a2bc 100644 --- a/gen/cloudlatencytest2/Cargo.toml +++ b/gen/cloudlatencytest2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-cloudlatencytest2" version = "0.1.5+20150206" -authors = ["Sebastian Thiel "] +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" documentation = "http://byron.github.io/google-apis-rs/google_cloudlatencytest2" diff --git a/gen/cloudlatencytest2/README.md b/gen/cloudlatencytest2/README.md index 58c974cdbf..3991c2dde8 100644 --- a/gen/cloudlatencytest2/README.md +++ b/gen/cloudlatencytest2/README.md @@ -90,7 +90,7 @@ let mut hub = Cloudlatencytest::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Stats = Default::default(); +let mut req = Stats::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/cloudlatencytest2/src/cmn.rs b/gen/cloudlatencytest2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/cloudlatencytest2/src/cmn.rs +++ b/gen/cloudlatencytest2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/cloudlatencytest2/src/lib.rs b/gen/cloudlatencytest2/src/lib.rs index de849e1f7c..4109352f2d 100644 --- a/gen/cloudlatencytest2/src/lib.rs +++ b/gen/cloudlatencytest2/src/lib.rs @@ -91,7 +91,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Stats = Default::default(); +//! let mut req = Stats::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -266,7 +266,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Stats = Default::default(); +/// let mut req = Stats::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -336,9 +336,9 @@ impl<'a, C, A> Cloudlatencytest #[derive(Default, Clone, Debug, Serialize)] pub struct IntValue { /// no description provided - pub value: String, + pub value: Option, /// no description provided - pub label: String, + pub label: Option, } impl Part for IntValue {} @@ -378,9 +378,9 @@ impl RequestValue for Stats {} #[derive(Default, Clone, Debug, Serialize)] pub struct StringValue { /// no description provided - pub value: String, + pub value: Option, /// no description provided - pub label: String, + pub label: Option, } impl Part for StringValue {} @@ -417,7 +417,7 @@ impl RequestValue for AggregatedStats {} pub struct AggregatedStatsReply { /// no description provided #[serde(rename="testValue")] - pub test_value: String, + pub test_value: Option, } impl ResponseResult for AggregatedStatsReply {} @@ -430,9 +430,9 @@ impl ResponseResult for AggregatedStatsReply {} #[derive(Default, Clone, Debug, Serialize)] pub struct DoubleValue { /// no description provided - pub value: f32, + pub value: Option, /// no description provided - pub label: String, + pub label: Option, } impl Part for DoubleValue {} @@ -451,7 +451,7 @@ impl Part for DoubleValue {} pub struct StatsReply { /// no description provided #[serde(rename="testValue")] - pub test_value: String, + pub test_value: Option, } impl ResponseResult for StatsReply {} @@ -570,7 +570,7 @@ impl<'a, C, A> StatscollectionMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AggregatedStats = Default::default(); +/// let mut req = AggregatedStats::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -636,16 +636,20 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -788,7 +792,7 @@ impl<'a, C, A> StatscollectionUpdateaggregatedstatCall<'a, C, A> where C: Borrow /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Stats = Default::default(); +/// let mut req = Stats::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -854,16 +858,20 @@ impl<'a, C, A> StatscollectionUpdatestatCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/cloudmonitoring2_beta2-cli/Cargo.toml b/gen/cloudmonitoring2_beta2-cli/Cargo.toml index dea0210120..e76b49dea0 100644 --- a/gen/cloudmonitoring2_beta2-cli/Cargo.toml +++ b/gen/cloudmonitoring2_beta2-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-cloudmonitoring2_beta2-cli" -version = "0.0.1+20150303" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://cloud.google.com/monitoring/v2beta2/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/cloudmonitoring2_beta2-cli/mkdocs.yml b/gen/cloudmonitoring2_beta2-cli/mkdocs.yml index 61709342d5..edf8cb8d37 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+20150303 +site_name: Cloud Monitoring v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/cmn.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/cloudmonitoring2_beta2-cli/src/main.rs b/gen/cloudmonitoring2_beta2-cli/src/main.rs index 91470c5751..7a1c8c8668 100644 --- a/gen/cloudmonitoring2_beta2-cli/src/main.rs +++ b/gen/cloudmonitoring2_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -37,6 +38,12 @@ Configuration: 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. "); mod cmn; @@ -58,10 +65,10 @@ struct Engine { impl Engine { fn _metric_descriptors_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::MetricDescriptor = Default::default(); + let mut request = api::MetricDescriptor::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -81,9 +88,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -99,11 +107,11 @@ impl Engine { }, "type-descriptor.value-type" => { request_type_descriptor_init(&mut request); - request.type_descriptor.as_mut().unwrap().value_type = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.type_descriptor.as_mut().unwrap().metric_type = Some(value.unwrap_or("").to_string()); }, "description" => { request_type_descriptor_init(&mut request); @@ -130,8 +138,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -142,7 +149,7 @@ impl Engine { -> Option { let mut call = self.hub.metric_descriptors().delete(&self.opt.arg_project, &self.opt.arg_metric); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -174,8 +181,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -184,10 +190,10 @@ impl Engine { fn _metric_descriptors_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ListMetricDescriptorsRequest = Default::default(); + let mut request = api::ListMetricDescriptorsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "query" => { call = call.query(value.unwrap_or("")); @@ -216,9 +222,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -243,8 +250,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -253,10 +259,10 @@ impl Engine { fn _timeseries_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ListTimeseriesRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "window" => { call = call.window(value.unwrap_or("")); @@ -297,9 +303,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -324,8 +331,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -334,10 +340,10 @@ impl Engine { fn _timeseries_write(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::WriteTimeseriesRequest = Default::default(); + let mut request = api::WriteTimeseriesRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -357,18 +363,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); + request.common_labels = Some(Default::default()); } - request.common_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()))); @@ -387,8 +395,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -397,10 +404,10 @@ impl Engine { fn _timeseries_descriptors_list(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ListTimeseriesDescriptorsRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "window" => { call = call.window(value.unwrap_or("")); @@ -441,9 +448,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -468,8 +476,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -491,7 +498,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_timeseries { + } + else if self.opt.cmd_timeseries { if self.opt.cmd_list { call_result = self._timeseries_list(dry_run, &mut err); } else if self.opt.cmd_write { @@ -499,7 +507,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_timeseries_descriptors { + } + else if self.opt.cmd_timeseries_descriptors { if self.opt.cmd_list { call_result = self._timeseries_descriptors_list(dry_run, &mut err); } else { @@ -525,21 +534,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "cloudmonitoring2-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "cloudmonitoring2-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "cloudmonitoring2-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "cloudmonitoring2-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::CloudMonitoring::new(hyper::Client::new(), auth), + hub: api::CloudMonitoring::new(client, auth), }; match engine._doit(true) { @@ -559,12 +584,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 34ed8fcf90..d389d725c4 100644 --- a/gen/cloudmonitoring2_beta2/Cargo.toml +++ b/gen/cloudmonitoring2_beta2/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-cloudmonitoring2_beta2" -version = "0.1.5+20150303" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://cloud.google.com/monitoring/v2beta2/" diff --git a/gen/cloudmonitoring2_beta2/README.md b/gen/cloudmonitoring2_beta2/README.md index 107de7e0ae..f2d96a3b14 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+20150303*, where *20150303* 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.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*. Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the [official documentation site](https://cloud.google.com/monitoring/v2beta2/). @@ -99,7 +99,7 @@ let mut hub = CloudMonitoring::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: ListMetricDescriptorsRequest = Default::default(); +let mut req = ListMetricDescriptorsRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/cloudmonitoring2_beta2/src/cmn.rs b/gen/cloudmonitoring2_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/cloudmonitoring2_beta2/src/cmn.rs +++ b/gen/cloudmonitoring2_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/cloudmonitoring2_beta2/src/lib.rs b/gen/cloudmonitoring2_beta2/src/lib.rs index 71c58ea46a..c15198a5e6 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+20150303*, where *20150303* 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.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*. //! //! Everything else about the *Cloud Monitoring* *v2_beta2* API can be found at the //! [official documentation site](https://cloud.google.com/monitoring/v2beta2/). @@ -100,7 +100,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: ListMetricDescriptorsRequest = Default::default(); +//! let mut req = ListMetricDescriptorsRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -278,7 +278,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ListMetricDescriptorsRequest = Default::default(); +/// let mut req = ListMetricDescriptorsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -357,10 +357,10 @@ impl<'a, C, A> CloudMonitoring #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PointDistributionUnderflowBucket { /// The number of events whose values are in the interval defined by this bucket. - pub count: String, + pub count: Option, /// The upper bound of the value interval of this bucket (exclusive). #[serde(rename="upperBound")] - pub upper_bound: f64, + pub upper_bound: Option, } impl Part for PointDistributionUnderflowBucket {} @@ -378,12 +378,12 @@ impl Part for PointDistributionUnderflowBucket {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListMetricDescriptorsResponse { /// The returned metric descriptors. - pub metrics: Vec, + pub metrics: Option>, /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, pass this value to the pageToken query parameter. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listMetricDescriptorsResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for ListMetricDescriptorsResponse {} @@ -433,9 +433,9 @@ impl RequestValue for ListTimeseriesDescriptorsRequest {} pub struct TimeseriesPoint { /// The descriptor of this time series. #[serde(rename="timeseriesDesc")] - pub timeseries_desc: TimeseriesDescriptor, + pub timeseries_desc: Option, /// The data point in this time series snapshot. - pub point: Point, + pub point: Option, } impl Part for TimeseriesPoint {} @@ -448,13 +448,13 @@ impl Part for TimeseriesPoint {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PointDistribution { /// The finite buckets. - pub buckets: Vec, + pub buckets: Option>, /// The underflow bucket. #[serde(rename="underflowBucket")] - pub underflow_bucket: PointDistributionUnderflowBucket, + pub underflow_bucket: Option, /// The overflow bucket. #[serde(rename="overflowBucket")] - pub overflow_bucket: PointDistributionOverflowBucket, + pub overflow_bucket: Option, } impl Part for PointDistribution {} @@ -466,12 +466,12 @@ impl Part for PointDistribution {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetricDescriptorTypeDescriptor { - /// The type of data that is written to a timeseries point for this metric. + /// The data type of of individual points in the metric's time series. See Metric value types. #[serde(rename="valueType")] - pub value_type: String, - /// The method of collecting data for the metric. + pub value_type: Option, + /// The method of collecting data for the metric. See Metric types. #[serde(rename="metricType")] - pub metric_type: String, + pub metric_type: Option, } impl Part for MetricDescriptorTypeDescriptor {} @@ -484,9 +484,9 @@ impl Part for MetricDescriptorTypeDescriptor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetricDescriptorLabelDescriptor { /// Label description. - pub description: String, + pub description: Option, /// Label key. - pub key: String, + pub key: Option, } impl Part for MetricDescriptorLabelDescriptor {} @@ -499,13 +499,13 @@ impl Part for MetricDescriptorLabelDescriptor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PointDistributionBucket { /// The number of events whose values are in the interval defined by this bucket. - pub count: String, + pub count: Option, /// The lower bound of the value interval of this bucket (inclusive). #[serde(rename="lowerBound")] - pub lower_bound: f64, + pub lower_bound: Option, /// The upper bound of the value interval of this bucket (exclusive). #[serde(rename="upperBound")] - pub upper_bound: f64, + pub upper_bound: Option, } impl Part for PointDistributionBucket {} @@ -572,7 +572,7 @@ impl ResponseResult for MetricDescriptor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WriteTimeseriesResponse { /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#writeTimeseriesResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for WriteTimeseriesResponse {} @@ -590,7 +590,7 @@ impl ResponseResult for WriteTimeseriesResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeleteMetricDescriptorResponse { /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#deleteMetricDescriptorResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for DeleteMetricDescriptorResponse {} @@ -624,24 +624,24 @@ impl RequestValue for WriteTimeseriesRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Point { /// The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings. - pub start: String, + pub start: Option, /// The value of this data point. Either "true" or "false". #[serde(rename="boolValue")] - pub bool_value: bool, + pub bool_value: Option, /// The interval [start, end] is the time period to which the point's value applies. For gauge metrics, whose values are instantaneous measurements, this interval should be empty (start should equal end). For cumulative metrics (of which deltas and rates are special cases), the interval should be non-empty. Both start and end are RFC 3339 strings. - pub end: String, + pub end: Option, /// The value of this data point as a distribution. A distribution value can contain a list of buckets and/or an underflowBucket and an overflowBucket. The values of these points can be used to create a histogram. #[serde(rename="distributionValue")] - pub distribution_value: PointDistribution, + pub distribution_value: Option, /// The value of this data point in string format. #[serde(rename="stringValue")] - pub string_value: String, + pub string_value: Option, /// The value of this data point as a 64-bit integer. #[serde(rename="int64Value")] - pub int64_value: String, + pub int64_value: Option, /// The value of this data point as a double-precision floating-point number. #[serde(rename="doubleValue")] - pub double_value: f64, + pub double_value: Option, } impl Part for Point {} @@ -677,9 +677,9 @@ impl Resource for TimeseriesDescriptor {} pub struct Timeseries { /// The descriptor of this time series. #[serde(rename="timeseriesDesc")] - pub timeseries_desc: TimeseriesDescriptor, + pub timeseries_desc: Option, /// The data points of this time series. The points are listed in order of their end timestamp, from younger to older. - pub points: Vec, + pub points: Option>, } impl Part for Timeseries {} @@ -692,10 +692,10 @@ impl Part for Timeseries {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PointDistributionOverflowBucket { /// The number of events whose values are in the interval defined by this bucket. - pub count: String, + pub count: Option, /// The lower bound of the value interval of this bucket (inclusive). #[serde(rename="lowerBound")] - pub lower_bound: f64, + pub lower_bound: Option, } impl Part for PointDistributionOverflowBucket {} @@ -714,15 +714,15 @@ impl Part for PointDistributionOverflowBucket {} pub struct ListTimeseriesDescriptorsResponse { /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set this value to the pageToken query parameter. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The youngest timestamp of the interval of this query, as an RFC 3339 string. - pub youngest: String, + pub youngest: Option, /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesDescriptorsResponse". - pub kind: String, + pub kind: Option, /// The oldest timestamp of the interval of this query, as an RFC 3339 string. - pub oldest: String, + pub oldest: Option, /// The returned time series descriptors. - pub timeseries: Vec, + pub timeseries: Option>, } impl ResponseResult for ListTimeseriesDescriptorsResponse {} @@ -741,15 +741,15 @@ impl ResponseResult for ListTimeseriesDescriptorsResponse {} pub struct ListTimeseriesResponse { /// Pagination token. If present, indicates that additional results are available for retrieval. To access the results past the pagination limit, set the pageToken query parameter to this value. All of the points of a time series will be returned before returning any point of the subsequent time series. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// The youngest timestamp of the interval of this query as an RFC 3339 string. - pub youngest: String, + pub youngest: Option, /// Identifies what kind of resource this is. Value: the fixed string "cloudmonitoring#listTimeseriesResponse". - pub kind: String, + pub kind: Option, /// The oldest timestamp of the interval of this query as an RFC 3339 string. - pub oldest: String, + pub oldest: Option, /// The returned time series. - pub timeseries: Vec, + pub timeseries: Option>, } impl ResponseResult for ListTimeseriesResponse {} @@ -1055,7 +1055,7 @@ impl<'a, C, A> MetricDescriptorMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ListTimeseriesDescriptorsRequest = Default::default(); +/// let mut req = ListTimeseriesDescriptorsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1190,16 +1190,20 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1438,7 +1442,7 @@ impl<'a, C, A> TimeseriesDescriptorListCall<'a, C, A> where C: BorrowMut TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1692,7 +1700,7 @@ impl<'a, C, A> TimeseryWriteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ListTimeseriesRequest = Default::default(); +/// let mut req = ListTimeseriesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1827,16 +1835,20 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2075,7 +2087,7 @@ impl<'a, C, A> TimeseryListCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ListMetricDescriptorsRequest = Default::default(); +/// let mut req = ListMetricDescriptorsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2182,16 +2194,20 @@ impl<'a, C, A> MetricDescriptorListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2448,16 +2464,20 @@ impl<'a, C, A> MetricDescriptorDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2607,7 +2627,7 @@ impl<'a, C, A> MetricDescriptorDeleteCall<'a, C, A> where C: BorrowMut MetricDescriptorCreateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/cloudsearch1-cli/Cargo.toml b/gen/cloudsearch1-cli/Cargo.toml index fad60afec3..580966a5f8 100644 --- a/gen/cloudsearch1-cli/Cargo.toml +++ b/gen/cloudsearch1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-cloudsearch1-cli" -version = "0.0.1+20150309" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" documentation = "http://byron.github.io/google-apis-rs/google_cloudsearch1_cli" @@ -22,6 +22,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/cloudsearch1-cli/mkdocs.yml b/gen/cloudsearch1-cli/mkdocs.yml index a7ab174bdb..f30709e098 100644 --- a/gen/cloudsearch1-cli/mkdocs.yml +++ b/gen/cloudsearch1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: cloudsearch v0.0.1+20150309 +site_name: cloudsearch v0.0.1+20150416 site_url: http://byron.github.io/google-apis-rs/google-cloudsearch1-cli site_description: Write integrating applications with bcore @@ -9,12 +9,6 @@ site_dir: build_html pages: - ['index.md', 'Home'] -- ['projects_indexes-documents-create.md', 'Projects', 'Indexes Documents Create'] -- ['projects_indexes-documents-delete.md', 'Projects', 'Indexes Documents Delete'] -- ['projects_indexes-documents-get.md', 'Projects', 'Indexes Documents Get'] -- ['projects_indexes-documents-list.md', 'Projects', 'Indexes Documents List'] -- ['projects_indexes-list.md', 'Projects', 'Indexes List'] -- ['projects_indexes-search.md', 'Projects', 'Indexes Search'] theme: readthedocs diff --git a/gen/cloudsearch1-cli/src/cmn.rs b/gen/cloudsearch1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/cloudsearch1-cli/src/cmn.rs +++ b/gen/cloudsearch1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/cloudsearch1-cli/src/main.rs b/gen/cloudsearch1-cli/src/main.rs index 7cbf7e57a6..d4a790d5d4 100644 --- a/gen/cloudsearch1-cli/src/main.rs +++ b/gen/cloudsearch1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -18,25 +19,21 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - cloudsearch1 [options] projects indexes-documents-create -r ... [-p ]... [-o ] - cloudsearch1 [options] projects indexes-documents-delete [-p ]... [-o ] - cloudsearch1 [options] projects indexes-documents-get [-p ]... [-o ] - cloudsearch1 [options] projects indexes-documents-list [-p ]... [-o ] - cloudsearch1 [options] projects indexes-list [-p ]... [-o ] - cloudsearch1 [options] projects indexes-search [-p ]... [-o ] cloudsearch1 --help All documentation details can be found TODO: 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. "); mod cmn; @@ -56,353 +53,11 @@ struct Engine { impl Engine { - fn _projects_indexes_documents_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut request: api::Document = Default::default(); - let mut call = self.hub.projects().indexes_documents_create(&request, &self.opt.arg_project_id, &self.opt.arg_index_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "doc-id" => { - request.doc_id = Some(value.unwrap_or("").to_string()); - }, - "rank" => { - request.rank = Some(arg_from_str(value.unwrap_or("-0"), err, "rank", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_indexes_documents_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.projects().indexes_documents_delete(&self.opt.arg_project_id, &self.opt.arg_index_id, &self.opt.arg_doc_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_indexes_documents_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let mut call = self.hub.projects().indexes_documents_get(&self.opt.arg_project_id, &self.opt.arg_index_id, &self.opt.arg_doc_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_indexes_documents_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let page_size: i32 = arg_from_str(&self.opt.arg_page_size, err, "", "integer"); - let mut call = self.hub.projects().indexes_documents_list(&self.opt.arg_project_id, &self.opt.arg_index_id, page_size, &self.opt.arg_page_token, &self.opt.arg_view); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_indexes_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let page_size: i32 = arg_from_str(&self.opt.arg_page_size, err, "", "integer"); - let mut call = self.hub.projects().indexes_list(&self.opt.arg_project_id, &self.opt.arg_index_name_prefix, page_size, &self.opt.arg_page_token, &self.opt.arg_view); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_indexes_search(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option { - let page_size: i32 = arg_from_str(&self.opt.arg_page_size, err, "", "integer"); - let offset: i32 = arg_from_str(&self.opt.arg_offset, err, "", "integer"); - let matched_count_accuracy: i32 = arg_from_str(&self.opt.arg_matched_count_accuracy, err, "", "integer"); - let scorer_size: i32 = arg_from_str(&self.opt.arg_scorer_size, err, "", "integer"); - let mut call = self.hub.projects().indexes_search(&self.opt.arg_project_id, &self.opt.arg_index_id, &self.opt.arg_query, &self.opt.arg_field_expressions, page_size, &self.opt.arg_page_token, offset, matched_count_accuracy, &self.opt.arg_order_by, &self.opt.arg_scorer, scorer_size, &self.opt.arg_return_fields); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - fn _doit(&self, dry_run: bool) -> (Option, Option) { let mut err = InvalidOptionsError::new(); let mut call_result: Option; let mut err_opt: Option = None; - - if self.opt.cmd_projects { - if self.opt.cmd_indexes_documents_create { - call_result = self._projects_indexes_documents_create(dry_run, &mut err); - } else if self.opt.cmd_indexes_documents_delete { - call_result = self._projects_indexes_documents_delete(dry_run, &mut err); - } else if self.opt.cmd_indexes_documents_get { - call_result = self._projects_indexes_documents_get(dry_run, &mut err); - } else if self.opt.cmd_indexes_documents_list { - call_result = self._projects_indexes_documents_list(dry_run, &mut err); - } else if self.opt.cmd_indexes_list { - call_result = self._projects_indexes_list(dry_run, &mut err); - } else if self.opt.cmd_indexes_search { - call_result = self._projects_indexes_search(dry_run, &mut err); - } else { - unreachable!(); - } - } else { + else { unreachable!(); } @@ -422,21 +77,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "cloudsearch1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "cloudsearch1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "cloudsearch1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "cloudsearch1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Cloudsearch::new(hyper::Client::new(), auth), + hub: api::Cloudsearch::new(client, auth), }; match engine._doit(true) { @@ -456,12 +127,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/cloudsearch1/Cargo.toml b/gen/cloudsearch1/Cargo.toml index 95603a1a8e..dba02cda31 100644 --- a/gen/cloudsearch1/Cargo.toml +++ b/gen/cloudsearch1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-cloudsearch1" -version = "0.1.5+20150309" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" documentation = "http://byron.github.io/google-apis-rs/google_cloudsearch1" diff --git a/gen/cloudsearch1/README.md b/gen/cloudsearch1/README.md index d8d8ef383d..085b0d7aec 100644 --- a/gen/cloudsearch1/README.md +++ b/gen/cloudsearch1/README.md @@ -5,13 +5,11 @@ 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+20150309*, where *20150309* 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.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*. # Features -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.Cloudsearch.html) ... +It seems there is nothing you can do here ... . -* projects - * [*indexes documents create*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeDocumentCreateCall.html), [*indexes documents delete*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeDocumentDeleteCall.html), [*indexes documents get*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeDocumentGetCall.html), [*indexes documents list*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeDocumentListCall.html), [*indexes list*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeListCall.html) and [*indexes search*](http://byron.github.io/google-apis-rs/google_cloudsearch1/struct.ProjectIndexeSearchCall.html) @@ -41,12 +39,6 @@ Generally speaking, you can invoke *Activities* like this: let r = hub.resource().activity(...).doit() ``` -Or specifically ... - -```ignore -let r = hub.projects().indexes_documents_get(...).doit() -let r = hub.projects().indexes_documents_create(...).doit() -``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be @@ -70,7 +62,7 @@ google-cloudsearch1 = "*" extern crate hyper; extern crate yup_oauth2 as oauth2; extern crate google_cloudsearch1 as cloudsearch1; -use cloudsearch1::{Result, Error}; + use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; use cloudsearch1::Cloudsearch; @@ -87,29 +79,9 @@ let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, hyper::Client::new(), ::default(), None); let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -// You can configure optional parameters by calling 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().indexes_documents_get("projectId", "indexId", "docId") - .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::MissingAPIKey - |Error::MissingToken - |Error::Cancelled - |Error::UploadSizeLimitExceeded(_, _) - |Error::Failure(_) - |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), - }, - Ok(res) => println!("Success: {:?}", res), -} ``` + ## Handling Errors All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_cloudsearch1/enum.Result.html) enumeration as return value of diff --git a/gen/cloudsearch1/src/cmn.rs b/gen/cloudsearch1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/cloudsearch1/src/cmn.rs +++ b/gen/cloudsearch1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/cloudsearch1/src/lib.rs b/gen/cloudsearch1/src/lib.rs index 078fa366ba..d6fdfe5bd8 100644 --- a/gen/cloudsearch1/src/lib.rs +++ b/gen/cloudsearch1/src/lib.rs @@ -2,14 +2,12 @@ // 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+20150309*, where *20150309* 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.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*. //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudsearch1). //! # Features //! -//! Handle the following *Resources* with ease from the central [hub](struct.Cloudsearch.html) ... +//! It seems there is nothing you can do here ... . //! -//! * projects -//! * [*indexes documents create*](struct.ProjectIndexeDocumentCreateCall.html), [*indexes documents delete*](struct.ProjectIndexeDocumentDeleteCall.html), [*indexes documents get*](struct.ProjectIndexeDocumentGetCall.html), [*indexes documents list*](struct.ProjectIndexeDocumentListCall.html), [*indexes list*](struct.ProjectIndexeListCall.html) and [*indexes search*](struct.ProjectIndexeSearchCall.html) //! //! //! @@ -41,12 +39,6 @@ //! let r = hub.resource().activity(...).doit() //! ``` //! -//! Or specifically ... -//! -//! ```ignore -//! let r = hub.projects().indexes_documents_get(...).doit() -//! let r = hub.projects().indexes_documents_create(...).doit() -//! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` //! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be @@ -70,7 +62,7 @@ //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; //! extern crate google_cloudsearch1 as cloudsearch1; -//! use cloudsearch1::{Result, Error}; +//! //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -88,29 +80,9 @@ //! hyper::Client::new(), //! ::default(), None); //! let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -//! // You can configure optional parameters by calling 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().indexes_documents_get("projectId", "indexId", "docId") -//! .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::MissingAPIKey -//! |Error::MissingToken -//! |Error::Cancelled -//! |Error::UploadSizeLimitExceeded(_, _) -//! |Error::Failure(_) -//! |Error::FieldClash(_) -//! |Error::JsonDecodeError(_) => println!("{}", e), -//! }, -//! Ok(res) => println!("Success: {:?}", res), -//! } //! # } //! ``` +//! //! ## Handling Errors //! //! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of @@ -200,36 +172,6 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, // UTILITIES ### // ############ -/// Identifies the an OAuth2 authorization scope. -/// A scope is needed when requesting an -/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). -#[derive(PartialEq, Eq, Hash)] -pub enum Scope { - /// FOR TESTING ONLY - Full, - - /// View your email address - UserinfoEmail, - - /// View and manage your data across Google Cloud Platform services - CloudPlatform, -} - -impl AsRef for Scope { - fn as_ref(&self) -> &str { - match *self { - Scope::Full => "https://www.googleapis.com/auth/cloudsearch", - Scope::UserinfoEmail => "https://www.googleapis.com/auth/userinfo.email", - Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", - } - } -} - -impl Default for Scope { - fn default() -> Scope { - Scope::Full - } -} @@ -247,7 +189,7 @@ impl Default for Scope { /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_cloudsearch1 as cloudsearch1; -/// use cloudsearch1::{Result, Error}; +/// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -265,29 +207,9 @@ impl Default for Scope { /// hyper::Client::new(), /// ::default(), None); /// let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_documents_get("projectId", "indexId", "docId") -/// .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::MissingAPIKey -/// |Error::MissingToken -/// |Error::Cancelled -/// |Error::UploadSizeLimitExceeded(_, _) -/// |Error::Failure(_) -/// |Error::FieldClash(_) -/// |Error::JsonDecodeError(_) => println!("{}", e), -/// }, -/// Ok(res) => println!("Success: {:?}", res), -/// } /// # } /// ``` +/// pub struct Cloudsearch { client: RefCell, auth: RefCell, @@ -307,9 +229,6 @@ impl<'a, C, A> Cloudsearch } } - pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { - ProjectMethods { hub: &self } - } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/0.1.5`. @@ -323,2152 +242,14 @@ impl<'a, C, A> Cloudsearch } -// ############ -// SCHEMAS ### -// ########## -/// A response returned from a listing documents request. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [indexes documents list projects](struct.ProjectIndexeDocumentListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListDocumentsResponse { - /// If there are more results, retrieve them by invoking list documents call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set. - #[serde(rename="nextPageToken")] - pub next_page_token: String, - /// The list of documents. - pub documents: Vec, -} - -impl ResponseResult for ListDocumentsResponse {} - - -/// Information about an index. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct IndexInfo { - /// The project associated with the index. It cannot be the empty string. - #[serde(rename="projectId")] - pub project_id: String, - /// The index identifier. It cannot be the empty string. It must contain only visible, printable ASCII characters (ASCII codes 33 through 126 inclusive) and be no longer than 100 characters. It cannot begin with an exclamation point ('!'), and it can't begin and end with double underscores ("__"). - #[serde(rename="indexId")] - pub index_id: String, - /// Names of indexed fields. - #[serde(rename="indexedField")] - pub indexed_field: FieldNames, -} - -impl Part for IndexInfo {} - - -/// A document returned in a SearchResponse. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SearchResult { - /// If there are more results, retrieve them by invoking search call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set. - #[serde(rename="nextPageToken")] - pub next_page_token: String, - /// The list of fields in the result. Each field is either from the stored document, the built-in fields (`_rank`, the document rank, and `_score` if scoring is enabled), or computed from any extra `fieldExpressions` defined in the request. For example, if a request contains a `fieldExpressions` named `"TotalPrice"` and expressed as `"Price + Tax"`, the result will have a field whose name is `"TotalPrice"` and whose value is set to the computed sum of the value of field `"Price"` and the value of field `"Tax"`. If a request contains a `fieldExpressions` named `"snippet"` and expressed as `"snippet(\"good times\", content)"`, the result will have a field whose name is `"snippet"` and whose value contains a snippet of text from field `"content"` matching the query "good times". - pub fields: HashMap, - /// The unique identifier of the document. - #[serde(rename="docId")] - pub doc_id: String, -} - -impl Part for SearchResult {} - - -/// Names of indexed fields. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FieldNames { - /// The names of fields in which TEXT values are stored. - #[serde(rename="textFields")] - pub text_fields: Vec, - /// The names of fields in which DATE values are stored. - #[serde(rename="dateFields")] - pub date_fields: Vec, - /// The names of fields in which NUMBER values are stored. - #[serde(rename="numberFields")] - pub number_fields: Vec, - /// The names of fields in which GEO values are stored. - #[serde(rename="geoFields")] - pub geo_fields: Vec, - /// The names of fields in which ATOM values are stored. - #[serde(rename="atomFields")] - pub atom_fields: Vec, - /// The names of fields in which HTML values are stored. - #[serde(rename="htmlFields")] - pub html_fields: Vec, -} - -impl Part for FieldNames {} - - -/// The values of a document field under the same field name. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FieldValueList { - /// The list of typed values. - pub values: Vec, -} - -impl Part for FieldValueList {} - - -/// A response returned from a listing indexes request. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [indexes list projects](struct.ProjectIndexeListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ListIndexesResponse { - /// If there are more results, retrieve them by invoking list indexes call with the same arguments and this `nextPageToken`. If there are no more results, this field is not set. - #[serde(rename="nextPageToken")] - pub next_page_token: String, - /// The information about available indexes. - pub indexes: Vec, -} - -impl ResponseResult for ListIndexesResponse {} - - -/// A response returned from a search request. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [indexes search projects](struct.ProjectIndexeSearchCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SearchResponse { - /// The number of documents that match the query. It is greater than or equal to the number of documents actually returned. This is an approximation and not an exact count unless it is less than or equal to `matchedCountAccuracy` in search parameter. - #[serde(rename="matchedCount")] - pub matched_count: i64, - /// The list of documents that match the search query. - pub results: Vec, -} - -impl ResponseResult for SearchResponse {} - - -/// The message representing a document resource. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [indexes documents get projects](struct.ProjectIndexeDocumentGetCall.html) (response) -/// * [indexes documents create projects](struct.ProjectIndexeDocumentCreateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Document { - /// The list of fields in the document. It cannot be the empty list. Each field has a name and a list of values. The field name is unique to a document and is case sensitive. The name can only contain ASCII characters. It must start with a letter and can contain letters, digits, or underscore. It cannot be longer than 500 characters and cannot be the empty string. A field can have multiple values with same or different types, however, it cannot have multiple Timestamp or number values. - pub fields: Option>, - /// The unique identifier of the document. It must contain only visible, printable ASCII characters (ASCII codes 33 through 126 inclusive) and be no longer than 500 characters. It cannot begin with an exclamation point ('!'), and it can't begin and end with double underscores ("__"). If missing, it is automatically assigned for the document. - #[serde(rename="docId")] - pub doc_id: Option, - /// A positive integer which determines the default ordering of documents returned from a search. The rank can be set explicitly when the document is created. It is a bad idea to assign the same rank to many documents, and the same rank should never be assigned to more than 10,000 documents. By default (when it is not specified or set to 0), it is set at the time the document is created to the number of seconds since January 1, 2011. The rank can be used in field_expressions, order_by or return_fields in a search request, where it is referenced as `_rank`. - pub rank: Option, -} - -impl RequestValue for Document {} -impl ResponseResult for Document {} - - -/// The value of a document field and associated metadata. Exactly one of the value fields may be set. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FieldValue { - /// The language of a string value. If given, the language must be a valid `ISO 639-1` code. - pub lang: String, - /// The value of a number-valued field. - #[serde(rename="numberValue")] - pub number_value: f64, - /// The value of a timestamp-valued field. - #[serde(rename="timestampValue")] - pub timestamp_value: String, - /// The value of a string-valued field. - #[serde(rename="stringValue")] - pub string_value: String, - /// The format of a string value. By default, the string format is `DEFAULT`, where a format will be automatically detected. - #[serde(rename="stringFormat")] - pub string_format: String, - /// The value of a GEO-valued field, represented in string with any of the listed [ways of writing coordinates](http://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ways_of_writing_coordinates) - #[serde(rename="geoValue")] - pub geo_value: String, -} - -impl Part for FieldValue {} - - -/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [indexes documents delete projects](struct.ProjectIndexeDocumentDeleteCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Empty; - -impl ResponseResult for Empty {} - - // ################### // MethodBuilders ### // ################# -/// A builder providing access to all methods supported on *project* resources. -/// It is not used directly, but through the `Cloudsearch` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_cloudsearch1 as cloudsearch1; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use cloudsearch1::Cloudsearch; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// ::default(), None); -/// let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `indexes_documents_create(...)`, `indexes_documents_delete(...)`, `indexes_documents_get(...)`, `indexes_documents_list(...)`, `indexes_list(...)` and `indexes_search(...)` -/// // to build up your call. -/// let rb = hub.projects(); -/// # } -/// ``` -pub struct ProjectMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, -} - -impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} - -impl<'a, C, A> ProjectMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Lists search indexes belonging to the specified project. - /// - /// # Arguments - /// - /// * `projectId` - The project from which to retrieve indexes. It cannot be the empty string. - /// * `indexNamePrefix` - The prefix of the index name. It is used to list all indexes with names that have this prefix. - /// * `pageSize` - The maximum number of indexes to return per page. If not specified, 100 indexes are returned per page. - /// * `pageToken` - A `nextPageToken` returned from previous list indexes call as the starting point for this call. If not specified, list indexes from the beginning. - /// * `view` - Specifies which parts of the IndexInfo resource is returned in the response. If not specified, `ID_ONLY` is used. - pub fn indexes_list(&self, project_id: &str, index_name_prefix: &str, page_size: i32, page_token: &str, view: &str) -> ProjectIndexeListCall<'a, C, A> { - ProjectIndexeListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _index_name_prefix: index_name_prefix.to_string(), - _page_size: page_size, - _page_token: page_token.to_string(), - _view: view.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a document from an index. - /// - /// # Arguments - /// - /// * `projectId` - The project associated with the index for retrieving the document. It cannot be the empty string. - /// * `indexId` - The index from which to retrieve the document. It cannot be the empty string. - /// * `docId` - The identifier of the document to retrieve. It cannot be the empty string. - pub fn indexes_documents_get(&self, project_id: &str, index_id: &str, doc_id: &str) -> ProjectIndexeDocumentGetCall<'a, C, A> { - ProjectIndexeDocumentGetCall { - hub: self.hub, - _project_id: project_id.to_string(), - _index_id: index_id.to_string(), - _doc_id: doc_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists the documents in the named index that match the query. - /// - /// # Arguments - /// - /// * `projectId` - The project associated with the index for searching document. It cannot be the empty string. - /// * `indexId` - The index to search. It cannot be the empty string. - /// * `query` - The query string in search query syntax. If the query is missing or empty, all documents are returned. - /// * `fieldExpressions` - Customized expressions used in `orderBy` or `returnFields`. The expression can contain fields in `Document`, the built-in fields ( `_rank`, the document rank, and `_score` if scoring is enabled) and fields defined in `fieldExpressions`. Each field expression is represented in a json object with the following fields: * `name`: the name of the field expression in string. * `expression`: the expression to be computed. It can be a combination of supported functions encoded in string. Expressions involving number fields can use the arithmetical operators (`+`, `-`, `*`, `/`) and the built-in numeric functions (`max`, `min`, `pow`, `count`, `log`, `abs`). Expressions involving geopoint fields can use the `geopoint` and `distance` functions. Expressions for text and html fields can use the `snippet` function. For example: ``` fieldExpressions={name: "TotalPrice", expression: "(Price+Tax)"} ``` ``` fieldExpressions={name: "snippet", expression: "snippet('good times', content)"} ``` The field expression names can be used in `orderBy` and `returnFields` after they are defined in `fieldExpressions`. - /// * `pageSize` - The maximum number of search results to return per page. Searches perform best when the `pageSize` is kept as small as possible. If not specified, 10 results are returned per page. - /// * `pageToken` - A `nextPageToken` returned from previous Search call as the starting point for this call. Pagination tokens provide better performance and consistency than offsets, and they cannot be used in combination with offsets. - /// * `offset` - Offset is used to move to an arbitrary result, independent of the previous results. Offsets are inefficient when compared to `pageToken`. `pageToken` and `offset` cannot be both set. The default value of `offset` is 0. - /// * `matchedCountAccuracy` - Minimum accuracy requirement for `matchedCount` in search response. If specified, `matchedCount` will be accurate up to at least that number. For example, when set to 100, any `matchedCount <= 100` is accurate. This option may add considerable latency/expense. By default (when it is not specified or set to 0), the accuracy is the same as `pageSize`. - /// * `orderBy` - Comma-separated list of fields for sorting on the search result, including fields from `Document`, the built-in fields (`_rank` and `_score`), and fields defined in `fieldExpressions`. For example: `orderBy="foo,bar"`. The default sorting order is ascending. To specify descending order for a field, a suffix `" desc"` should be appended to the field name. For example: `orderBy="foo desc,bar"`. The default value for text sort is the empty string, and the default value for numeric sort is 0. If not specified, the search results are automatically sorted by descending `_rank`. Sorting by ascending `_rank` is not allowed. - /// * `scorer` - The scoring function to invoke on a search result for this query. If `scorer` is not set, scoring is disabled and `_score` is 0 for all documents in the search result. To enable document relevancy score based on term frequency, set `"scorer=generic"`. - /// * `scorerSize` - Maximum number of top retrieved results to score. It is valid only when `scorer` is set. If not specified, 100 retrieved results are scored. - /// * `returnFields` - List of fields to return in `SearchResult` objects. It can be fields from `Document`, the built-in fields `_rank` and `_score`, and fields defined in `fieldExpressions`. Use `"*"` to return all fields from `Document`. - pub fn indexes_search(&self, project_id: &str, index_id: &str, query: &str, field_expressions: &Vec, page_size: i32, page_token: &str, offset: i32, matched_count_accuracy: i32, order_by: &str, scorer: &str, scorer_size: i32, return_fields: &Vec) -> ProjectIndexeSearchCall<'a, C, A> { - ProjectIndexeSearchCall { - hub: self.hub, - _project_id: project_id.to_string(), - _index_id: index_id.to_string(), - _query: query.to_string(), - _field_expressions: field_expressions.clone(), - _page_size: page_size, - _page_token: page_token.to_string(), - _offset: offset, - _matched_count_accuracy: matched_count_accuracy, - _order_by: order_by.to_string(), - _scorer: scorer.to_string(), - _scorer_size: scorer_size, - _return_fields: return_fields.clone(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists documents in the specified search index. Intended for batch processing. - /// - /// # Arguments - /// - /// * `projectId` - The project associated with the index for listing documents. It cannot be the empty string. - /// * `indexId` - The index from which to list the documents. It cannot be the empty string. - /// * `pageSize` - The maximum number of documents to return per page. If not specified, 100 documents are returned per page. - /// * `pageToken` - A `nextPageToken` returned from previous list documents call as the starting point for this call. If not specified, list documents from the beginning. - /// * `view` - Specifies which part of the document resource is returned in the response. If not specified, `ID_ONLY` is used. - pub fn indexes_documents_list(&self, project_id: &str, index_id: &str, page_size: i32, page_token: &str, view: &str) -> ProjectIndexeDocumentListCall<'a, C, A> { - ProjectIndexeDocumentListCall { - hub: self.hub, - _project_id: project_id.to_string(), - _index_id: index_id.to_string(), - _page_size: page_size, - _page_token: page_token.to_string(), - _view: view.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Inserts a document for indexing or updates an indexed document. The returned document contains only the ID of the new document. When `docId` is absent from the document, it is provided by the server. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `projectId` - The project associated with the index for adding document. It cannot be the empty string. - /// * `indexId` - The index to add document to. It cannot be the empty string. - pub fn indexes_documents_create(&self, request: &Document, project_id: &str, index_id: &str) -> ProjectIndexeDocumentCreateCall<'a, C, A> { - ProjectIndexeDocumentCreateCall { - hub: self.hub, - _request: request.clone(), - _project_id: project_id.to_string(), - _index_id: index_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes a document from an index. - /// - /// # Arguments - /// - /// * `projectId` - The project associated with the index for deleting document. It cannot be the empty string. - /// * `indexId` - The index from which to delete the document. It cannot be the empty string. - /// * `docId` - The document to be deleted. It cannot be the empty string. - pub fn indexes_documents_delete(&self, project_id: &str, index_id: &str, doc_id: &str) -> ProjectIndexeDocumentDeleteCall<'a, C, A> { - ProjectIndexeDocumentDeleteCall { - hub: self.hub, - _project_id: project_id.to_string(), - _index_id: index_id.to_string(), - _doc_id: doc_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - // ################### // CallBuilders ### // ################# -/// Lists search indexes belonging to the specified project. -/// -/// A builder for the *indexes.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_list("projectId", "indexNamePrefix", -81, "pageToken", "view") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _project_id: String, - _index_name_prefix: String, - _page_size: i32, - _page_token: String, - _view: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeListCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListIndexesResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexNamePrefix", self._index_name_prefix.to_string())); - params.push(("pageSize", self._page_size.to_string())); - params.push(("pageToken", self._page_token.to_string())); - params.push(("view", self._view.to_string())); - for &field in ["alt", "projectId", "indexNamePrefix", "pageSize", "pageToken", "view"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(1); - for param_name in ["projectId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project from which to retrieve indexes. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The prefix of the index name. It is used to list all indexes with names that have this prefix. - /// - /// Sets the *index name prefix* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_name_prefix(mut self, new_value: &str) -> ProjectIndexeListCall<'a, C, A> { - self._index_name_prefix = new_value.to_string(); - self - } - /// The maximum number of indexes to return per page. If not specified, 100 indexes are returned per page. - /// - /// Sets the *page size* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_size(mut self, new_value: i32) -> ProjectIndexeListCall<'a, C, A> { - self._page_size = new_value; - self - } - /// A `nextPageToken` returned from previous list indexes call as the starting point for this call. If not specified, list indexes from the beginning. - /// - /// Sets the *page token* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_token(mut self, new_value: &str) -> ProjectIndexeListCall<'a, C, A> { - self._page_token = new_value.to_string(); - self - } - /// Specifies which parts of the IndexInfo resource is returned in the response. If not specified, `ID_ONLY` is used. - /// - /// Sets the *view* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn view(mut self, new_value: &str) -> ProjectIndexeListCall<'a, C, A> { - self._view = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a document from an index. -/// -/// A builder for the *indexes.documents.get* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_documents_get("projectId", "indexId", "docId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeDocumentGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _project_id: String, - _index_id: String, - _doc_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeDocumentGetCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeDocumentGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Document)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.documents.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexId", self._index_id.to_string())); - params.push(("docId", self._doc_id.to_string())); - for &field in ["alt", "projectId", "indexId", "docId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes/{indexId}/documents/{docId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{indexId}", "indexId"), ("{docId}", "docId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["projectId", "indexId", "docId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project associated with the index for retrieving the document. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeDocumentGetCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The index from which to retrieve the document. It cannot be the empty string. - /// - /// Sets the *index id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_id(mut self, new_value: &str) -> ProjectIndexeDocumentGetCall<'a, C, A> { - self._index_id = new_value.to_string(); - self - } - /// The identifier of the document to retrieve. It cannot be the empty string. - /// - /// Sets the *doc id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn doc_id(mut self, new_value: &str) -> ProjectIndexeDocumentGetCall<'a, C, A> { - self._doc_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeDocumentGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeDocumentGetCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeDocumentGetCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists the documents in the named index that match the query. -/// -/// A builder for the *indexes.search* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_search("projectId", "indexId", "query", "fieldExpressions", -21, "pageToken", -34, -17, "orderBy", "scorer", -5, "returnFields") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeSearchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _project_id: String, - _index_id: String, - _query: String, - _field_expressions: Vec, - _page_size: i32, - _page_token: String, - _offset: i32, - _matched_count_accuracy: i32, - _order_by: String, - _scorer: String, - _scorer_size: i32, - _return_fields: Vec, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeSearchCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeSearchCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, SearchResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.search", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((14 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexId", self._index_id.to_string())); - params.push(("query", self._query.to_string())); - if self._field_expressions.len() > 0 { - let mut s = String::new(); - for f in self._field_expressions.iter() { - s.push_str(&("/".to_string() + &f.to_string())); - } - params.push(("fieldExpressions", s)); - } - params.push(("pageSize", self._page_size.to_string())); - params.push(("pageToken", self._page_token.to_string())); - params.push(("offset", self._offset.to_string())); - params.push(("matchedCountAccuracy", self._matched_count_accuracy.to_string())); - params.push(("orderBy", self._order_by.to_string())); - params.push(("scorer", self._scorer.to_string())); - params.push(("scorerSize", self._scorer_size.to_string())); - if self._return_fields.len() > 0 { - let mut s = String::new(); - for f in self._return_fields.iter() { - s.push_str(&("/".to_string() + &f.to_string())); - } - params.push(("returnFields", s)); - } - for &field in ["alt", "projectId", "indexId", "query", "fieldExpressions", "pageSize", "pageToken", "offset", "matchedCountAccuracy", "orderBy", "scorer", "scorerSize", "returnFields"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes/{indexId}/search".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{indexId}", "indexId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["projectId", "indexId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project associated with the index for searching document. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The index to search. It cannot be the empty string. - /// - /// Sets the *index id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_id(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._index_id = new_value.to_string(); - self - } - /// The query string in search query syntax. If the query is missing or empty, all documents are returned. - /// - /// Sets the *query* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn query(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._query = new_value.to_string(); - self - } - /// Customized expressions used in `orderBy` or `returnFields`. The expression can contain fields in `Document`, the built-in fields ( `_rank`, the document rank, and `_score` if scoring is enabled) and fields defined in `fieldExpressions`. Each field expression is represented in a json object with the following fields: * `name`: the name of the field expression in string. * `expression`: the expression to be computed. It can be a combination of supported functions encoded in string. Expressions involving number fields can use the arithmetical operators (`+`, `-`, `*`, `/`) and the built-in numeric functions (`max`, `min`, `pow`, `count`, `log`, `abs`). Expressions involving geopoint fields can use the `geopoint` and `distance` functions. Expressions for text and html fields can use the `snippet` function. For example: ``` fieldExpressions={name: "TotalPrice", expression: "(Price+Tax)"} ``` ``` fieldExpressions={name: "snippet", expression: "snippet('good times', content)"} ``` The field expression names can be used in `orderBy` and `returnFields` after they are defined in `fieldExpressions`. - /// - /// Append the given value to the *field expressions* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn add_field_expressions(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._field_expressions.push(new_value.to_string()); - self - } - /// The maximum number of search results to return per page. Searches perform best when the `pageSize` is kept as small as possible. If not specified, 10 results are returned per page. - /// - /// Sets the *page size* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_size(mut self, new_value: i32) -> ProjectIndexeSearchCall<'a, C, A> { - self._page_size = new_value; - self - } - /// A `nextPageToken` returned from previous Search call as the starting point for this call. Pagination tokens provide better performance and consistency than offsets, and they cannot be used in combination with offsets. - /// - /// Sets the *page token* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_token(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._page_token = new_value.to_string(); - self - } - /// Offset is used to move to an arbitrary result, independent of the previous results. Offsets are inefficient when compared to `pageToken`. `pageToken` and `offset` cannot be both set. The default value of `offset` is 0. - /// - /// Sets the *offset* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn offset(mut self, new_value: i32) -> ProjectIndexeSearchCall<'a, C, A> { - self._offset = new_value; - self - } - /// Minimum accuracy requirement for `matchedCount` in search response. If specified, `matchedCount` will be accurate up to at least that number. For example, when set to 100, any `matchedCount <= 100` is accurate. This option may add considerable latency/expense. By default (when it is not specified or set to 0), the accuracy is the same as `pageSize`. - /// - /// Sets the *matched count accuracy* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn matched_count_accuracy(mut self, new_value: i32) -> ProjectIndexeSearchCall<'a, C, A> { - self._matched_count_accuracy = new_value; - self - } - /// Comma-separated list of fields for sorting on the search result, including fields from `Document`, the built-in fields (`_rank` and `_score`), and fields defined in `fieldExpressions`. For example: `orderBy="foo,bar"`. The default sorting order is ascending. To specify descending order for a field, a suffix `" desc"` should be appended to the field name. For example: `orderBy="foo desc,bar"`. The default value for text sort is the empty string, and the default value for numeric sort is 0. If not specified, the search results are automatically sorted by descending `_rank`. Sorting by ascending `_rank` is not allowed. - /// - /// Sets the *order by* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn order_by(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._order_by = new_value.to_string(); - self - } - /// The scoring function to invoke on a search result for this query. If `scorer` is not set, scoring is disabled and `_score` is 0 for all documents in the search result. To enable document relevancy score based on term frequency, set `"scorer=generic"`. - /// - /// Sets the *scorer* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn scorer(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._scorer = new_value.to_string(); - self - } - /// Maximum number of top retrieved results to score. It is valid only when `scorer` is set. If not specified, 100 retrieved results are scored. - /// - /// Sets the *scorer size* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn scorer_size(mut self, new_value: i32) -> ProjectIndexeSearchCall<'a, C, A> { - self._scorer_size = new_value; - self - } - /// List of fields to return in `SearchResult` objects. It can be fields from `Document`, the built-in fields `_rank` and `_score`, and fields defined in `fieldExpressions`. Use `"*"` to return all fields from `Document`. - /// - /// Append the given value to the *return fields* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn add_return_fields(mut self, new_value: &str) -> ProjectIndexeSearchCall<'a, C, A> { - self._return_fields.push(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeSearchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeSearchCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeSearchCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists documents in the specified search index. Intended for batch processing. -/// -/// A builder for the *indexes.documents.list* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_documents_list("projectId", "indexId", -9, "pageToken", "view") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeDocumentListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _project_id: String, - _index_id: String, - _page_size: i32, - _page_token: String, - _view: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeDocumentListCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeDocumentListCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListDocumentsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.documents.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexId", self._index_id.to_string())); - params.push(("pageSize", self._page_size.to_string())); - params.push(("pageToken", self._page_token.to_string())); - params.push(("view", self._view.to_string())); - for &field in ["alt", "projectId", "indexId", "pageSize", "pageToken", "view"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes/{indexId}/documents".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{indexId}", "indexId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["projectId", "indexId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project associated with the index for listing documents. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The index from which to list the documents. It cannot be the empty string. - /// - /// Sets the *index id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_id(mut self, new_value: &str) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._index_id = new_value.to_string(); - self - } - /// The maximum number of documents to return per page. If not specified, 100 documents are returned per page. - /// - /// Sets the *page size* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_size(mut self, new_value: i32) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._page_size = new_value; - self - } - /// A `nextPageToken` returned from previous list documents call as the starting point for this call. If not specified, list documents from the beginning. - /// - /// Sets the *page token* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn page_token(mut self, new_value: &str) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._page_token = new_value.to_string(); - self - } - /// Specifies which part of the document resource is returned in the response. If not specified, `ID_ONLY` is used. - /// - /// Sets the *view* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn view(mut self, new_value: &str) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._view = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeDocumentListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeDocumentListCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeDocumentListCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Inserts a document for indexing or updates an indexed document. The returned document contains only the ID of the new document. When `docId` is absent from the document, it is provided by the server. -/// -/// A builder for the *indexes.documents.create* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// use cloudsearch1::Document; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Document = Default::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().indexes_documents_create(&req, "projectId", "indexId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeDocumentCreateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _request: Document, - _project_id: String, - _index_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeDocumentCreateCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeDocumentCreateCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Document)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.documents.create", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexId", self._index_id.to_string())); - for &field in ["alt", "projectId", "indexId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes/{indexId}/documents".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{indexId}", "indexId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(2); - for param_name in ["projectId", "indexId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: &Document) -> ProjectIndexeDocumentCreateCall<'a, C, A> { - self._request = new_value.clone(); - self - } - /// The project associated with the index for adding document. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeDocumentCreateCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The index to add document to. It cannot be the empty string. - /// - /// Sets the *index id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_id(mut self, new_value: &str) -> ProjectIndexeDocumentCreateCall<'a, C, A> { - self._index_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeDocumentCreateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeDocumentCreateCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeDocumentCreateCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes a document from an index. -/// -/// A builder for the *indexes.documents.delete* method supported by a *project* resource. -/// It is not used directly, but through a `ProjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_cloudsearch1 as cloudsearch1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use cloudsearch1::Cloudsearch; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # ::default(), None); -/// # let mut hub = Cloudsearch::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().indexes_documents_delete("projectId", "indexId", "docId") -/// .doit(); -/// # } -/// ``` -pub struct ProjectIndexeDocumentDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Cloudsearch, - _project_id: String, - _index_id: String, - _doc_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap, - _scopes: BTreeMap -} - -impl<'a, C, A> CallBuilder for ProjectIndexeDocumentDeleteCall<'a, C, A> {} - -impl<'a, C, A> ProjectIndexeDocumentDeleteCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "cloudsearch.projects.indexes.documents.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("projectId", self._project_id.to_string())); - params.push(("indexId", self._index_id.to_string())); - params.push(("docId", self._doc_id.to_string())); - for &field in ["alt", "projectId", "indexId", "docId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://cloudsearch.googleapis.com/v1/projects/{projectId}/indexes/{indexId}/documents/{docId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{projectId}", "projectId"), ("{indexId}", "indexId"), ("{docId}", "docId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec = Vec::with_capacity(3); - for param_name in ["projectId", "indexId", "docId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project associated with the index for deleting document. It cannot be the empty string. - /// - /// Sets the *project id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn project_id(mut self, new_value: &str) -> ProjectIndexeDocumentDeleteCall<'a, C, A> { - self._project_id = new_value.to_string(); - self - } - /// The index from which to delete the document. It cannot be the empty string. - /// - /// Sets the *index id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn index_id(mut self, new_value: &str) -> ProjectIndexeDocumentDeleteCall<'a, C, A> { - self._index_id = new_value.to_string(); - self - } - /// The document to be deleted. It cannot be the empty string. - /// - /// Sets the *doc id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn doc_id(mut self, new_value: &str) -> ProjectIndexeDocumentDeleteCall<'a, C, A> { - self._doc_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectIndexeDocumentDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *bearer_token* (query-string) - OAuth bearer token. - /// * *pp* (query-boolean) - Pretty-print response. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *access_token* (query-string) - OAuth access token. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. - /// * *callback* (query-string) - JSONP - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *alt* (query-string) - Data format for response. - /// * *$.xgafv* (query-string) - V1 error format. - pub fn param(mut self, name: T, value: T) -> ProjectIndexeDocumentDeleteCall<'a, C, A> - where T: AsRef { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope(mut self, scope: T) -> ProjectIndexeDocumentDeleteCall<'a, C, A> - where T: AsRef { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - diff --git a/gen/compute1-cli/Cargo.toml b/gen/compute1-cli/Cargo.toml index 701885c837..3f771a67b4 100644 --- a/gen/compute1-cli/Cargo.toml +++ b/gen/compute1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-compute1-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/compute/docs/reference/latest/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/compute1-cli/src/cmn.rs b/gen/compute1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/compute1-cli/src/cmn.rs +++ b/gen/compute1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/compute1-cli/src/main.rs b/gen/compute1-cli/src/main.rs index c5612a405e..ee1654fd5d 100644 --- a/gen/compute1-cli/src/main.rs +++ b/gen/compute1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -177,6 +178,12 @@ Configuration: 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. "); mod cmn; @@ -200,7 +207,7 @@ impl Engine { -> Option { let mut call = self.hub.addresses().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -241,8 +248,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -253,7 +259,7 @@ impl Engine { -> Option { let mut call = self.hub.addresses().delete(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_address); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -285,8 +291,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -297,7 +302,7 @@ impl Engine { -> Option { let mut call = self.hub.addresses().get(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_address); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -329,8 +334,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -339,10 +343,10 @@ impl Engine { fn _addresses_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Address = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -362,9 +366,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -386,9 +391,9 @@ impl Engine { }, "users" => { if request.users.is_none() { - request.users = Some(Default::default()); + request.users = Some(Default::default()); } - request.users.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.users.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -419,8 +424,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -431,7 +435,7 @@ impl Engine { -> Option { let mut call = self.hub.addresses().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -472,8 +476,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -484,7 +487,7 @@ impl Engine { -> Option { let mut call = self.hub.backend_services().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -516,8 +519,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -528,7 +530,7 @@ impl Engine { -> Option { let mut call = self.hub.backend_services().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -560,8 +562,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -570,10 +571,10 @@ impl Engine { fn _backend_services_get_health(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ResourceGroupReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -593,9 +594,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -620,8 +622,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -630,10 +631,10 @@ impl Engine { fn _backend_services_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::BackendService = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -653,9 +654,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -683,9 +685,9 @@ impl Engine { }, "health-checks" => { if request.health_checks.is_none() { - request.health_checks = Some(Default::default()); + request.health_checks = Some(Default::default()); } - request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -716,8 +718,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -728,7 +729,7 @@ impl Engine { -> Option { let mut call = self.hub.backend_services().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -769,8 +770,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -779,10 +779,10 @@ impl Engine { fn _backend_services_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::BackendService = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -802,9 +802,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -832,9 +833,9 @@ impl Engine { }, "health-checks" => { if request.health_checks.is_none() { - request.health_checks = Some(Default::default()); + request.health_checks = Some(Default::default()); } - request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -865,8 +866,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -875,10 +875,10 @@ impl Engine { fn _backend_services_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::BackendService = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -898,9 +898,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -928,9 +929,9 @@ impl Engine { }, "health-checks" => { if request.health_checks.is_none() { - request.health_checks = Some(Default::default()); + request.health_checks = Some(Default::default()); } - request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -961,8 +962,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -973,7 +973,7 @@ impl Engine { -> Option { let mut call = self.hub.disk_types().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1014,8 +1014,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1026,7 +1025,7 @@ impl Engine { -> Option { let mut call = self.hub.disk_types().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_disk_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1058,8 +1057,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1070,7 +1068,7 @@ impl Engine { -> Option { let mut call = self.hub.disk_types().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1111,8 +1109,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1123,7 +1120,7 @@ impl Engine { -> Option { let mut call = self.hub.disks().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1164,8 +1161,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1174,10 +1170,10 @@ impl Engine { fn _disks_create_snapshot(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Snapshot = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1197,9 +1193,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1230,9 +1227,9 @@ impl Engine { }, "licenses" => { if request.licenses.is_none() { - request.licenses = Some(Default::default()); + request.licenses = Some(Default::default()); } - request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -1263,8 +1260,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1275,7 +1271,7 @@ impl Engine { -> Option { let mut call = self.hub.disks().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1307,8 +1303,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1319,7 +1314,7 @@ impl Engine { -> Option { let mut call = self.hub.disks().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1351,8 +1346,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1361,10 +1355,10 @@ impl Engine { fn _disks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Disk = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source-image" => { call = call.source_image(value.unwrap_or("")); @@ -1387,9 +1381,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1426,9 +1421,9 @@ impl Engine { }, "licenses" => { if request.licenses.is_none() { - request.licenses = Some(Default::default()); + request.licenses = Some(Default::default()); } - request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "zone" => { request.zone = Some(value.unwrap_or("").to_string()); @@ -1462,8 +1457,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1474,7 +1468,7 @@ impl Engine { -> Option { let mut call = self.hub.disks().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1515,8 +1509,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1527,7 +1520,7 @@ impl Engine { -> Option { let mut call = self.hub.firewalls().delete(&self.opt.arg_project, &self.opt.arg_firewall); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1559,8 +1552,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1571,7 +1563,7 @@ impl Engine { -> Option { let mut call = self.hub.firewalls().get(&self.opt.arg_project, &self.opt.arg_firewall); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1603,8 +1595,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1613,10 +1604,10 @@ impl Engine { fn _firewalls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Firewall = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1636,9 +1627,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1651,24 +1643,24 @@ impl Engine { }, "source-tags" => { if request.source_tags.is_none() { - request.source_tags = Some(Default::default()); + request.source_tags = Some(Default::default()); } - request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "source-ranges" => { if request.source_ranges.is_none() { - request.source_ranges = Some(Default::default()); + request.source_ranges = Some(Default::default()); } - request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "network" => { request.network = Some(value.unwrap_or("").to_string()); }, "target-tags" => { if request.target_tags.is_none() { - request.target_tags = Some(Default::default()); + request.target_tags = Some(Default::default()); } - request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -1699,8 +1691,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1711,7 +1702,7 @@ impl Engine { -> Option { let mut call = self.hub.firewalls().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1752,8 +1743,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1762,10 +1752,10 @@ impl Engine { fn _firewalls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Firewall = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1785,9 +1775,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1800,24 +1791,24 @@ impl Engine { }, "source-tags" => { if request.source_tags.is_none() { - request.source_tags = Some(Default::default()); + request.source_tags = Some(Default::default()); } - request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "source-ranges" => { if request.source_ranges.is_none() { - request.source_ranges = Some(Default::default()); + request.source_ranges = Some(Default::default()); } - request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "network" => { request.network = Some(value.unwrap_or("").to_string()); }, "target-tags" => { if request.target_tags.is_none() { - request.target_tags = Some(Default::default()); + request.target_tags = Some(Default::default()); } - request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -1848,8 +1839,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1858,10 +1848,10 @@ impl Engine { fn _firewalls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Firewall = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1881,9 +1871,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1896,24 +1887,24 @@ impl Engine { }, "source-tags" => { if request.source_tags.is_none() { - request.source_tags = Some(Default::default()); + request.source_tags = Some(Default::default()); } - request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "source-ranges" => { if request.source_ranges.is_none() { - request.source_ranges = Some(Default::default()); + request.source_ranges = Some(Default::default()); } - request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_ranges.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "network" => { request.network = Some(value.unwrap_or("").to_string()); }, "target-tags" => { if request.target_tags.is_none() { - request.target_tags = Some(Default::default()); + request.target_tags = Some(Default::default()); } - request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.target_tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -1944,8 +1935,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1956,7 +1946,7 @@ impl Engine { -> Option { let mut call = self.hub.forwarding_rules().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1997,8 +1987,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2009,7 +1998,7 @@ impl Engine { -> Option { let mut call = self.hub.forwarding_rules().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2041,8 +2030,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2053,7 +2041,7 @@ impl Engine { -> Option { let mut call = self.hub.forwarding_rules().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2085,8 +2073,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2095,10 +2082,10 @@ impl Engine { fn _forwarding_rules_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ForwardingRule = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2118,9 +2105,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2175,8 +2163,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2187,7 +2174,7 @@ impl Engine { -> Option { let mut call = self.hub.forwarding_rules().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2228,8 +2215,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2238,10 +2224,10 @@ impl Engine { fn _forwarding_rules_set_target(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2261,9 +2247,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2288,8 +2275,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2300,7 +2286,7 @@ impl Engine { -> Option { let mut call = self.hub.global_addresses().delete(&self.opt.arg_project, &self.opt.arg_address); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2332,8 +2318,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2344,7 +2329,7 @@ impl Engine { -> Option { let mut call = self.hub.global_addresses().get(&self.opt.arg_project, &self.opt.arg_address); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2376,8 +2361,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2386,10 +2370,10 @@ impl Engine { fn _global_addresses_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Address = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2409,9 +2393,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2433,9 +2418,9 @@ impl Engine { }, "users" => { if request.users.is_none() { - request.users = Some(Default::default()); + request.users = Some(Default::default()); } - request.users.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.users.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -2466,8 +2451,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2478,7 +2462,7 @@ impl Engine { -> Option { let mut call = self.hub.global_addresses().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2519,8 +2503,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2531,7 +2514,7 @@ impl Engine { -> Option { let mut call = self.hub.global_forwarding_rules().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2563,8 +2546,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2575,7 +2557,7 @@ impl Engine { -> Option { let mut call = self.hub.global_forwarding_rules().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2607,8 +2589,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2617,10 +2598,10 @@ impl Engine { fn _global_forwarding_rules_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ForwardingRule = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2640,9 +2621,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2697,8 +2679,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2709,7 +2690,7 @@ impl Engine { -> Option { let mut call = self.hub.global_forwarding_rules().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2750,8 +2731,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2760,10 +2740,10 @@ impl Engine { fn _global_forwarding_rules_set_target(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2783,9 +2763,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2810,8 +2791,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2822,7 +2802,7 @@ impl Engine { -> Option { let mut call = self.hub.global_operations().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2863,8 +2843,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2875,7 +2854,7 @@ impl Engine { -> Option { let mut call = self.hub.global_operations().delete(&self.opt.arg_project, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2906,7 +2885,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2917,7 +2895,7 @@ impl Engine { -> Option { let mut call = self.hub.global_operations().get(&self.opt.arg_project, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2949,8 +2927,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2961,7 +2938,7 @@ impl Engine { -> Option { let mut call = self.hub.global_operations().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -3002,8 +2979,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3014,7 +2990,7 @@ impl Engine { -> Option { let mut call = self.hub.http_health_checks().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3046,8 +3022,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3058,7 +3033,7 @@ impl Engine { -> Option { let mut call = self.hub.http_health_checks().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3090,8 +3065,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3100,10 +3074,10 @@ impl Engine { fn _http_health_checks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::HttpHealthCheck = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3123,9 +3097,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3186,8 +3161,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3198,7 +3172,7 @@ impl Engine { -> Option { let mut call = self.hub.http_health_checks().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -3239,8 +3213,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3249,10 +3222,10 @@ impl Engine { fn _http_health_checks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::HttpHealthCheck = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3272,9 +3245,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3335,8 +3309,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3345,10 +3318,10 @@ impl Engine { fn _http_health_checks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::HttpHealthCheck = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3368,9 +3341,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3431,8 +3405,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3443,7 +3416,7 @@ impl Engine { -> Option { let mut call = self.hub.images().delete(&self.opt.arg_project, &self.opt.arg_image); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3475,8 +3448,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3485,10 +3457,10 @@ impl Engine { fn _images_deprecate(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::DeprecationStatus = Default::default(); + let mut request = api::DeprecationStatus::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3508,9 +3480,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3547,8 +3520,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3559,7 +3531,7 @@ impl Engine { -> Option { let mut call = self.hub.images().get(&self.opt.arg_project, &self.opt.arg_image); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3591,8 +3563,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3601,10 +3572,10 @@ impl Engine { fn _images_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Image = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3624,9 +3595,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3654,15 +3626,15 @@ impl Engine { }, "raw-disk.container-type" => { request_raw_disk_init(&mut request); - request.raw_disk.as_mut().unwrap().container_type = value.unwrap_or("").to_string(); + request.raw_disk.as_mut().unwrap().container_type = Some(value.unwrap_or("").to_string()); }, "raw-disk.source" => { request_raw_disk_init(&mut request); - request.raw_disk.as_mut().unwrap().source = value.unwrap_or("").to_string(); + request.raw_disk.as_mut().unwrap().source = Some(value.unwrap_or("").to_string()); }, "raw-disk.sha1-checksum" => { request_raw_disk_init(&mut request); - request.raw_disk.as_mut().unwrap().sha1_checksum = value.unwrap_or("").to_string(); + request.raw_disk.as_mut().unwrap().sha1_checksum = Some(value.unwrap_or("").to_string()); }, "deprecated.deleted" => { request_deprecated_init(&mut request); @@ -3703,9 +3675,9 @@ impl Engine { "licenses" => { request_deprecated_init(&mut request); if request.licenses.is_none() { - request.licenses = Some(Default::default()); + request.licenses = Some(Default::default()); } - request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "source-type" => { request_deprecated_init(&mut request); @@ -3744,8 +3716,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3756,7 +3727,7 @@ impl Engine { -> Option { let mut call = self.hub.images().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -3797,8 +3768,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3809,7 +3779,7 @@ impl Engine { -> Option { let mut call = self.hub.instance_templates().delete(&self.opt.arg_project, &self.opt.arg_instance_template); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3841,8 +3811,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3853,7 +3822,7 @@ impl Engine { -> Option { let mut call = self.hub.instance_templates().get(&self.opt.arg_project, &self.opt.arg_instance_template); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3885,8 +3854,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3895,10 +3863,10 @@ impl Engine { fn _instance_templates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InstanceTemplate = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3918,9 +3886,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3930,6 +3899,27 @@ impl Engine { } } + fn request_properties_metadata_init(request: &mut api::InstanceTemplate) { + request_properties_init(request); + if request.properties.as_mut().unwrap().metadata.is_none() { + request.properties.as_mut().unwrap().metadata = Some(Default::default()); + } + } + + fn request_properties_scheduling_init(request: &mut api::InstanceTemplate) { + request_properties_init(request); + if request.properties.as_mut().unwrap().scheduling.is_none() { + request.properties.as_mut().unwrap().scheduling = Some(Default::default()); + } + } + + fn request_properties_tags_init(request: &mut api::InstanceTemplate) { + request_properties_init(request); + if request.properties.as_mut().unwrap().tags.is_none() { + request.properties.as_mut().unwrap().tags = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -3945,42 +3935,42 @@ impl Engine { }, "properties.machine-type" => { request_properties_init(&mut request); - request.properties.as_mut().unwrap().machine_type = value.unwrap_or("").to_string(); + request.properties.as_mut().unwrap().machine_type = Some(value.unwrap_or("").to_string()); }, "properties.description" => { request_properties_init(&mut request); - request.properties.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.properties.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "properties.tags.items" => { - request_properties_init(&mut request); - if request.properties.as_mut().unwrap().tags.items.is_none() { - request.properties.as_mut().unwrap().tags.items = Some(Default::default()); + request_properties_tags_init(&mut request); + if request.properties.as_mut().unwrap().tags.as_mut().unwrap().items.is_none() { + request.properties.as_mut().unwrap().tags.as_mut().unwrap().items = Some(Default::default()); } - request.properties.as_mut().unwrap().tags.items.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.properties.as_mut().unwrap().tags.as_mut().unwrap().items.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "properties.tags.fingerprint" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().tags.fingerprint = Some(value.unwrap_or("").to_string()); + request_properties_tags_init(&mut request); + request.properties.as_mut().unwrap().tags.as_mut().unwrap().fingerprint = Some(value.unwrap_or("").to_string()); }, "properties.scheduling.automatic-restart" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().scheduling.automatic_restart = Some(arg_from_str(value.unwrap_or("false"), err, "properties.scheduling.automatic-restart", "boolean")); + request_properties_scheduling_init(&mut request); + request.properties.as_mut().unwrap().scheduling.as_mut().unwrap().automatic_restart = Some(arg_from_str(value.unwrap_or("false"), err, "properties.scheduling.automatic-restart", "boolean")); }, "properties.scheduling.on-host-maintenance" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().scheduling.on_host_maintenance = Some(value.unwrap_or("").to_string()); + request_properties_scheduling_init(&mut request); + request.properties.as_mut().unwrap().scheduling.as_mut().unwrap().on_host_maintenance = Some(value.unwrap_or("").to_string()); }, "properties.can-ip-forward" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().can_ip_forward = arg_from_str(value.unwrap_or("false"), err, "properties.can-ip-forward", "boolean"); + request_properties_scheduling_init(&mut request); + request.properties.as_mut().unwrap().can_ip_forward = Some(arg_from_str(value.unwrap_or("false"), err, "properties.can-ip-forward", "boolean")); }, "properties.metadata.kind" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().metadata.kind = Some(value.unwrap_or("").to_string()); + request_properties_metadata_init(&mut request); + request.properties.as_mut().unwrap().metadata.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "properties.metadata.fingerprint" => { - request_properties_init(&mut request); - request.properties.as_mut().unwrap().metadata.fingerprint = Some(value.unwrap_or("").to_string()); + request_properties_metadata_init(&mut request); + request.properties.as_mut().unwrap().metadata.as_mut().unwrap().fingerprint = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_properties_init(&mut request); @@ -4007,8 +3997,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4019,7 +4008,7 @@ impl Engine { -> Option { let mut call = self.hub.instance_templates().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4060,8 +4049,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4070,10 +4058,10 @@ impl Engine { fn _instances_add_access_config(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccessConfig = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4093,9 +4081,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4129,8 +4118,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4141,7 +4129,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4182,8 +4170,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4192,10 +4179,10 @@ impl Engine { fn _instances_attach_disk(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AttachedDisk = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4215,9 +4202,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4236,19 +4224,19 @@ impl Engine { }, "initialize-params.disk-size-gb" => { request_initialize_params_init(&mut request); - request.initialize_params.as_mut().unwrap().disk_size_gb = value.unwrap_or("").to_string(); + request.initialize_params.as_mut().unwrap().disk_size_gb = Some(value.unwrap_or("").to_string()); }, "initialize-params.disk-name" => { request_initialize_params_init(&mut request); - request.initialize_params.as_mut().unwrap().disk_name = value.unwrap_or("").to_string(); + request.initialize_params.as_mut().unwrap().disk_name = Some(value.unwrap_or("").to_string()); }, "initialize-params.source-image" => { request_initialize_params_init(&mut request); - request.initialize_params.as_mut().unwrap().source_image = value.unwrap_or("").to_string(); + request.initialize_params.as_mut().unwrap().source_image = Some(value.unwrap_or("").to_string()); }, "initialize-params.disk-type" => { request_initialize_params_init(&mut request); - request.initialize_params.as_mut().unwrap().disk_type = value.unwrap_or("").to_string(); + request.initialize_params.as_mut().unwrap().disk_type = Some(value.unwrap_or("").to_string()); }, "auto-delete" => { request_initialize_params_init(&mut request); @@ -4265,9 +4253,9 @@ impl Engine { "licenses" => { request_initialize_params_init(&mut request); if request.licenses.is_none() { - request.licenses = Some(Default::default()); + request.licenses = Some(Default::default()); } - request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.licenses.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "mode" => { request_initialize_params_init(&mut request); @@ -4302,8 +4290,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4314,7 +4301,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4346,8 +4333,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4358,7 +4344,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().delete_access_config(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance, &self.opt.arg_access_config, &self.opt.arg_network_interface); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4390,8 +4376,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4402,7 +4387,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().detach_disk(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance, &self.opt.arg_device_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4434,8 +4419,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4446,7 +4430,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4478,8 +4462,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4490,8 +4473,11 @@ impl Engine { -> Option { let mut call = self.hub.instances().get_serial_port_output(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { + "port" => { + call = call.port(arg_from_str(value.unwrap_or("-0"), err, "port", "integer")); + }, "alt" |"fields" |"key" @@ -4522,8 +4508,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4532,10 +4517,10 @@ impl Engine { fn _instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Instance = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4555,9 +4540,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4601,9 +4587,9 @@ impl Engine { "tags.items" => { request_tags_init(&mut request); if request.tags.as_mut().unwrap().items.is_none() { - request.tags.as_mut().unwrap().items = Some(Default::default()); + request.tags.as_mut().unwrap().items = Some(Default::default()); } - request.tags.as_mut().unwrap().items.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tags.as_mut().unwrap().items.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "tags.fingerprint" => { request_tags_init(&mut request); @@ -4666,8 +4652,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4678,7 +4663,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4719,8 +4704,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4731,7 +4715,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().reset(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4763,8 +4747,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4776,7 +4759,7 @@ impl Engine { let auto_delete: bool = arg_from_str(&self.opt.arg_auto_delete, err, "", "boolean"); let mut call = self.hub.instances().set_disk_auto_delete(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance, auto_delete, &self.opt.arg_device_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4808,8 +4791,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4818,10 +4800,10 @@ impl Engine { fn _instances_set_metadata(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Metadata = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4841,9 +4823,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4871,8 +4854,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4881,10 +4863,10 @@ impl Engine { fn _instances_set_scheduling(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Scheduling = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4904,9 +4886,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4934,8 +4917,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4944,10 +4926,10 @@ impl Engine { fn _instances_set_tags(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Tags = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4967,18 +4949,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.items.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.items.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "fingerprint" => { request.fingerprint = Some(value.unwrap_or("").to_string()); @@ -5000,8 +4983,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5012,7 +4994,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().start(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5044,8 +5026,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5056,7 +5037,7 @@ impl Engine { -> Option { let mut call = self.hub.instances().stop(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5088,8 +5069,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5100,7 +5080,7 @@ impl Engine { -> Option { let mut call = self.hub.licenses().get(&self.opt.arg_project, &self.opt.arg_license); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5132,8 +5112,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5144,7 +5123,7 @@ impl Engine { -> Option { let mut call = self.hub.machine_types().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -5185,8 +5164,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5197,7 +5175,7 @@ impl Engine { -> Option { let mut call = self.hub.machine_types().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_machine_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5229,8 +5207,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5241,7 +5218,7 @@ impl Engine { -> Option { let mut call = self.hub.machine_types().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -5282,8 +5259,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5294,7 +5270,7 @@ impl Engine { -> Option { let mut call = self.hub.networks().delete(&self.opt.arg_project, &self.opt.arg_network); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5326,8 +5302,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5338,7 +5313,7 @@ impl Engine { -> Option { let mut call = self.hub.networks().get(&self.opt.arg_project, &self.opt.arg_network); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5370,8 +5345,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5380,10 +5354,10 @@ impl Engine { fn _networks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Network = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5403,9 +5377,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5451,8 +5426,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5463,7 +5437,7 @@ impl Engine { -> Option { let mut call = self.hub.networks().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -5504,8 +5478,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5516,7 +5489,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().get(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5548,8 +5521,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5558,10 +5530,10 @@ impl Engine { fn _projects_move_disk(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::DiskMoveRequest = Default::default(); + let mut request = api::DiskMoveRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5581,9 +5553,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5611,8 +5584,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5621,10 +5593,10 @@ impl Engine { fn _projects_move_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InstanceMoveRequest = Default::default(); + let mut request = api::InstanceMoveRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5644,9 +5616,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5674,8 +5647,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5684,10 +5656,10 @@ impl Engine { fn _projects_set_common_instance_metadata(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Metadata = Default::default(); + let mut request = api::Metadata::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5707,9 +5679,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5737,8 +5710,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5747,10 +5719,10 @@ impl Engine { fn _projects_set_usage_export_bucket(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UsageExportLocation = Default::default(); + let mut request = api::UsageExportLocation::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5770,9 +5742,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5800,8 +5773,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5812,7 +5784,7 @@ impl Engine { -> Option { let mut call = self.hub.region_operations().delete(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5843,7 +5815,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -5854,7 +5825,7 @@ impl Engine { -> Option { let mut call = self.hub.region_operations().get(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5886,8 +5857,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5898,7 +5868,7 @@ impl Engine { -> Option { let mut call = self.hub.region_operations().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -5939,8 +5909,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5951,7 +5920,7 @@ impl Engine { -> Option { let mut call = self.hub.regions().get(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5983,8 +5952,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5995,7 +5963,7 @@ impl Engine { -> Option { let mut call = self.hub.regions().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6036,8 +6004,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6048,7 +6015,7 @@ impl Engine { -> Option { let mut call = self.hub.routes().delete(&self.opt.arg_project, &self.opt.arg_route); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6080,8 +6047,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6092,7 +6058,7 @@ impl Engine { -> Option { let mut call = self.hub.routes().get(&self.opt.arg_project, &self.opt.arg_route); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6124,8 +6090,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6134,10 +6099,10 @@ impl Engine { fn _routes_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Route = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6157,9 +6122,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6178,9 +6144,9 @@ impl Engine { }, "tags" => { if request.tags.is_none() { - request.tags = Some(Default::default()); + request.tags = Some(Default::default()); } - request.tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "next-hop-instance" => { request.next_hop_instance = Some(value.unwrap_or("").to_string()); @@ -6229,8 +6195,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6241,7 +6206,7 @@ impl Engine { -> Option { let mut call = self.hub.routes().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6282,8 +6247,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6294,7 +6258,7 @@ impl Engine { -> Option { let mut call = self.hub.snapshots().delete(&self.opt.arg_project, &self.opt.arg_snapshot); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6326,8 +6290,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6338,7 +6301,7 @@ impl Engine { -> Option { let mut call = self.hub.snapshots().get(&self.opt.arg_project, &self.opt.arg_snapshot); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6370,8 +6333,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6382,7 +6344,7 @@ impl Engine { -> Option { let mut call = self.hub.snapshots().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6423,8 +6385,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6435,7 +6396,7 @@ impl Engine { -> Option { let mut call = self.hub.target_http_proxies().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6467,8 +6428,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6479,7 +6439,7 @@ impl Engine { -> Option { let mut call = self.hub.target_http_proxies().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6511,8 +6471,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6521,10 +6480,10 @@ impl Engine { fn _target_http_proxies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetHttpProxy = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6544,9 +6503,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6589,8 +6549,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6601,7 +6560,7 @@ impl Engine { -> Option { let mut call = self.hub.target_http_proxies().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6642,8 +6601,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6652,10 +6610,10 @@ impl Engine { fn _target_http_proxies_set_url_map(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UrlMapReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6675,9 +6633,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6702,8 +6661,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6714,7 +6672,7 @@ impl Engine { -> Option { let mut call = self.hub.target_instances().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6755,8 +6713,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6767,7 +6724,7 @@ impl Engine { -> Option { let mut call = self.hub.target_instances().delete(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_target_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6799,8 +6756,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6811,7 +6767,7 @@ impl Engine { -> Option { let mut call = self.hub.target_instances().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_target_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6843,8 +6799,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6853,10 +6808,10 @@ impl Engine { fn _target_instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetInstance = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6876,9 +6831,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6927,8 +6883,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6939,7 +6894,7 @@ impl Engine { -> Option { let mut call = self.hub.target_instances().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -6980,8 +6935,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6990,10 +6944,10 @@ impl Engine { fn _target_pools_add_health_check(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetPoolsAddHealthCheckRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7013,9 +6967,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7037,8 +6992,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7047,10 +7001,10 @@ impl Engine { fn _target_pools_add_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetPoolsAddInstanceRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7070,9 +7024,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7094,8 +7049,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7106,7 +7060,7 @@ impl Engine { -> Option { let mut call = self.hub.target_pools().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -7147,8 +7101,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7159,7 +7112,7 @@ impl Engine { -> Option { let mut call = self.hub.target_pools().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7191,8 +7144,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7203,7 +7155,7 @@ impl Engine { -> Option { let mut call = self.hub.target_pools().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7235,8 +7187,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7245,10 +7196,10 @@ impl Engine { fn _target_pools_get_health(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InstanceReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7268,9 +7219,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7295,8 +7247,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7305,10 +7256,10 @@ impl Engine { fn _target_pools_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetPool = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7328,9 +7279,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7352,18 +7304,18 @@ impl Engine { }, "instances" => { if request.instances.is_none() { - request.instances = Some(Default::default()); + request.instances = Some(Default::default()); } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "backup-pool" => { request.backup_pool = Some(value.unwrap_or("").to_string()); }, "health-checks" => { if request.health_checks.is_none() { - request.health_checks = Some(Default::default()); + request.health_checks = Some(Default::default()); } - request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.health_checks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-timestamp" => { request.creation_timestamp = Some(value.unwrap_or("").to_string()); @@ -7394,8 +7346,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7406,7 +7357,7 @@ impl Engine { -> Option { let mut call = self.hub.target_pools().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -7447,8 +7398,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7457,10 +7407,10 @@ impl Engine { fn _target_pools_remove_health_check(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetPoolsRemoveHealthCheckRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7480,9 +7430,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7504,8 +7455,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7514,10 +7464,10 @@ impl Engine { fn _target_pools_remove_instance(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetPoolsRemoveInstanceRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7537,9 +7487,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7561,8 +7512,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7571,10 +7521,10 @@ impl Engine { fn _target_pools_set_backup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetReference = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "failover-ratio" => { call = call.failover_ratio(arg_from_str(value.unwrap_or("0.0"), err, "failover-ratio", "number")); @@ -7597,9 +7547,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7624,8 +7575,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7636,7 +7586,7 @@ impl Engine { -> Option { let mut call = self.hub.target_vpn_gateways().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -7677,8 +7627,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7689,7 +7638,7 @@ impl Engine { -> Option { let mut call = self.hub.target_vpn_gateways().delete(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_vpn_gateway); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7721,8 +7670,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7733,7 +7681,7 @@ impl Engine { -> Option { let mut call = self.hub.target_vpn_gateways().get(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_target_vpn_gateway); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7765,8 +7713,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7775,10 +7722,10 @@ impl Engine { fn _target_vpn_gateways_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::TargetVpnGateway = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7798,9 +7745,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7819,15 +7767,15 @@ impl Engine { }, "forwarding-rules" => { if request.forwarding_rules.is_none() { - request.forwarding_rules = Some(Default::default()); + request.forwarding_rules = Some(Default::default()); } - request.forwarding_rules.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.forwarding_rules.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "tunnels" => { if request.tunnels.is_none() { - request.tunnels = Some(Default::default()); + request.tunnels = Some(Default::default()); } - request.tunnels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tunnels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "network" => { request.network = Some(value.unwrap_or("").to_string()); @@ -7861,8 +7809,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7873,7 +7820,7 @@ impl Engine { -> Option { let mut call = self.hub.target_vpn_gateways().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -7914,8 +7861,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7926,7 +7872,7 @@ impl Engine { -> Option { let mut call = self.hub.url_maps().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7958,8 +7904,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7970,7 +7915,7 @@ impl Engine { -> Option { let mut call = self.hub.url_maps().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8002,8 +7947,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8012,10 +7956,10 @@ impl Engine { fn _url_maps_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UrlMap = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8035,9 +7979,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8083,8 +8028,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8095,7 +8039,7 @@ impl Engine { -> Option { let mut call = self.hub.url_maps().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8136,8 +8080,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8146,10 +8089,10 @@ impl Engine { fn _url_maps_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UrlMap = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8169,9 +8112,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8217,8 +8161,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8227,10 +8170,10 @@ impl Engine { fn _url_maps_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UrlMap = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8250,9 +8193,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8298,8 +8242,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8308,10 +8251,10 @@ impl Engine { fn _url_maps_validate(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::UrlMapsValidateRequest = Default::default(); + let mut request = api::UrlMapsValidateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8331,9 +8274,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8393,8 +8337,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8405,7 +8348,7 @@ impl Engine { -> Option { let mut call = self.hub.vpn_tunnels().aggregated_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8446,8 +8389,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8458,7 +8400,7 @@ impl Engine { -> Option { let mut call = self.hub.vpn_tunnels().delete(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_vpn_tunnel); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8490,8 +8432,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8502,7 +8443,7 @@ impl Engine { -> Option { let mut call = self.hub.vpn_tunnels().get(&self.opt.arg_project, &self.opt.arg_region, &self.opt.arg_vpn_tunnel); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8534,8 +8475,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8544,10 +8484,10 @@ impl Engine { fn _vpn_tunnels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::VpnTunnel = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8567,9 +8507,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8618,9 +8559,9 @@ impl Engine { }, "ike-networks" => { if request.ike_networks.is_none() { - request.ike_networks = Some(Default::default()); + request.ike_networks = Some(Default::default()); } - request.ike_networks.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ike_networks.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -8639,8 +8580,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8651,7 +8591,7 @@ impl Engine { -> Option { let mut call = self.hub.vpn_tunnels().list(&self.opt.arg_project, &self.opt.arg_region); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8692,8 +8632,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8704,7 +8643,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().delete(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8735,7 +8674,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -8746,7 +8684,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8778,8 +8716,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8790,7 +8727,7 @@ impl Engine { -> Option { let mut call = self.hub.zone_operations().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8831,8 +8768,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8843,7 +8779,7 @@ impl Engine { -> Option { let mut call = self.hub.zones().get(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8875,8 +8811,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8887,7 +8822,7 @@ impl Engine { -> Option { let mut call = self.hub.zones().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8928,8 +8863,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8955,7 +8889,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_backend_services { + } + else if self.opt.cmd_backend_services { if self.opt.cmd_delete { call_result = self._backend_services_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -8973,7 +8908,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_disk_types { + } + else if self.opt.cmd_disk_types { if self.opt.cmd_aggregated_list { call_result = self._disk_types_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -8983,7 +8919,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_disks { + } + else if self.opt.cmd_disks { if self.opt.cmd_aggregated_list { call_result = self._disks_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_create_snapshot { @@ -8999,7 +8936,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_firewalls { + } + else if self.opt.cmd_firewalls { if self.opt.cmd_delete { call_result = self._firewalls_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9015,7 +8953,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_forwarding_rules { + } + else if self.opt.cmd_forwarding_rules { if self.opt.cmd_aggregated_list { call_result = self._forwarding_rules_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -9031,7 +8970,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_global_addresses { + } + else if self.opt.cmd_global_addresses { if self.opt.cmd_delete { call_result = self._global_addresses_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9043,7 +8983,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_global_forwarding_rules { + } + else if self.opt.cmd_global_forwarding_rules { if self.opt.cmd_delete { call_result = self._global_forwarding_rules_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9057,7 +8998,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_global_operations { + } + else if self.opt.cmd_global_operations { if self.opt.cmd_aggregated_list { call_result = self._global_operations_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -9069,7 +9011,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_http_health_checks { + } + else if self.opt.cmd_http_health_checks { if self.opt.cmd_delete { call_result = self._http_health_checks_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9085,7 +9028,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_images { + } + else if self.opt.cmd_images { if self.opt.cmd_delete { call_result = self._images_delete(dry_run, &mut err); } else if self.opt.cmd_deprecate { @@ -9099,7 +9043,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_instance_templates { + } + else if self.opt.cmd_instance_templates { if self.opt.cmd_delete { call_result = self._instance_templates_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9111,7 +9056,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_instances { + } + else if self.opt.cmd_instances { if self.opt.cmd_add_access_config { call_result = self._instances_add_access_config(dry_run, &mut err); } else if self.opt.cmd_aggregated_list { @@ -9149,13 +9095,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_licenses { + } + else if self.opt.cmd_licenses { if self.opt.cmd_get { call_result = self._licenses_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_machine_types { + } + else if self.opt.cmd_machine_types { if self.opt.cmd_aggregated_list { call_result = self._machine_types_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9165,7 +9113,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_networks { + } + else if self.opt.cmd_networks { if self.opt.cmd_delete { call_result = self._networks_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9177,7 +9126,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_projects { + } + else if self.opt.cmd_projects { if self.opt.cmd_get { call_result = self._projects_get(dry_run, &mut err); } else if self.opt.cmd_move_disk { @@ -9191,7 +9141,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_region_operations { + } + else if self.opt.cmd_region_operations { if self.opt.cmd_delete { call_result = self._region_operations_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9201,7 +9152,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_regions { + } + else if self.opt.cmd_regions { if self.opt.cmd_get { call_result = self._regions_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -9209,7 +9161,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_routes { + } + else if self.opt.cmd_routes { if self.opt.cmd_delete { call_result = self._routes_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9221,7 +9174,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_snapshots { + } + else if self.opt.cmd_snapshots { if self.opt.cmd_delete { call_result = self._snapshots_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9231,7 +9185,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_target_http_proxies { + } + else if self.opt.cmd_target_http_proxies { if self.opt.cmd_delete { call_result = self._target_http_proxies_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9245,7 +9200,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_target_instances { + } + else if self.opt.cmd_target_instances { if self.opt.cmd_aggregated_list { call_result = self._target_instances_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -9259,7 +9215,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_target_pools { + } + else if self.opt.cmd_target_pools { if self.opt.cmd_add_health_check { call_result = self._target_pools_add_health_check(dry_run, &mut err); } else if self.opt.cmd_add_instance { @@ -9285,7 +9242,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_target_vpn_gateways { + } + else if self.opt.cmd_target_vpn_gateways { if self.opt.cmd_aggregated_list { call_result = self._target_vpn_gateways_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -9299,7 +9257,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_url_maps { + } + else if self.opt.cmd_url_maps { if self.opt.cmd_delete { call_result = self._url_maps_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9317,7 +9276,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_vpn_tunnels { + } + else if self.opt.cmd_vpn_tunnels { if self.opt.cmd_aggregated_list { call_result = self._vpn_tunnels_aggregated_list(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -9331,7 +9291,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zone_operations { + } + else if self.opt.cmd_zone_operations { if self.opt.cmd_delete { call_result = self._zone_operations_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -9341,7 +9302,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zones { + } + else if self.opt.cmd_zones { if self.opt.cmd_get { call_result = self._zones_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -9369,21 +9331,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "compute1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "compute1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "compute1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "compute1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Compute::new(hyper::Client::new(), auth), + hub: api::Compute::new(client, auth), }; match engine._doit(true) { @@ -9403,12 +9381,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/compute1/Cargo.toml b/gen/compute1/Cargo.toml index 5f42fd5b94..661c103fca 100644 --- a/gen/compute1/Cargo.toml +++ b/gen/compute1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-compute1" version = "0.1.5+20150326" -authors = ["Sebastian Thiel "] +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" homepage = "https://developers.google.com/compute/docs/reference/latest/" diff --git a/gen/compute1/src/cmn.rs b/gen/compute1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/compute1/src/cmn.rs +++ b/gen/compute1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/compute1/src/lib.rs b/gen/compute1/src/lib.rs index a88dfe614f..d5a5377619 100644 --- a/gen/compute1/src/lib.rs +++ b/gen/compute1/src/lib.rs @@ -562,9 +562,9 @@ impl<'a, C, A> Compute pub struct VpnTunnelsScopedList { /// List of vpn tunnels contained in this scope. #[serde(rename="vpnTunnels")] - pub vpn_tunnels: Vec, + pub vpn_tunnels: Option>, /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: VpnTunnelsScopedListWarning, + pub warning: Option, } impl Part for VpnTunnelsScopedList {} @@ -582,12 +582,12 @@ impl Part for VpnTunnelsScopedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SerialPortOutput { /// [Output Only] Type of the resource. Always compute#serialPortOutput for serial port output. - pub kind: String, + pub kind: Option, /// [Output Only] The contents of the console output. - pub contents: String, + pub contents: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for SerialPortOutput {} @@ -600,9 +600,9 @@ impl ResponseResult for SerialPortOutput {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationsScopedList { /// [Output Only] List of operations contained in this scope. - pub operations: Vec, + pub operations: Option>, /// [Output Only] Informational warning which replaces the list of operations when the list is empty. - pub warning: OperationsScopedListWarning, + pub warning: Option, } impl Part for OperationsScopedList {} @@ -621,16 +621,16 @@ impl Part for OperationsScopedList {} pub struct UrlMapList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of UrlMap resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for UrlMapList {} @@ -643,11 +643,11 @@ impl ResponseResult for UrlMapList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetInstancesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for TargetInstancesScopedListWarning {} @@ -661,11 +661,11 @@ impl Part for TargetInstancesScopedListWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstancesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for InstancesScopedListWarning {} @@ -686,29 +686,29 @@ impl Part for InstancesScopedListWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskType { /// [Output Only] Type of the resource. Always compute#diskType for disk types. - pub kind: String, + pub kind: Option, /// [Output Only] An optional textual description of the resource. - pub description: String, + pub description: Option, /// [Output Only] URL of the zone where the disk type resides. - pub zone: String, + pub zone: Option, /// [Output Only] An optional textual description of the valid disk size, such as "10GB-10TB". #[serde(rename="validDiskSize")] - pub valid_disk_size: String, + pub valid_disk_size: Option, /// [Output Only] The deprecation status associated with this disk type. - pub deprecated: DeprecationStatus, + pub deprecated: Option, /// [Output Only] Server defined default disk size in GB. #[serde(rename="defaultDiskSizeGb")] - pub default_disk_size_gb: String, + pub default_disk_size_gb: Option, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option, } impl Resource for DiskType {} @@ -803,9 +803,9 @@ impl ResponseResult for Instance {} pub struct MachineTypesScopedList { /// [Output Only] List of machine types contained in this scope. #[serde(rename="machineTypes")] - pub machine_types: Vec, + pub machine_types: Option>, /// [Output Only] An informational warning that appears when the machine types list is empty. - pub warning: MachineTypesScopedListWarning, + pub warning: Option, } impl Part for MachineTypesScopedList {} @@ -824,16 +824,16 @@ impl Part for MachineTypesScopedList {} pub struct VpnTunnelAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped vpn tunnel lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for VpnTunnelAggregatedList {} @@ -852,16 +852,16 @@ impl ResponseResult for VpnTunnelAggregatedList {} pub struct OperationAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped operation lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#operationAggregatedList for aggregated lists of operations. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for OperationAggregatedList {} @@ -880,16 +880,16 @@ impl ResponseResult for OperationAggregatedList {} pub struct ImageList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of Image resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for ImageList {} @@ -925,11 +925,11 @@ impl RequestValue for Metadata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskTypesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for DiskTypesScopedListWarning {} @@ -943,9 +943,9 @@ impl Part for DiskTypesScopedListWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ForwardingRulesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for ForwardingRulesScopedListWarningData {} @@ -1040,16 +1040,16 @@ impl ResponseResult for TargetHttpProxy {} pub struct DiskAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped disk lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#diskAggregatedList for aggregated lists of persistent disks. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for DiskAggregatedList {} @@ -1062,9 +1062,9 @@ impl ResponseResult for DiskAggregatedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AddressesScopedList { /// [Output Only] Informational warning which replaces the list of addresses when the list is empty. - pub warning: AddressesScopedListWarning, + pub warning: Option, /// [Output Only] List of addresses contained in this scope. - pub addresses: Vec
, + pub addresses: Option>, } impl Part for AddressesScopedList {} @@ -1085,40 +1085,40 @@ impl Part for AddressesScopedList {} pub struct MachineType { /// [Output Only] The tumber of CPUs exposed to the instance. #[serde(rename="guestCpus")] - pub guest_cpus: i32, + pub guest_cpus: Option, /// [Deprecated] This property is deprecated and will never be populated with any relevant values. #[serde(rename="imageSpaceGb")] - pub image_space_gb: i32, + pub image_space_gb: Option, /// Type of the resource. - pub kind: String, + pub kind: Option, /// [Output Only] An optional textual description of the resource. - pub description: String, + pub description: Option, /// [Output Only] The name of the zone where the machine type resides, such as us-central1-a. - pub zone: String, + pub zone: Option, /// [Output Only] Maximum total persistent disks size (GB) allowed. #[serde(rename="maximumPersistentDisksSizeGb")] - pub maximum_persistent_disks_size_gb: String, + pub maximum_persistent_disks_size_gb: Option, /// [Output Only] The deprecation status associated with this machine type. - pub deprecated: DeprecationStatus, + pub deprecated: Option, /// [Output Only] Maximum persistent disks allowed. #[serde(rename="maximumPersistentDisks")] - pub maximum_persistent_disks: i32, + pub maximum_persistent_disks: Option, /// [Output Only] The amount of physical memory available to the instance, defined in MB. #[serde(rename="memoryMb")] - pub memory_mb: i32, + pub memory_mb: Option, /// [Output Only] List of extended scratch disks assigned to the instance. #[serde(rename="scratchDisks")] - pub scratch_disks: Vec, + pub scratch_disks: Option>, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option, } impl Resource for MachineType {} @@ -1132,9 +1132,9 @@ impl ResponseResult for MachineType {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetadataItems { /// Key for the metadata entry. Keys must conform to the following regexp: [a-zA-Z0-9-_]+, and be less than 128 bytes in length. This is reflected as part of a URL in the metadata server. Additionally, to avoid ambiguity, keys must not conflict with any other metadata keys for the project. - pub key: String, + pub key: Option, /// Value for the metadata entry. These are free-form strings, and only have meaning as interpreted by the image running in the instance. The only restriction placed on values is that their size must be less than or equal to 32768 bytes. - pub value: String, + pub value: Option, } impl NestedType for MetadataItems {} @@ -1148,9 +1148,9 @@ impl Part for MetadataItems {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstancesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for InstancesScopedListWarningData {} @@ -1171,16 +1171,16 @@ impl Part for InstancesScopedListWarningData {} pub struct AddressList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Address resources. - pub items: Vec
, + pub items: Option>, /// [Output Only] Type of resource. Always compute#addressList for lists of addresses. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for AddressList {} @@ -1199,16 +1199,16 @@ impl ResponseResult for AddressList {} pub struct DiskTypeList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Disk Type resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#diskTypeList for disk types. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for DiskTypeList {} @@ -1221,9 +1221,9 @@ impl ResponseResult for DiskTypeList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetVpnGatewaysScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for TargetVpnGatewaysScopedListWarningData {} @@ -1243,16 +1243,16 @@ impl Part for TargetVpnGatewaysScopedListWarningData {} pub struct AddressAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped address lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#addressAggregatedList for aggregated lists of addresses. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for AddressAggregatedList {} @@ -1266,16 +1266,16 @@ impl ResponseResult for AddressAggregatedList {} pub struct UrlMapValidationResult { /// no description provided #[serde(rename="testFailures")] - pub test_failures: Vec, + pub test_failures: Option>, /// no description provided #[serde(rename="loadErrors")] - pub load_errors: Vec, + pub load_errors: Option>, /// Whether the given UrlMap can be successfully loaded. If false, 'loadErrors' indicates the reasons. #[serde(rename="loadSucceeded")] - pub load_succeeded: bool, + pub load_succeeded: Option, /// If successfully loaded, this field indicates whether the test passed. If false, 'testFailures's indicate the reason of failure. #[serde(rename="testPassed")] - pub test_passed: bool, + pub test_passed: Option, } impl Part for UrlMapValidationResult {} @@ -1288,11 +1288,11 @@ impl Part for UrlMapValidationResult {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetPoolsScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for TargetPoolsScopedListWarning {} @@ -1307,14 +1307,14 @@ impl Part for TargetPoolsScopedListWarning {} pub struct PathMatcher { /// The URL to the BackendService resource. This will be used if none of the 'pathRules' defined by this PathMatcher is met by the URL's path portion. #[serde(rename="defaultService")] - pub default_service: String, + pub default_service: Option, /// The list of path rules. #[serde(rename="pathRules")] - pub path_rules: Vec, + pub path_rules: Option>, /// no description provided - pub description: String, + pub description: Option, /// The name to which this PathMatcher is referred by the HostRule. - pub name: String, + pub name: Option, } impl Part for PathMatcher {} @@ -1327,9 +1327,9 @@ impl Part for PathMatcher {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetInstancesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for TargetInstancesScopedListWarningData {} @@ -1349,16 +1349,16 @@ impl Part for TargetInstancesScopedListWarningData {} pub struct SnapshotList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of Snapshot resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for SnapshotList {} @@ -1377,27 +1377,27 @@ impl ResponseResult for SnapshotList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Region { /// [Output Only] Status of the region, either UP or DOWN. - pub status: String, + pub status: Option, /// [Output Only] Type of the resource. Always compute#region for regions. - pub kind: String, + pub kind: Option, /// [Output Only] Textual description of the resource. - pub description: String, + pub description: Option, /// [Output Only] The deprecation status associated with this region. - pub deprecated: DeprecationStatus, + pub deprecated: Option, /// [Output Only] Quotas assigned to this region. - pub quotas: Vec, + pub quotas: Option>, /// [Output Only] A list of zones available in this region, in the form of resource URLs. - pub zones: Vec, + pub zones: Option>, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server . - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option, } impl Resource for Region {} @@ -1411,9 +1411,9 @@ impl ResponseResult for Region {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PathRule { /// The list of path patterns to match. Each must start with / and the only place a * is allowed is at the end following a /. The string fed to the path matcher does not include any text after the first ? or #, and those chars are not allowed here. - pub paths: Vec, + pub paths: Option>, /// The URL of the BackendService resource if this rule is matched. - pub service: String, + pub service: Option, } impl Part for PathRule {} @@ -1426,9 +1426,9 @@ impl Part for PathRule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ServiceAccount { /// The list of scopes to be made available for this service account. - pub scopes: Vec, + pub scopes: Option>, /// Email address of the service account. - pub email: String, + pub email: Option, } impl Part for ServiceAccount {} @@ -1450,27 +1450,27 @@ impl Part for ServiceAccount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Project { /// [Output Only] Type of the resource. Always compute#project for projects. - pub kind: String, + pub kind: Option, /// An optional textual description of the resource. - pub description: String, + pub description: Option, /// Metadata key/value pairs available to all instances contained in this project. See Custom metadata for more information. #[serde(rename="commonInstanceMetadata")] - pub common_instance_metadata: Metadata, + pub common_instance_metadata: Option, /// [Output Only] Quotas assigned to this project. - pub quotas: Vec, + pub quotas: Option>, /// The location in Cloud Storage and naming method of the daily usage report. #[serde(rename="usageExportLocation")] - pub usage_export_location: UsageExportLocation, + pub usage_export_location: Option, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Name of the resource. - pub name: String, + pub name: Option, } impl Resource for Project {} @@ -1484,9 +1484,9 @@ impl ResponseResult for Project {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MachineTypesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for MachineTypesScopedListWarningData {} @@ -1554,10 +1554,10 @@ impl ResponseResult for Snapshot {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskTypesScopedList { /// [Output Only] Informational warning which replaces the list of disk types when the list is empty. - pub warning: DiskTypesScopedListWarning, + pub warning: Option, /// [Output Only] List of disk types contained in this scope. #[serde(rename="diskTypes")] - pub disk_types: Vec, + pub disk_types: Option>, } impl Part for DiskTypesScopedList {} @@ -1631,16 +1631,16 @@ impl ResponseResult for BackendService {} pub struct TargetVpnGatewayAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A map of scoped target vpn gateway lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server-defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetVpnGatewayAggregatedList {} @@ -1677,16 +1677,16 @@ impl RequestValue for ResourceGroupReference {} pub struct MachineTypeList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Machine Type resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#machineTypeList for lists of machine types. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for MachineTypeList {} @@ -1699,9 +1699,9 @@ impl ResponseResult for MachineTypeList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DisksScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for DisksScopedListWarningData {} @@ -1715,9 +1715,9 @@ impl Part for DisksScopedListWarningData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for OperationWarningsData {} @@ -1738,16 +1738,16 @@ impl Part for OperationWarningsData {} pub struct ForwardingRuleList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of ForwardingRule resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for ForwardingRuleList {} @@ -1760,11 +1760,11 @@ impl ResponseResult for ForwardingRuleList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ForwardingRulesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for ForwardingRulesScopedListWarning {} @@ -1784,16 +1784,16 @@ impl Part for ForwardingRulesScopedListWarning {} pub struct FirewallList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Firewall resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#firewallList for lists of firewalls. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for FirewallList {} @@ -1806,13 +1806,13 @@ impl ResponseResult for FirewallList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlMapTest { /// Path portion of the URL. - pub path: String, + pub path: Option, /// Host portion of the URL. - pub host: String, + pub host: Option, /// Description of this test case. - pub description: String, + pub description: Option, /// Expected BackendService resource the given URL should be mapped to. - pub service: String, + pub service: Option, } impl Part for UrlMapTest {} @@ -1825,11 +1825,11 @@ impl Part for UrlMapTest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for OperationWarnings {} @@ -1902,12 +1902,12 @@ impl ResponseResult for Firewall {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HostRule { /// The list of host patterns to match. They must be valid hostnames except that they may start with *. or *-. The * acts like a glob and will match any string of atoms (separated by .s and -s) to the left. - pub hosts: Vec, + pub hosts: Option>, /// no description provided - pub description: String, + pub description: Option, /// The name of the PathMatcher to match the path portion of the URL, if the this HostRule matches the URL's host portion. #[serde(rename="pathMatcher")] - pub path_matcher: String, + pub path_matcher: Option, } impl Part for HostRule {} @@ -1928,16 +1928,16 @@ impl Part for HostRule {} pub struct OperationList { /// [Output Only] A token used to continue a truncate. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] The operation resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#operations for Operations resource. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for OperationList {} @@ -2096,16 +2096,16 @@ impl ResponseResult for Network {} pub struct DiskTypeAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped disk type lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#diskTypeAggregatedList. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for DiskTypeAggregatedList {} @@ -2155,15 +2155,15 @@ impl ResponseResult for InstanceTemplate {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HealthStatus { /// URL of the instance resource. - pub instance: String, + pub instance: Option, /// Health state of the instance. #[serde(rename="healthState")] - pub health_state: String, + pub health_state: Option, /// The IP address represented by this resource. #[serde(rename="ipAddress")] - pub ip_address: String, + pub ip_address: Option, /// The port on the instance. - pub port: i32, + pub port: Option, } impl Part for HealthStatus {} @@ -2182,16 +2182,16 @@ impl Part for HealthStatus {} pub struct MachineTypeAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped machine type lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#machineTypeAggregatedList for aggregated lists of machine types. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for MachineTypeAggregatedList {} @@ -2209,7 +2209,7 @@ impl ResponseResult for MachineTypeAggregatedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlMapsValidateResponse { /// no description provided - pub result: UrlMapValidationResult, + pub result: Option, } impl ResponseResult for UrlMapsValidateResponse {} @@ -2223,9 +2223,9 @@ impl ResponseResult for UrlMapsValidateResponse {} pub struct ForwardingRulesScopedList { /// List of forwarding rules contained in this scope. #[serde(rename="forwardingRules")] - pub forwarding_rules: Vec, + pub forwarding_rules: Option>, /// Informational warning which replaces the list of forwarding rules when the list is empty. - pub warning: ForwardingRulesScopedListWarning, + pub warning: Option, } impl Part for ForwardingRulesScopedList {} @@ -2244,16 +2244,16 @@ impl Part for ForwardingRulesScopedList {} pub struct RouteList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of Route resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for RouteList {} @@ -2344,9 +2344,9 @@ impl ResponseResult for Disk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VpnTunnelsScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for VpnTunnelsScopedListWarningData {} @@ -2366,16 +2366,16 @@ impl Part for VpnTunnelsScopedListWarningData {} pub struct TargetHttpProxyList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of TargetHttpProxy resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetHttpProxyList {} @@ -2475,11 +2475,11 @@ impl RequestValue for DeprecationStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DisksScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for DisksScopedListWarning {} @@ -2499,16 +2499,16 @@ impl Part for DisksScopedListWarning {} pub struct TargetVpnGatewayList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of TargetVpnGateway resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#targetVpnGateway for target VPN gateways. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource. Defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server-defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetVpnGatewayList {} @@ -2527,28 +2527,28 @@ impl ResponseResult for TargetVpnGatewayList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Zone { /// [Output Only] Status of the zone, either UP or DOWN. - pub status: String, + pub status: Option, /// [Output Only] Type of the resource. Always kind#zone for zones. - pub kind: String, + pub kind: Option, /// [Output Only] Textual description of the resource. - pub description: String, + pub description: Option, /// [Output Only] Any scheduled maintenance windows for this zone. When the zone is in a maintenance window, all resources which reside in the zone will be unavailable. For more information, see Maintenance Windows #[serde(rename="maintenanceWindows")] - pub maintenance_windows: Vec, + pub maintenance_windows: Option>, /// [Output Only] The deprecation status associated with this zone. - pub deprecated: DeprecationStatus, + pub deprecated: Option, /// [Output Only] Full URL reference to the region which hosts the zone. - pub region: String, + pub region: Option, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option, } impl Resource for Zone {} @@ -2660,7 +2660,7 @@ impl RequestValue for UrlMapReference {} pub struct MachineTypeScratchDisks { /// Size of the scratch disk, defined in GB. #[serde(rename="diskGb")] - pub disk_gb: i32, + pub disk_gb: Option, } impl NestedType for MachineTypeScratchDisks {} @@ -2680,16 +2680,16 @@ impl Part for MachineTypeScratchDisks {} pub struct TargetInstanceAggregatedList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A map of scoped target instance lists. - pub items: HashMap, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetInstanceAggregatedList {} @@ -2724,11 +2724,11 @@ impl RequestValue for UsageExportLocation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AddressesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for AddressesScopedListWarning {} @@ -2743,7 +2743,7 @@ impl Part for AddressesScopedListWarning {} pub struct HealthCheckReference { /// no description provided #[serde(rename="healthCheck")] - pub health_check: String, + pub health_check: Option, } impl Part for HealthCheckReference {} @@ -2761,10 +2761,10 @@ impl Part for HealthCheckReference {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetPoolInstanceHealth { /// Type of resource. - pub kind: String, + pub kind: Option, /// no description provided #[serde(rename="healthStatus")] - pub health_status: Vec, + pub health_status: Option>, } impl ResponseResult for TargetPoolInstanceHealth {} @@ -2830,16 +2830,16 @@ impl ResponseResult for TargetVpnGateway {} pub struct InstanceAggregatedList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A map of scoped instance lists. - pub items: HashMap, + pub items: Option>, /// [Output Only] Type of resource. Always compute#instanceAggregatedList for aggregated lists of Instance resources. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for InstanceAggregatedList {} @@ -2870,11 +2870,11 @@ impl RequestValue for TargetPoolsAddInstanceRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationsScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for OperationsScopedListWarning {} @@ -2893,10 +2893,10 @@ impl Part for OperationsScopedListWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BackendServiceGroupHealth { /// Type of resource. - pub kind: String, + pub kind: Option, /// no description provided #[serde(rename="healthStatus")] - pub health_status: Vec, + pub health_status: Option>, } impl ResponseResult for BackendServiceGroupHealth {} @@ -2909,11 +2909,11 @@ impl ResponseResult for BackendServiceGroupHealth {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetVpnGatewaysScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for TargetVpnGatewaysScopedListWarning {} @@ -2986,10 +2986,10 @@ impl RequestValue for DiskMoveRequest {} pub struct AttachedDiskInitializeParams { /// Specifies the size of the disk in base-2 GB. #[serde(rename="diskSizeGb")] - pub disk_size_gb: String, + pub disk_size_gb: Option, /// Specifies the disk name. If not specified, the default is to use the name of the instance. #[serde(rename="diskName")] - pub disk_name: String, + pub disk_name: Option, /// A source image used to create the disk. You can provide a private (custom) image, and Compute Engine will use the corresponding image from your project. For example: /// /// global/images/my-private-image @@ -3000,7 +3000,7 @@ pub struct AttachedDiskInitializeParams { /// /// where vYYYYMMDD is the image version. The fully-qualified URL will also work in both cases. #[serde(rename="sourceImage")] - pub source_image: String, + pub source_image: Option, /// Specifies the disk type to use to create the instance. If not specified, the default is pd-standard, specified using the full URL. For example: /// /// https://www.googleapis.com/compute/v1/projects/project/zones/zone/diskTypes/pd-standard @@ -3010,7 +3010,7 @@ pub struct AttachedDiskInitializeParams { /// - projects/project/zones/zone/diskTypes/diskType /// - zones/zone/diskTypes/diskType #[serde(rename="diskType")] - pub disk_type: String, + pub disk_type: Option, } impl Part for AttachedDiskInitializeParams {} @@ -3024,14 +3024,14 @@ impl Part for AttachedDiskInitializeParams {} pub struct ZoneMaintenanceWindows { /// [Output Only] Ending time of the maintenance window, in RFC3339 format. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// [Output Only] Textual description of the maintenance window. - pub description: String, + pub description: Option, /// [Output Only] Starting time of the maintenance window, in RFC3339 format. #[serde(rename="beginTime")] - pub begin_time: String, + pub begin_time: Option, /// [Output Only] Name of the maintenance window. - pub name: String, + pub name: Option, } impl NestedType for ZoneMaintenanceWindows {} @@ -3051,16 +3051,16 @@ impl Part for ZoneMaintenanceWindows {} pub struct InstanceList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Instance resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#instanceList for lists of Instance resources. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for InstanceList {} @@ -3139,9 +3139,9 @@ impl ResponseResult for TargetPool {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetPoolsScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for TargetPoolsScopedListWarningData {} @@ -3155,9 +3155,9 @@ impl Part for TargetPoolsScopedListWarningData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstancesScopedList { /// [Output Only] List of instances contained in this scope. - pub instances: Vec, + pub instances: Option>, /// [Output Only] Informational warning which replaces the list of instances when the list is empty. - pub warning: InstancesScopedListWarning, + pub warning: Option, } impl Part for InstancesScopedList {} @@ -3212,7 +3212,7 @@ impl ResponseResult for Address {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec, + pub errors: Option>, } impl NestedType for OperationError {} @@ -3227,11 +3227,11 @@ impl Part for OperationError {} pub struct FirewallAllowed { /// The IP protocol that is allowed for this rule. The protocol type is required when creating a firewall. This value can either be one of the following well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. #[serde(rename="IPProtocol")] - pub ip_protocol: String, + pub ip_protocol: Option, /// An optional list of ports which are allowed. This field is only applicable for UDP or TCP protocol. Each entry must be either an integer or a range. If not specified, connections through any port are allowed /// /// Example inputs include: ["22"], ["80","443"], and ["12345-12349"]. - pub ports: Vec, + pub ports: Option>, } impl NestedType for FirewallAllowed {} @@ -3270,16 +3270,16 @@ impl RequestValue for TargetPoolsAddHealthCheckRequest {} pub struct NetworkList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Network resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#networkList for lists of networks. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource . #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for NetworkList {} @@ -3298,16 +3298,16 @@ impl ResponseResult for NetworkList {} pub struct ZoneList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Zone resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for ZoneList {} @@ -3320,11 +3320,11 @@ impl ResponseResult for ZoneList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MachineTypesScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for MachineTypesScopedListWarning {} @@ -3362,16 +3362,16 @@ impl RequestValue for InstanceReference {} pub struct InstanceTemplateList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of InstanceTemplate resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for InstanceTemplateList {} @@ -3390,16 +3390,16 @@ impl ResponseResult for InstanceTemplateList {} pub struct TargetInstanceList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of TargetInstance resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetInstanceList {} @@ -3418,16 +3418,16 @@ impl ResponseResult for TargetInstanceList {} pub struct HttpHealthCheckList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of HttpHealthCheck resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for HttpHealthCheckList {} @@ -3446,14 +3446,14 @@ impl ResponseResult for HttpHealthCheckList {} pub struct License { /// If true, the customer will be charged license fee for running software that contains this license on an instance. #[serde(rename="chargesUseFee")] - pub charges_use_fee: bool, + pub charges_use_fee: Option, /// [Output Only] Type of resource. Always compute#license for licenses. - pub kind: String, + pub kind: Option, /// Name of the resource. The name must be 1-63 characters long, and comply with RCF1035. - pub name: String, + pub name: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl Resource for License {} @@ -3513,11 +3513,11 @@ impl RequestValue for AttachedDisk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Quota { /// [Output Only] Current usage of this metric. - pub usage: f64, + pub usage: Option, /// [Output Only] Name of the quota metric. - pub metric: String, + pub metric: Option, /// [Output Only] Quota limit for this metric. - pub limit: f64, + pub limit: Option, } impl Part for Quota {} @@ -3592,9 +3592,9 @@ impl ResponseResult for Route {} pub struct TargetVpnGatewaysScopedList { /// [Output Only] List of target vpn gateways contained in this scope. #[serde(rename="targetVpnGateways")] - pub target_vpn_gateways: Vec, + pub target_vpn_gateways: Option>, /// [Output Only] Informational warning which replaces the list of addresses when the list is empty. - pub warning: TargetVpnGatewaysScopedListWarning, + pub warning: Option, } impl Part for TargetVpnGatewaysScopedList {} @@ -3607,9 +3607,9 @@ impl Part for TargetVpnGatewaysScopedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DiskTypesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for DiskTypesScopedListWarningData {} @@ -3644,12 +3644,12 @@ impl RequestValue for TargetReference {} pub struct NetworkInterface { /// An array of configurations for this interface. Currently, , + pub access_configs: Option>, /// [Output Only] An optional IPV4 internal network address assigned to the instance for this network interface. #[serde(rename="networkIP")] - pub network_ip: String, + pub network_ip: Option, /// [Output Only] The name of the network interface, generated by the server. For network devices, these are eth0, eth1, etc. - pub name: String, + pub name: Option, /// URL of the network resource for this instance. This is required for creating an instance but optional when creating a firewall rule. If not specified when creating a firewall rule, the default network is used: /// /// global/networks/default @@ -3658,7 +3658,7 @@ pub struct NetworkInterface { /// - https://www.googleapis.com/compute/v1/projects/project/global/networks/network /// - projects/project/global/networks/network /// - global/networks/default - pub network: String, + pub network: Option, } impl Part for NetworkInterface {} @@ -3677,16 +3677,16 @@ impl Part for NetworkInterface {} pub struct ForwardingRuleAggregatedList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A map of scoped forwarding rule lists. - pub items: HashMap, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for ForwardingRuleAggregatedList {} @@ -3699,15 +3699,15 @@ impl ResponseResult for ForwardingRuleAggregatedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TestFailure { /// no description provided - pub path: String, + pub path: Option, /// no description provided #[serde(rename="actualService")] - pub actual_service: String, + pub actual_service: Option, /// no description provided - pub host: String, + pub host: Option, /// no description provided #[serde(rename="expectedService")] - pub expected_service: String, + pub expected_service: Option, } impl Part for TestFailure {} @@ -3726,16 +3726,16 @@ impl Part for TestFailure {} pub struct VpnTunnelList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of VpnTunnel resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#vpnTunnel for VPN tunnels. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server-defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for VpnTunnelList {} @@ -3754,16 +3754,16 @@ impl ResponseResult for VpnTunnelList {} pub struct TargetPoolAggregatedList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A map of scoped target pool lists. - pub items: HashMap, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetPoolAggregatedList {} @@ -3777,9 +3777,9 @@ impl ResponseResult for TargetPoolAggregatedList {} pub struct TargetInstancesScopedList { /// List of target instances contained in this scope. #[serde(rename="targetInstances")] - pub target_instances: Vec, + pub target_instances: Option>, /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: TargetInstancesScopedListWarning, + pub warning: Option, } impl Part for TargetInstancesScopedList {} @@ -3843,9 +3843,9 @@ impl ResponseResult for UrlMap {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RouteWarningsData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for RouteWarningsData {} @@ -3938,61 +3938,61 @@ impl Part for RouteWarningsData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// [Output Only] Status of the operation. Can be one of the following: PENDING, RUNNING, or DONE. - pub status: String, + pub status: Option, /// [Output Only] The time that this operation was requested. This is in RFC3339 text format. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option, /// [Output Only] If warning messages are generated during processing of the operation, this field will be populated. - pub warnings: Vec, + pub warnings: Option>, /// [Output Only] If errors are generated during processing of the operation, this field will be populated. - pub error: OperationError, + pub error: Option, /// [Output Only] Unique target ID which identifies a particular incarnation of the target. #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option, /// [Output Only] URL of the resource the operation is mutating. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option, /// [Output Only] The time that this operation was started by the server. This is in RFC3339 text format. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option, /// [Output Only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project #[serde(rename="clientOperationId")] - pub client_operation_id: String, + pub client_operation_id: Option, /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Type of the resource. Always compute#Operation for Operation resources. - pub kind: String, + pub kind: Option, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option, /// [Output Only] URL of the zone where the operation resides. - pub zone: String, + pub zone: Option, /// [Output Only] URL of the region where the operation resides. Only applicable for regional resources. - pub region: String, + pub region: Option, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Output Only] Type of the operation, such as insert, update, and delete. #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option, /// [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as NOT FOUND. #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option, /// [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses. - pub progress: i32, + pub progress: Option, /// [Output Only] The time that this operation was completed. This is in RFC3339 text format. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option, /// [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as 404. #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option, /// [Output Only] An optional textual description of the current status of the operation. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option, /// [Output Only] User who requested the operation, for example: user@example.com. - pub user: String, + pub user: Option, } impl ResponseResult for Operation {} @@ -4029,16 +4029,16 @@ impl RequestValue for TargetPoolsRemoveInstanceRequest {} pub struct TargetPoolList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of TargetPool resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for TargetPoolList {} @@ -4052,26 +4052,26 @@ impl ResponseResult for TargetPoolList {} pub struct InstanceProperties { /// Allows instances created based on this template to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. If these instances will be used as an IP gateway or it will be set as the next-hop in a Route resource, say true. If unsure, leave this set to false. #[serde(rename="canIpForward")] - pub can_ip_forward: bool, + pub can_ip_forward: Option, /// An optional textual description for the instances created based on the instance template resource; provided by the client when the template is created. - pub description: String, + pub description: Option, /// A list of tags to be applied to the instances created based on this template used to identify valid sources or targets for network firewalls. Provided by the client on instance creation. The tags can be later modified by the setTags method. Each tag within the list must comply with RFC1035. - pub tags: Tags, + pub tags: Option, /// Array of disks associated with instance created based on this template. - pub disks: Vec, + pub disks: Option>, /// Scheduling options for the instances created based on this template. - pub scheduling: Scheduling, + pub scheduling: Option, /// Name of the machine type resource describing which machine type to use to host the instances created based on this template; provided by the client when the instance template is created. #[serde(rename="machineType")] - pub machine_type: String, + pub machine_type: Option, /// A list of service accounts each with specified scopes, for which access tokens are to be made available to the instances created based on this template, through metadata queries. #[serde(rename="serviceAccounts")] - pub service_accounts: Vec, + pub service_accounts: Option>, /// Array of configurations for this interface. This specifies how this interface is configured to interact with other network services, such as connecting to the internet. Currently, ONE_TO_ONE_NAT is the only access config supported. If there are no accessConfigs specified, then this instances created based based on this template will have no external internet access. #[serde(rename="networkInterfaces")] - pub network_interfaces: Vec, + pub network_interfaces: Option>, /// Metadata key/value pairs assigned to instances created based on this template. Consists of custom metadata or predefined keys; see Instance documentation for more information. - pub metadata: Metadata, + pub metadata: Option, } impl Part for InstanceProperties {} @@ -4103,9 +4103,9 @@ impl RequestValue for TargetPoolsRemoveHealthCheckRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DisksScopedList { /// [Output Only] List of disks contained in this scope. - pub disks: Vec, + pub disks: Option>, /// [Output Only] Informational warning which replaces the list of disks when the list is empty. - pub warning: DisksScopedListWarning, + pub warning: Option, } impl Part for DisksScopedList {} @@ -4118,11 +4118,11 @@ impl Part for DisksScopedList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VpnTunnelsScopedListWarning { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for VpnTunnelsScopedListWarning {} @@ -4205,16 +4205,16 @@ impl ResponseResult for Image {} pub struct DiskList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of persistent disks. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#diskList for lists of disks. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for DiskList {} @@ -4228,12 +4228,12 @@ impl ResponseResult for DiskList {} pub struct ImageRawDisk { /// The format used to encode and transmit the block device, which should be TAR. This is just a container and transmission format and not a runtime format. Provided by the client when the disk image is created. #[serde(rename="containerType")] - pub container_type: String, + pub container_type: Option, /// The full Google Cloud Storage URL where the disk image is stored. You must provide either this property or the sourceDisk property but not both. - pub source: String, + pub source: Option, /// An optional SHA1 checksum of the disk image before unpackaging; provided by the client when the disk image is created. #[serde(rename="sha1Checksum")] - pub sha1_checksum: String, + pub sha1_checksum: Option, } impl NestedType for ImageRawDisk {} @@ -4247,9 +4247,9 @@ impl Part for ImageRawDisk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationsScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for OperationsScopedListWarningData {} @@ -4269,16 +4269,16 @@ impl Part for OperationsScopedListWarningData {} pub struct BackendServiceList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// A list of BackendService resources. - pub items: Vec, + pub items: Option>, /// Type of resource. - pub kind: String, + pub kind: Option, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for BackendServiceList {} @@ -4291,9 +4291,9 @@ impl ResponseResult for BackendServiceList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AddressesScopedListWarningData { /// [Output Only] A key for the warning data. - pub key: String, + pub key: Option, /// [Output Only] A warning data value corresponding to the key. - pub value: String, + pub value: Option, } impl NestedType for AddressesScopedListWarningData {} @@ -4307,11 +4307,11 @@ impl Part for AddressesScopedListWarningData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option, /// [Output Only] The error type identifier for this error. - pub code: String, + pub code: Option, /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub location: Option, } impl NestedType for OperationErrorErrors {} @@ -4325,11 +4325,11 @@ impl Part for OperationErrorErrors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RouteWarnings { /// [Output Only] Optional human-readable details for this warning. - pub message: String, + pub message: Option, /// [Output Only] The warning type identifier for this warning. - pub code: String, + pub code: Option, /// [Output Only] Metadata for this warning in key: value format. - pub data: Vec, + pub data: Option>, } impl NestedType for RouteWarnings {} @@ -4365,10 +4365,10 @@ impl RequestValue for Scheduling {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetPoolsScopedList { /// Informational warning which replaces the list of addresses when the list is empty. - pub warning: TargetPoolsScopedListWarning, + pub warning: Option, /// List of target pools contained in this scope. #[serde(rename="targetPools")] - pub target_pools: Vec, + pub target_pools: Option>, } impl Part for TargetPoolsScopedList {} @@ -4387,16 +4387,16 @@ impl Part for TargetPoolsScopedList {} pub struct RegionList { /// [Output Only] A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// [Output Only] A list of Region resources. - pub items: Vec, + pub items: Option>, /// [Output Only] Type of resource. Always compute#regionList for lists of regions. - pub kind: String, + pub kind: Option, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option, /// [Output Only] Server defined URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, } impl ResponseResult for RegionList {} @@ -4410,23 +4410,23 @@ impl ResponseResult for RegionList {} pub struct Backend { /// The multiplier (a value between 0 and 1e6) of the max capacity (CPU or RPS, depending on 'balancingMode') the group should serve up to. 0 means the group is totally drained. Default value is 1. Valid range is [0, 1e6]. #[serde(rename="capacityScaler")] - pub capacity_scaler: f32, + pub capacity_scaler: Option, /// The max RPS of the group. Can be used with either balancing mode, but required if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be set. #[serde(rename="maxRate")] - pub max_rate: i32, + pub max_rate: Option, /// URL of a zonal Cloud Resource View resource. This resource view defines the list of instances that serve traffic. Member virtual machine instances from each resource view must live in the same zone as the resource view itself. No two backends in a backend service are allowed to use same Resource View resource. - pub group: String, + pub group: Option, /// An optional textual description of the resource, which is provided by the client when the resource is created. - pub description: String, + pub description: Option, /// Used when 'balancingMode' is UTILIZATION. This ratio defines the CPU utilization target for the group. The default is 0.8. Valid range is [0, 1]. #[serde(rename="maxUtilization")] - pub max_utilization: f32, + pub max_utilization: Option, /// The max RPS that a single backed instance can handle. This is used to calculate the capacity of the group. Can be used in either balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be set. #[serde(rename="maxRatePerInstance")] - pub max_rate_per_instance: f32, + pub max_rate_per_instance: Option, /// The balancing mode of this backend, default is UTILIZATION. #[serde(rename="balancingMode")] - pub balancing_mode: String, + pub balancing_mode: Option, } impl Part for Backend {} @@ -5432,6 +5432,7 @@ impl<'a, C, A> InstanceMethods<'a, C, A> { _project: project.to_string(), _zone: zone.to_string(), _instance: instance.to_string(), + _port: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -8743,16 +8744,20 @@ impl<'a, C, A> DiskDeleteCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -9008,16 +9013,20 @@ impl<'a, C, A> DiskAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9276,16 +9285,20 @@ impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9456,7 +9469,7 @@ impl<'a, C, A> DiskListCall<'a, C, A> where C: BorrowMut, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Disk = Default::default(); +/// let mut req = Disk::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9555,16 +9568,20 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9734,7 +9751,7 @@ impl<'a, C, A> DiskInsertCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Snapshot = Default::default(); +/// let mut req = Snapshot::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9830,16 +9847,20 @@ impl<'a, C, A> DiskCreateSnapshotCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10097,16 +10118,20 @@ impl<'a, C, A> DiskGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10364,16 +10389,20 @@ impl<'a, C, A> AddresseListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10640,16 +10669,20 @@ impl<'a, C, A> AddresseAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10895,16 +10928,20 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11064,7 +11101,7 @@ impl<'a, C, A> AddresseGetCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Address = Default::default(); +/// let mut req = Address::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11158,16 +11195,20 @@ impl<'a, C, A> AddresseInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11415,16 +11456,20 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11584,7 +11629,7 @@ impl<'a, C, A> AddresseDeleteCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UrlMap = Default::default(); +/// let mut req = UrlMap::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11676,16 +11721,20 @@ impl<'a, C, A> UrlMapInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11921,16 +11970,20 @@ impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12080,7 +12133,7 @@ impl<'a, C, A> UrlMapGetCall<'a, C, A> where C: BorrowMut, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UrlMapsValidateRequest = Default::default(); +/// let mut req = UrlMapsValidateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12174,16 +12227,20 @@ impl<'a, C, A> UrlMapValidateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12442,16 +12499,20 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12612,7 +12673,7 @@ impl<'a, C, A> UrlMapListCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UrlMap = Default::default(); +/// let mut req = UrlMap::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12706,16 +12767,20 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12878,7 +12943,7 @@ impl<'a, C, A> UrlMapPatchCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UrlMap = Default::default(); +/// let mut req = UrlMap::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12972,16 +13037,20 @@ impl<'a, C, A> UrlMapUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13227,16 +13296,20 @@ impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13386,7 +13459,7 @@ impl<'a, C, A> UrlMapDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Address = Default::default(); +/// let mut req = Address::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13478,16 +13551,20 @@ impl<'a, C, A> GlobalAddresseInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13736,16 +13813,20 @@ impl<'a, C, A> GlobalAddresseListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13989,16 +14070,20 @@ impl<'a, C, A> GlobalAddresseGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14231,16 +14316,20 @@ impl<'a, C, A> GlobalAddresseDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -14473,16 +14562,20 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14728,16 +14821,20 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14981,16 +15078,20 @@ impl<'a, C, A> SnapshotDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -15225,16 +15326,20 @@ impl<'a, C, A> DiskTypeGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15490,16 +15595,20 @@ impl<'a, C, A> DiskTypeAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15758,16 +15867,20 @@ impl<'a, C, A> DiskTypeListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16021,16 +16134,20 @@ impl<'a, C, A> ZoneGetCall<'a, C, A> where C: BorrowMut, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16276,16 +16393,20 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16446,7 +16567,7 @@ impl<'a, C, A> ZoneListCall<'a, C, A> where C: BorrowMut, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Scheduling = Default::default(); +/// let mut req = Scheduling::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16542,16 +16663,20 @@ impl<'a, C, A> InstanceSetSchedulingCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16809,16 +16934,20 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -16978,6 +17107,7 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.instances().get_serial_port_output("project", "zone", "instance") +/// .port(-38) /// .doit(); /// # } /// ``` @@ -16988,6 +17118,7 @@ pub struct InstanceGetSerialPortOutputCall<'a, C, A> _project: String, _zone: String, _instance: String, + _port: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -17009,11 +17140,14 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("project", self._project.to_string())); params.push(("zone", self._zone.to_string())); params.push(("instance", self._instance.to_string())); - for &field in ["alt", "project", "zone", "instance"].iter() { + if let Some(value) = self._port { + params.push(("port", value.to_string())); + } + for &field in ["alt", "project", "zone", "instance", "port"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -17063,16 +17197,20 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17153,6 +17291,13 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut InstanceGetSerialPortOutputCall<'a, C, A> { + self._port = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -17231,7 +17376,7 @@ impl<'a, C, A> InstanceGetSerialPortOutputCall<'a, C, A> where C: BorrowMut InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -17510,7 +17659,7 @@ impl<'a, C, A> InstanceSetDiskAutoDeleteCall<'a, C, A> where C: BorrowMut InstanceAddAccessConfigCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17885,16 +18038,20 @@ impl<'a, C, A> InstanceStartCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -18139,16 +18296,20 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18308,7 +18469,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Tags = Default::default(); +/// let mut req = Tags::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -18404,16 +18565,20 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18586,7 +18751,7 @@ impl<'a, C, A> InstanceSetTagCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Metadata = Default::default(); +/// let mut req = Metadata::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -18682,16 +18847,20 @@ impl<'a, C, A> InstanceSetMetadataCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18951,16 +19120,20 @@ impl<'a, C, A> InstanceDetachDiskCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -19215,16 +19388,20 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -19384,7 +19561,7 @@ impl<'a, C, A> InstanceStopCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Instance = Default::default(); +/// let mut req = Instance::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19478,16 +19655,20 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19735,16 +19916,20 @@ impl<'a, C, A> InstanceResetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -19993,16 +20178,20 @@ impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -20182,7 +20371,7 @@ impl<'a, C, A> InstanceDeleteAccessConfigCall<'a, C, A> where C: BorrowMut InstanceAttachDiskCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20460,9 +20653,9 @@ impl<'a, C, A> InstanceAttachDiskCall<'a, C, A> where C: BorrowMut InstanceListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -20737,8 +20934,8 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut, A: /// // Values shown here are possibly random and not representative ! /// let result = hub.instances().aggregated_list("project") /// .page_token("Lorem") -/// .max_results(51) -/// .filter("diam") +/// .max_results(59) +/// .filter("ut") /// .doit(); /// # } /// ``` @@ -20832,16 +21029,20 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21002,7 +21203,7 @@ impl<'a, C, A> InstanceAggregatedListCall<'a, C, A> where C: BorrowMut BackendServiceGetHealthCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21350,16 +21555,20 @@ impl<'a, C, A> BackendServiceDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -21592,16 +21801,20 @@ impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21751,7 +21964,7 @@ impl<'a, C, A> BackendServiceGetCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BackendService = Default::default(); +/// let mut req = BackendService::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -21845,16 +22058,20 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22017,9 +22234,9 @@ impl<'a, C, A> BackendServiceUpdateCall<'a, C, A> where C: BorrowMut BackendServiceListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22283,7 +22504,7 @@ impl<'a, C, A> BackendServiceListCall<'a, C, A> where C: BorrowMut BackendServicePatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22549,7 +22774,7 @@ impl<'a, C, A> BackendServicePatchCall<'a, C, A> where C: BorrowMut BackendServiceInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22886,16 +23115,20 @@ impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23045,7 +23278,7 @@ impl<'a, C, A> LicenseGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Network = Default::default(); +/// let mut req = Network::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -23137,16 +23370,20 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -23299,9 +23536,9 @@ impl<'a, C, A> NetworkInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.networks().list("project") -/// .page_token("justo") -/// .max_results(67) -/// .filter("vero") +/// .page_token("dolore") +/// .max_results(75) +/// .filter("dolor") /// .doit(); /// # } /// ``` @@ -23395,16 +23632,20 @@ impl<'a, C, A> NetworkListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23648,16 +23889,20 @@ impl<'a, C, A> NetworkDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -23890,16 +24135,20 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -24049,9 +24298,9 @@ impl<'a, C, A> NetworkGetCall<'a, C, A> where C: BorrowMut, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.global_operations().list("project") -/// .page_token("sed") -/// .max_results(91) -/// .filter("invidunt") +/// .page_token("no") +/// .max_results(63) +/// .filter("rebum.") /// .doit(); /// # } /// ``` @@ -24145,16 +24394,20 @@ impl<'a, C, A> GlobalOperationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -24398,16 +24651,20 @@ impl<'a, C, A> GlobalOperationGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -24639,16 +24896,20 @@ impl<'a, C, A> GlobalOperationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -24788,9 +25049,9 @@ impl<'a, C, A> GlobalOperationDeleteCall<'a, C, A> where C: BorrowMut GlobalOperationAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25054,9 +25319,9 @@ impl<'a, C, A> GlobalOperationAggregatedListCall<'a, C, A> where C: BorrowMut RegionListCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25403,16 +25672,20 @@ impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25562,9 +25835,9 @@ impl<'a, C, A> RegionGetCall<'a, C, A> where C: BorrowMut, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.forwarding_rules().aggregated_list("project") -/// .page_token("aliquyam") -/// .max_results(7) -/// .filter("ea") +/// .page_token("elitr") +/// .max_results(85) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -25658,16 +25931,20 @@ impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25828,7 +26105,7 @@ impl<'a, C, A> ForwardingRuleAggregatedListCall<'a, C, A> where C: BorrowMut ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -26094,7 +26375,7 @@ impl<'a, C, A> ForwardingRuleInsertCall<'a, C, A> where C: BorrowMut ForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -26457,16 +26742,20 @@ impl<'a, C, A> ForwardingRuleGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26626,9 +26915,9 @@ impl<'a, C, A> ForwardingRuleGetCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.forwarding_rules().list("project", "region") -/// .page_token("labore") -/// .max_results(40) -/// .filter("et") +/// .page_token("gubergren") +/// .max_results(28) +/// .filter("sadipscing") /// .doit(); /// # } /// ``` @@ -26724,16 +27013,20 @@ impl<'a, C, A> ForwardingRuleListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26989,16 +27282,20 @@ impl<'a, C, A> ForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -27158,9 +27455,9 @@ impl<'a, C, A> ForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut TargetPoolListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -27436,7 +27737,7 @@ impl<'a, C, A> TargetPoolListCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TargetPoolsAddHealthCheckRequest = Default::default(); +/// let mut req = TargetPoolsAddHealthCheckRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -27532,16 +27833,20 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -27713,7 +28018,7 @@ impl<'a, C, A> TargetPoolAddHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -27979,7 +28288,7 @@ impl<'a, C, A> TargetPoolInsertCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TargetPoolsRemoveHealthCheckRequest = Default::default(); +/// let mut req = TargetPoolsRemoveHealthCheckRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -28075,16 +28384,20 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -28256,7 +28569,7 @@ impl<'a, C, A> TargetPoolRemoveHealthCheckCall<'a, C, A> where C: BorrowMut TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -28533,13 +28850,13 @@ impl<'a, C, A> TargetPoolGetHealthCall<'a, C, A> where C: BorrowMut TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -28823,9 +29144,9 @@ impl<'a, C, A> TargetPoolSetBackupCall<'a, C, A> where C: BorrowMut TargetPoolAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -29174,16 +29499,20 @@ impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -29343,7 +29672,7 @@ impl<'a, C, A> TargetPoolGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TargetPoolsAddInstanceRequest = Default::default(); +/// let mut req = TargetPoolsAddInstanceRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -29439,16 +29768,20 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -29620,7 +29953,7 @@ impl<'a, C, A> TargetPoolAddInstanceCall<'a, C, A> where C: BorrowMut TargetPoolRemoveInstanceCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -29982,16 +30319,20 @@ impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -30151,9 +30492,9 @@ impl<'a, C, A> TargetPoolDeleteCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.target_instances().list("project", "zone") -/// .page_token("amet.") -/// .max_results(83) -/// .filter("dolores") +/// .page_token("dolores") +/// .max_results(32) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -30249,16 +30590,20 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -30429,7 +30774,7 @@ impl<'a, C, A> TargetInstanceListCall<'a, C, A> where C: BorrowMut TargetInstanceInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -30695,9 +31044,9 @@ impl<'a, C, A> TargetInstanceInsertCall<'a, C, A> where C: BorrowMut TargetInstanceAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -31046,16 +31399,20 @@ impl<'a, C, A> TargetInstanceGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -31300,16 +31657,20 @@ impl<'a, C, A> TargetInstanceDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -31552,16 +31913,20 @@ impl<'a, C, A> GlobalForwardingRuleGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -31794,16 +32159,20 @@ impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -31953,7 +32322,7 @@ impl<'a, C, A> GlobalForwardingRuleDeleteCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -32219,7 +32592,7 @@ impl<'a, C, A> GlobalForwardingRuleSetTargetCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -32473,9 +32850,9 @@ impl<'a, C, A> GlobalForwardingRuleInsertCall<'a, C, A> where C: BorrowMut GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -32739,9 +33120,9 @@ impl<'a, C, A> GlobalForwardingRuleListCall<'a, C, A> where C: BorrowMut ImageListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -33088,16 +33473,20 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -33249,7 +33638,7 @@ impl<'a, C, A> ImageDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DeprecationStatus = Default::default(); +/// let mut req = DeprecationStatus::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -33343,16 +33732,20 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -33515,7 +33908,7 @@ impl<'a, C, A> ImageDeprecateCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Image = Default::default(); +/// let mut req = Image::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -33607,16 +34000,20 @@ impl<'a, C, A> ImageInsertCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -33852,16 +34249,20 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34011,9 +34412,9 @@ impl<'a, C, A> ImageGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.machine_types().aggregated_list("project") -/// .page_token("et") -/// .max_results(37) -/// .filter("sed") +/// .page_token("clita") +/// .max_results(21) +/// .filter("dolores") /// .doit(); /// # } /// ``` @@ -34107,16 +34508,20 @@ impl<'a, C, A> MachineTypeAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34362,16 +34767,20 @@ impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34531,9 +34940,9 @@ impl<'a, C, A> MachineTypeGetCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.machine_types().list("project", "zone") -/// .page_token("takimata") -/// .max_results(48) -/// .filter("labore") +/// .page_token("sit") +/// .max_results(15) +/// .filter("nonumy") /// .doit(); /// # } /// ``` @@ -34629,16 +35038,20 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34809,9 +35222,9 @@ impl<'a, C, A> MachineTypeListCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.target_vpn_gateways().aggregated_list("project") -/// .page_token("erat") -/// .max_results(90) -/// .filter("erat") +/// .page_token("gubergren") +/// .max_results(71) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -34905,16 +35318,20 @@ impl<'a, C, A> TargetVpnGatewayAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35160,16 +35577,20 @@ impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35329,9 +35750,9 @@ impl<'a, C, A> TargetVpnGatewayGetCall<'a, C, A> where C: BorrowMut TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35607,7 +36032,7 @@ impl<'a, C, A> TargetVpnGatewayListCall<'a, C, A> where C: BorrowMut TargetVpnGatewayInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -35958,16 +36387,20 @@ impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -36127,7 +36560,7 @@ impl<'a, C, A> TargetVpnGatewayDeleteCall<'a, C, A> where C: BorrowMut ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -36381,7 +36818,7 @@ impl<'a, C, A> ProjectMoveDiskCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Metadata = Default::default(); +/// let mut req = Metadata::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -36473,16 +36910,20 @@ impl<'a, C, A> ProjectSetCommonInstanceMetadataCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -36716,16 +37157,20 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -36865,7 +37310,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceMoveRequest = Default::default(); +/// let mut req = InstanceMoveRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -36957,16 +37402,20 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -37119,7 +37568,7 @@ impl<'a, C, A> ProjectMoveInstanceCall<'a, C, A> where C: BorrowMut ProjectSetUsageExportBucketCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -37456,16 +37909,20 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -37615,7 +38072,7 @@ impl<'a, C, A> HttpHealthCheckGetCall<'a, C, A> where C: BorrowMut HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -37881,9 +38342,9 @@ impl<'a, C, A> HttpHealthCheckPatchCall<'a, C, A> where C: BorrowMut HttpHealthCheckListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -38230,16 +38695,20 @@ impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -38389,7 +38858,7 @@ impl<'a, C, A> HttpHealthCheckDeleteCall<'a, C, A> where C: BorrowMut HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -38643,7 +39116,7 @@ impl<'a, C, A> HttpHealthCheckInsertCall<'a, C, A> where C: BorrowMut HttpHealthCheckUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -38992,16 +39469,20 @@ impl<'a, C, A> InstanceTemplateDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -39234,16 +39715,20 @@ impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -39393,9 +39878,9 @@ impl<'a, C, A> InstanceTemplateGetCall<'a, C, A> where C: BorrowMut InstanceTemplateListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -39659,7 +40148,7 @@ impl<'a, C, A> InstanceTemplateListCall<'a, C, A> where C: BorrowMut InstanceTemplateInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -39996,16 +40489,20 @@ impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -40155,9 +40652,9 @@ impl<'a, C, A> TargetHttpProxyDeleteCall<'a, C, A> where C: BorrowMut TargetHttpProxyListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -40504,16 +41005,20 @@ impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -40663,7 +41168,7 @@ impl<'a, C, A> TargetHttpProxyGetCall<'a, C, A> where C: BorrowMut TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -40929,7 +41438,7 @@ impl<'a, C, A> TargetHttpProxySetUrlMapCall<'a, C, A> where C: BorrowMut TargetHttpProxyInsertCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -41267,16 +41780,20 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -41426,9 +41943,9 @@ impl<'a, C, A> ZoneOperationDeleteCall<'a, C, A> where C: BorrowMut ZoneOperationListCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -41789,16 +42310,20 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -42041,16 +42566,20 @@ impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -42200,7 +42729,7 @@ impl<'a, C, A> RouteGetCall<'a, C, A> where C: BorrowMut, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Route = Default::default(); +/// let mut req = Route::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -42292,16 +42821,20 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -42454,9 +42987,9 @@ impl<'a, C, A> RouteInsertCall<'a, C, A> where C: BorrowMut, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.routes().list("project") -/// .page_token("nonumy") -/// .max_results(18) -/// .filter("ea") +/// .page_token("magna") +/// .max_results(35) +/// .filter("sea") /// .doit(); /// # } /// ``` @@ -42550,16 +43083,20 @@ impl<'a, C, A> RouteListCall<'a, C, A> where C: BorrowMut, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -42803,16 +43340,20 @@ impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -42962,7 +43503,7 @@ impl<'a, C, A> RouteDeleteCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Firewall = Default::default(); +/// let mut req = Firewall::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -43056,16 +43597,20 @@ impl<'a, C, A> FirewallPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -43311,16 +43856,20 @@ impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -43470,7 +44019,7 @@ impl<'a, C, A> FirewallGetCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Firewall = Default::default(); +/// let mut req = Firewall::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -43562,16 +44111,20 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -43724,7 +44277,7 @@ impl<'a, C, A> FirewallInsertCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Firewall = Default::default(); +/// let mut req = Firewall::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -43818,16 +44371,20 @@ impl<'a, C, A> FirewallUpdateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -44073,16 +44630,20 @@ impl<'a, C, A> FirewallDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -44232,9 +44793,9 @@ impl<'a, C, A> FirewallDeleteCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.firewalls().list("project") -/// .page_token("ipsum") -/// .max_results(77) -/// .filter("nonumy") +/// .page_token("eos") +/// .max_results(10) +/// .filter("sanctus") /// .doit(); /// # } /// ``` @@ -44328,16 +44889,20 @@ impl<'a, C, A> FirewallListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -44583,16 +45148,20 @@ impl<'a, C, A> VpnTunnelDeleteCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -44752,9 +45321,9 @@ impl<'a, C, A> VpnTunnelDeleteCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.vpn_tunnels().list("project", "region") -/// .page_token("voluptua.") -/// .max_results(95) -/// .filter("consetetur") +/// .page_token("est") +/// .max_results(5) +/// .filter("tempor") /// .doit(); /// # } /// ``` @@ -44850,16 +45419,20 @@ impl<'a, C, A> VpnTunnelListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45115,16 +45688,20 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45284,7 +45861,7 @@ impl<'a, C, A> VpnTunnelGetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: VpnTunnel = Default::default(); +/// let mut req = VpnTunnel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -45378,16 +45955,20 @@ impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -45550,9 +46131,9 @@ impl<'a, C, A> VpnTunnelInsertCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.vpn_tunnels().aggregated_list("project") -/// .page_token("et") -/// .max_results(62) -/// .filter("ea") +/// .page_token("eirmod") +/// .max_results(34) +/// .filter("et") /// .doit(); /// # } /// ``` @@ -45646,16 +46227,20 @@ impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45816,9 +46401,9 @@ impl<'a, C, A> VpnTunnelAggregatedListCall<'a, C, A> where C: BorrowMut RegionOperationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -46178,16 +46767,20 @@ impl<'a, C, A> RegionOperationDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -46422,16 +47015,20 @@ impl<'a, C, A> RegionOperationGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/container1_beta1-cli/Cargo.toml b/gen/container1_beta1-cli/Cargo.toml index 8b239c0f37..ec5a4d72bb 100644 --- a/gen/container1_beta1-cli/Cargo.toml +++ b/gen/container1_beta1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-container1_beta1-cli" -version = "0.0.1+20150318" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://cloud.google.com/container-engine/docs/v1beta1/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/container1_beta1-cli/mkdocs.yml b/gen/container1_beta1-cli/mkdocs.yml index 6b3b22c8ef..dda10ae786 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+20150318 +site_name: container v0.0.1+20150420 site_url: http://byron.github.io/google-apis-rs/google-container1_beta1-cli site_description: Write integrating applications with bcore @@ -17,6 +17,7 @@ pages: - ['projects_zones-clusters-list.md', 'Projects', 'Zones Clusters List'] - ['projects_zones-operations-get.md', 'Projects', 'Zones Operations Get'] - ['projects_zones-operations-list.md', 'Projects', 'Zones Operations List'] +- ['projects_zones-tokens-get.md', 'Projects', 'Zones Tokens Get'] theme: readthedocs diff --git a/gen/container1_beta1-cli/src/cmn.rs b/gen/container1_beta1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/container1_beta1-cli/src/cmn.rs +++ b/gen/container1_beta1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/container1_beta1-cli/src/main.rs b/gen/container1_beta1-cli/src/main.rs index 8763a7cd8a..6aa2f1e845 100644 --- a/gen/container1_beta1-cli/src/main.rs +++ b/gen/container1_beta1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -26,6 +27,7 @@ Usage: 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: @@ -39,6 +41,12 @@ Configuration: 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. "); mod cmn; @@ -62,7 +70,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().clusters_list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -94,8 +102,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -106,7 +113,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().operations_list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -138,8 +145,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -148,10 +154,10 @@ impl Engine { fn _projects_zones_clusters_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::CreateClusterRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -171,9 +177,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -183,82 +190,100 @@ impl Engine { } } + fn request_cluster_master_auth_init(request: &mut api::CreateClusterRequest) { + request_cluster_init(request); + if request.cluster.as_mut().unwrap().master_auth.is_none() { + request.cluster.as_mut().unwrap().master_auth = Some(Default::default()); + } + } + + fn request_cluster_node_config_init(request: &mut api::CreateClusterRequest) { + request_cluster_init(request); + if request.cluster.as_mut().unwrap().node_config.is_none() { + request.cluster.as_mut().unwrap().node_config = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "cluster.status" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.cluster.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "cluster.container-ipv4-cidr" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().container_ipv4_cidr = value.unwrap_or("").to_string(); + request.cluster.as_mut().unwrap().container_ipv4_cidr = Some(value.unwrap_or("").to_string()); }, "cluster.description" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.cluster.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "cluster.zone" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().zone = value.unwrap_or("").to_string(); + request.cluster.as_mut().unwrap().zone = Some(value.unwrap_or("").to_string()); }, "cluster.num-nodes" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().num_nodes = arg_from_str(value.unwrap_or("-0"), err, "cluster.num-nodes", "integer"); + request.cluster.as_mut().unwrap().num_nodes = Some(arg_from_str(value.unwrap_or("-0"), err, "cluster.num-nodes", "integer")); }, "cluster.node-routing-prefix-size" => { request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().node_routing_prefix_size = arg_from_str(value.unwrap_or("-0"), err, "cluster.node-routing-prefix-size", "integer"); + request.cluster.as_mut().unwrap().node_routing_prefix_size = Some(arg_from_str(value.unwrap_or("-0"), err, "cluster.node-routing-prefix-size", "integer")); + }, + "cluster.master-auth.bearer-token" => { + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().master_auth.as_mut().unwrap().bearer_token = Some(value.unwrap_or("").to_string()); }, "cluster.master-auth.password" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().master_auth.password = value.unwrap_or("").to_string(); + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().master_auth.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "cluster.master-auth.user" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().master_auth.user = value.unwrap_or("").to_string(); + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().master_auth.as_mut().unwrap().user = Some(value.unwrap_or("").to_string()); }, "cluster.cluster-api-version" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().cluster_api_version = value.unwrap_or("").to_string(); + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().cluster_api_version = Some(value.unwrap_or("").to_string()); }, "cluster.network" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().network = value.unwrap_or("").to_string(); + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().network = Some(value.unwrap_or("").to_string()); }, "cluster.endpoint" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().endpoint = value.unwrap_or("").to_string(); + request_cluster_master_auth_init(&mut request); + request.cluster.as_mut().unwrap().endpoint = Some(value.unwrap_or("").to_string()); }, "cluster.node-config.machine-type" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().node_config.machine_type = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().node_config.as_mut().unwrap().machine_type = Some(value.unwrap_or("").to_string()); }, "cluster.node-config.source-image" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().node_config.source_image = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().node_config.as_mut().unwrap().source_image = Some(value.unwrap_or("").to_string()); }, "cluster.status-message" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().status_message = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().status_message = Some(value.unwrap_or("").to_string()); }, "cluster.services-ipv4-cidr" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().services_ipv4_cidr = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().services_ipv4_cidr = Some(value.unwrap_or("").to_string()); }, "cluster.creation-timestamp" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().creation_timestamp = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().creation_timestamp = Some(value.unwrap_or("").to_string()); }, "cluster.enable-cloud-logging" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().enable_cloud_logging = arg_from_str(value.unwrap_or("false"), err, "cluster.enable-cloud-logging", "boolean"); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().enable_cloud_logging = Some(arg_from_str(value.unwrap_or("false"), err, "cluster.enable-cloud-logging", "boolean")); }, "cluster.self-link" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "cluster.name" => { - request_cluster_init(&mut request); - request.cluster.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request_cluster_node_config_init(&mut request); + request.cluster.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -277,8 +302,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -289,7 +313,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().zones_clusters_delete(&self.opt.arg_project_id, &self.opt.arg_zone_id, &self.opt.arg_cluster_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -321,8 +345,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -333,7 +356,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().zones_clusters_get(&self.opt.arg_project_id, &self.opt.arg_zone_id, &self.opt.arg_cluster_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -365,8 +388,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -377,7 +399,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().zones_clusters_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -409,8 +431,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -421,7 +442,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().zones_operations_get(&self.opt.arg_project_id, &self.opt.arg_zone_id, &self.opt.arg_operation_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -453,8 +474,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -465,7 +485,7 @@ impl Engine { -> Option { let mut call = self.hub.projects().zones_operations_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -497,8 +517,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _projects_zones_tokens_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option { + let mut call = self.hub.projects().zones_tokens_get(&self.opt.arg_master_project_id, &self.opt.arg_zone_id, &self.opt.arg_project_number, &self.opt.arg_cluster_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); + 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 } } @@ -527,6 +589,8 @@ impl Engine { call_result = self._projects_zones_operations_get(dry_run, &mut err); } else if self.opt.cmd_zones_operations_list { call_result = self._projects_zones_operations_list(dry_run, &mut err); + } else if self.opt.cmd_zones_tokens_get { + call_result = self._projects_zones_tokens_get(dry_run, &mut err); } else { unreachable!(); } @@ -550,21 +614,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "container1-beta1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "container1-beta1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "container1-beta1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "container1-beta1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Container::new(hyper::Client::new(), auth), + hub: api::Container::new(client, auth), }; match engine._doit(true) { @@ -584,12 +664,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 9a9522012d..5cea9d0555 100644 --- a/gen/container1_beta1/Cargo.toml +++ b/gen/container1_beta1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-container1_beta1" -version = "0.1.5+20150318" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://cloud.google.com/container-engine/docs/v1beta1/" diff --git a/gen/container1_beta1/README.md b/gen/container1_beta1/README.md index 5867acf7fa..be6c4472b9 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+20150318*, where *20150318* 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.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*. Everything else about the *container* *v1_beta1* API can be found at the [official documentation site](https://cloud.google.com/container-engine/docs/v1beta1/). @@ -14,7 +14,7 @@ Everything else about the *container* *v1_beta1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.Container.html) ... * projects - * [*clusters list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectClusterListCall.html), [*operations list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectOperationListCall.html), [*zones clusters create*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterListCall.html), [*zones operations get*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneOperationListCall.html) + * [*clusters list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectClusterListCall.html), [*operations list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectOperationListCall.html), [*zones clusters create*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneClusterListCall.html), [*zones operations get*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneOperationGetCall.html), [*zones operations list*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneOperationListCall.html) and [*zones tokens get*](http://byron.github.io/google-apis-rs/google_container1_beta1/struct.ProjectZoneTokenGetCall.html) diff --git a/gen/container1_beta1/src/cmn.rs b/gen/container1_beta1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/container1_beta1/src/cmn.rs +++ b/gen/container1_beta1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/container1_beta1/src/lib.rs b/gen/container1_beta1/src/lib.rs index 8a0c37ee0f..c83c48f931 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+20150318*, where *20150318* 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.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*. //! //! Everything else about the *container* *v1_beta1* API can be found at the //! [official documentation site](https://cloud.google.com/container-engine/docs/v1beta1/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Container.html) ... //! //! * projects -//! * [*clusters list*](struct.ProjectClusterListCall.html), [*operations list*](struct.ProjectOperationListCall.html), [*zones clusters create*](struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](struct.ProjectZoneClusterListCall.html), [*zones operations get*](struct.ProjectZoneOperationGetCall.html) and [*zones operations list*](struct.ProjectZoneOperationListCall.html) +//! * [*clusters list*](struct.ProjectClusterListCall.html), [*operations list*](struct.ProjectOperationListCall.html), [*zones clusters create*](struct.ProjectZoneClusterCreateCall.html), [*zones clusters delete*](struct.ProjectZoneClusterDeleteCall.html), [*zones clusters get*](struct.ProjectZoneClusterGetCall.html), [*zones clusters list*](struct.ProjectZoneClusterListCall.html), [*zones operations get*](struct.ProjectZoneOperationGetCall.html), [*zones operations list*](struct.ProjectZoneOperationListCall.html) and [*zones tokens get*](struct.ProjectZoneTokenGetCall.html) //! //! //! @@ -334,7 +334,7 @@ impl<'a, C, A> Container #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListOperationsResponse { /// A list of operations in the project in the specified zone. - pub operations: Vec, + pub operations: Option>, } impl ResponseResult for ListOperationsResponse {} @@ -352,7 +352,7 @@ impl ResponseResult for ListOperationsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListAggregatedClustersResponse { /// A list of clusters in the project, across all zones. - pub clusters: Vec, + pub clusters: Option>, } impl ResponseResult for ListAggregatedClustersResponse {} @@ -370,22 +370,25 @@ impl ResponseResult for ListAggregatedClustersResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListClustersResponse { /// A list of clusters in the project in the specified zone. - pub clusters: Vec, + pub clusters: Option>, } impl ResponseResult for ListClustersResponse {} -/// There is no detailed description. +/// The authentication information for accessing the master. Authentication is either done using HTTP basic authentication or using a bearer token. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MasterAuth { - /// The password to use when accessing the Kubernetes master endpoint. - pub password: String, - /// The username to use when accessing the Kubernetes master endpoint. - pub user: String, + /// The token used to authenticate API requests to the master. The token is be included in an HTTP Authorization Header included in all requests to the master endpoint. The format of the header is: "Authorization: Bearer ". + #[serde(rename="bearerToken")] + pub bearer_token: Option, + /// The password to use for HTTP basic authentication when accessing the Kubernetes master endpoint. Because the master endpoint is open to the internet, you should create a strong password. + pub password: Option, + /// The username to use for HTTP basic authentication when accessing the Kubernetes master endpoint. + pub user: Option, } impl Part for MasterAuth {} @@ -403,60 +406,82 @@ impl Part for MasterAuth {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Cluster { /// [Output only] The current status of this cluster. - pub status: String, - /// [Output only] The IP addresses of the container pods in this cluster, in CIDR notation (e.g. 1.2.3.4/29). + pub status: Option, + /// The IP addresses of the container pods in this cluster, in CIDR notation (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block in 10.0.0.0/8 or 172.16.0.0/12. #[serde(rename="containerIpv4Cidr")] - pub container_ipv4_cidr: String, + pub container_ipv4_cidr: Option, /// An optional description of this cluster. - pub description: String, + pub description: Option, /// [Output only] The size of the address space on each node for hosting containers. #[serde(rename="nodeRoutingPrefixSize")] - pub node_routing_prefix_size: i32, - /// The HTTP basic authentication information for accessing the master. Because the master endpoint is open to the internet, you should create a strong password. + pub node_routing_prefix_size: Option, + /// The authentication information for accessing the master. #[serde(rename="masterAuth")] - pub master_auth: MasterAuth, + pub master_auth: Option, /// The API version of the Kubernetes master and kubelets running in this cluster. Leave blank to pick up the latest stable release, or specify a version of the form "x.y.z". The Google Container Engine release notes lists the currently supported versions. If an incorrect version is specified, the server returns an error listing the currently supported versions. #[serde(rename="clusterApiVersion")] - pub cluster_api_version: String, + pub cluster_api_version: Option, /// [Output only] The time the cluster was created, in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option, /// The name of this cluster. The name must be unique within this project and zone, and can be up to 40 characters with the following restrictions: /// - Lowercase letters, numbers, and hyphens only. /// - Must start with a letter. /// - Must end with a number or a letter. - pub name: String, + pub name: Option, /// [Output only] The IP address of this cluster's Kubernetes master. The endpoint can be accessed from the internet at https://username:password@endpoint/. /// /// See the masterAuth property of this resource for username and password information. - pub endpoint: String, + pub endpoint: Option, /// The name of the Google Compute Engine network to which the cluster is connected. - pub network: String, + pub network: Option, /// [Output only] The name of the Google Compute Engine zone in which the cluster resides. - pub zone: String, + pub zone: Option, /// The number of nodes to create in this cluster. You must ensure that your Compute Engine resource quota is sufficient for this number of instances plus one (to include the master). You must also have available firewall and routes quota. #[serde(rename="numNodes")] - pub num_nodes: i32, + pub num_nodes: Option, /// The machine type and image to use for all nodes in this cluster. See the descriptions of the child properties of nodeConfig. #[serde(rename="nodeConfig")] - pub node_config: NodeConfig, + pub node_config: Option, /// [Output only] Server-defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// Whether logs from the cluster should be made available via the Google Cloud Logging service. This includes both logs from your applications running in the cluster as well as logs from the Kubernetes components themselves. #[serde(rename="enableCloudLogging")] - pub enable_cloud_logging: bool, + pub enable_cloud_logging: Option, /// [Output only] Additional information about the current status of this cluster, if available. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option, /// [Output only] The IP addresses of the Kubernetes services in this cluster, in CIDR notation (e.g. 1.2.3.4/29). Service addresses are always in the 10.0.0.0/16 range. #[serde(rename="servicesIpv4Cidr")] - pub services_ipv4_cidr: String, + pub services_ipv4_cidr: Option, } impl ResponseResult for Cluster {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [zones tokens get projects](struct.ProjectZoneTokenGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Token { + /// The expiration time of the token in seconds since the unix epoch. + #[serde(rename="expiryTimeSeconds")] + pub expiry_time_seconds: Option, + /// The OAuth2 access token + #[serde(rename="accessToken")] + pub access_token: Option, +} + +impl ResponseResult for Token {} + + /// There is no detailed description. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -467,17 +492,17 @@ pub struct NodeConfig { /// - https://www.googleapis.com/auth/compute, /// - https://www.googleapis.com/auth/devstorage.read_only #[serde(rename="serviceAccounts")] - pub service_accounts: Vec, + pub service_accounts: Option>, /// The name of a Google Compute Engine machine type (e.g. n1-standard-1). /// /// If unspecified, the default machine type is n1-standard-1. #[serde(rename="machineType")] - pub machine_type: String, + pub machine_type: Option, /// The fully-specified name of a Google Compute Engine image. For example: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-vYYYYMMDD (where YYYMMDD is the version date). /// /// If specifying an image, you are responsible for ensuring its compatibility with the Debian 7 backports image. We recommend leaving this field blank to accept the default backports-debian-7-wheezy value. #[serde(rename="sourceImage")] - pub source_image: String, + pub source_image: Option, } impl Part for NodeConfig {} @@ -490,9 +515,9 @@ impl Part for NodeConfig {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ServiceAccount { /// The list of scopes to be made available for this service account. - pub scopes: Vec, + pub scopes: Option>, /// Email address of the service account. - pub email: String, + pub email: Option, } impl Part for ServiceAccount {} @@ -512,25 +537,25 @@ impl Part for ServiceAccount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// The current status of the operation. - pub status: String, + pub status: Option, /// The server-assigned ID for this operation. If the operation is fulfilled upfront, it may not have a resource name. - pub name: String, + pub name: Option, /// The name of the Google Compute Engine zone in which the operation is taking place. - pub zone: String, + pub zone: Option, /// If an error has occurred, a textual description of the error. #[serde(rename="errorMessage")] - pub error_message: String, + pub error_message: Option, /// Server-defined URL for the target of the operation. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option, /// The operation type. #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option, /// Server-defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option, /// [Optional] The URL of the cluster resource that this operation is associated with. - pub target: String, + pub target: Option, } impl ResponseResult for Operation {} @@ -548,7 +573,7 @@ impl ResponseResult for Operation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListAggregatedOperationsResponse { /// A list of operations in the project, across all zones. - pub operations: Vec, + pub operations: Option>, } impl ResponseResult for ListAggregatedOperationsResponse {} @@ -600,7 +625,7 @@ impl RequestValue for CreateClusterRequest {} /// ::default(), None); /// let mut hub = Container::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `clusters_list(...)`, `operations_list(...)`, `zones_clusters_create(...)`, `zones_clusters_delete(...)`, `zones_clusters_get(...)`, `zones_clusters_list(...)`, `zones_operations_get(...)` and `zones_operations_list(...)` +/// // like `clusters_list(...)`, `operations_list(...)`, `zones_clusters_create(...)`, `zones_clusters_delete(...)`, `zones_clusters_get(...)`, `zones_clusters_list(...)`, `zones_operations_get(...)`, `zones_operations_list(...)` and `zones_tokens_get(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } @@ -653,6 +678,29 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets a compute-rw scoped OAuth2 access token for + /// . Authentication is performed to ensure that the caller is a member of and that the request is coming from the expected master VM for the specified cluster. See go/gke-cross-project-auth for more details. + /// + /// # Arguments + /// + /// * `masterProjectId` - The hosted master project from which this request is coming. + /// * `zoneId` - The zone of the specified cluster. + /// * `projectNumber` - The project number for which the access token is being requested. + /// * `clusterName` - The name of the specified cluster. + pub fn zones_tokens_get(&self, master_project_id: &str, zone_id: &str, project_number: &str, cluster_name: &str) -> ProjectZoneTokenGetCall<'a, C, A> { + ProjectZoneTokenGetCall { + hub: self.hub, + _master_project_id: master_project_id.to_string(), + _zone_id: zone_id.to_string(), + _project_number: project_number.to_string(), + _cluster_name: cluster_name.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes the cluster, including the Kubernetes master and all worker nodes. @@ -900,16 +948,20 @@ impl<'a, C, A> ProjectZoneClusterGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1150,16 +1202,20 @@ impl<'a, C, A> ProjectOperationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1272,6 +1328,254 @@ impl<'a, C, A> ProjectOperationListCall<'a, C, A> where C: BorrowMut::default(), None); +/// # let mut hub = Container::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().zones_tokens_get("masterProjectId", "zoneId", "projectNumber", "clusterName") +/// .doit(); +/// # } +/// ``` +pub struct ProjectZoneTokenGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Container, + _master_project_id: String, + _zone_id: String, + _project_number: String, + _cluster_name: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap, +} + +impl<'a, C, A> CallBuilder for ProjectZoneTokenGetCall<'a, C, A> {} + +impl<'a, C, A> ProjectZoneTokenGetCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Token)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "container.projects.zones.tokens.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("masterProjectId", self._master_project_id.to_string())); + params.push(("zoneId", self._zone_id.to_string())); + params.push(("projectNumber", self._project_number.to_string())); + params.push(("clusterName", self._cluster_name.to_string())); + for &field in ["alt", "masterProjectId", "zoneId", "projectNumber", "clusterName"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/container/v1beta1/projects/{masterProjectId}/zones/{zoneId}/tokens/{projectNumber}/{clusterName}".to_string(); + + let mut key = self.hub.auth.borrow_mut().api_key(); + if key.is_none() { + key = dlg.api_key(); + } + match key { + Some(value) => params.push(("key", value)), + None => { + dlg.finished(false); + return Err(Error::MissingAPIKey) + } + } + + for &(find_this, param_name) in [("{masterProjectId}", "masterProjectId"), ("{zoneId}", "zoneId"), ("{projectNumber}", "projectNumber"), ("{clusterName}", "clusterName")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["masterProjectId", "zoneId", "projectNumber", "clusterName"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The hosted master project from which this request is coming. + /// + /// Sets the *master project id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn master_project_id(mut self, new_value: &str) -> ProjectZoneTokenGetCall<'a, C, A> { + self._master_project_id = new_value.to_string(); + self + } + /// The zone of the specified cluster. + /// + /// Sets the *zone id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn zone_id(mut self, new_value: &str) -> ProjectZoneTokenGetCall<'a, C, A> { + self._zone_id = new_value.to_string(); + self + } + /// The project number for which the access token is being requested. + /// + /// Sets the *project number* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn project_number(mut self, new_value: &str) -> ProjectZoneTokenGetCall<'a, C, A> { + self._project_number = new_value.to_string(); + self + } + /// The name of the specified cluster. + /// + /// Sets the *cluster name* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn cluster_name(mut self, new_value: &str) -> ProjectZoneTokenGetCall<'a, C, A> { + self._cluster_name = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectZoneTokenGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param(mut self, name: T, value: T) -> ProjectZoneTokenGetCall<'a, C, A> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + /// Deletes the cluster, including the Kubernetes master and all worker nodes. /// /// Firewalls and routes that were configured at cluster creation are also deleted. @@ -1386,16 +1690,20 @@ impl<'a, C, A> ProjectZoneClusterDeleteCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1636,16 +1944,20 @@ impl<'a, C, A> ProjectClusterListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1870,16 +2182,20 @@ impl<'a, C, A> ProjectZoneOperationGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2122,16 +2438,20 @@ impl<'a, C, A> ProjectZoneOperationListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2364,16 +2684,20 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2529,7 +2853,7 @@ impl<'a, C, A> ProjectZoneClusterListCall<'a, C, A> where C: BorrowMut ProjectZoneClusterCreateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/content2-cli/Cargo.toml b/gen/content2-cli/Cargo.toml index 81e5a58248..03414f7b25 100644 --- a/gen/content2-cli/Cargo.toml +++ b/gen/content2-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-content2-cli" -version = "0.0.1+20150317" -authors = ["Sebastian Thiel "] +version = "0.0.1+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" homepage = "https://developers.google.com/shopping-content/v2/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/content2-cli/mkdocs.yml b/gen/content2-cli/mkdocs.yml index 46b020ce04..01367bc243 100644 --- a/gen/content2-cli/mkdocs.yml +++ b/gen/content2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Shopping Content v0.0.1+20150317 +site_name: Shopping Content v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/content2-cli/src/cmn.rs +++ b/gen/content2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option) -> Option { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern =", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/content2-cli/src/main.rs b/gen/content2-cli/src/main.rs index 040ad3a704..6f9758e38b 100644 --- a/gen/content2-cli/src/main.rs +++ b/gen/content2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -72,6 +73,12 @@ Configuration: 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. "); mod cmn; @@ -95,7 +102,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().authinfo(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -127,8 +134,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -137,10 +143,10 @@ impl Engine { fn _accounts_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountsCustomBatchRequest = Default::default(); + let mut request = api::AccountsCustomBatchRequest::default(); let mut call = self.hub.accounts().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -160,9 +166,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -184,8 +191,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -196,7 +202,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -227,7 +233,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -238,7 +243,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -270,8 +275,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -280,10 +284,10 @@ impl Engine { fn _accounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -303,9 +307,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -348,8 +353,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -360,7 +364,7 @@ impl Engine { -> Option { let mut call = self.hub.accounts().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -398,8 +402,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -408,10 +411,10 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -431,9 +434,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -476,8 +480,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -486,10 +489,10 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -509,9 +512,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -554,8 +558,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -564,11 +567,14 @@ impl Engine { fn _accountshipping_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountshippingCustomBatchRequest = Default::default(); + let mut request = api::AccountshippingCustomBatchRequest::default(); let mut call = self.hub.accountshipping().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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" @@ -587,9 +593,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -611,8 +618,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -623,7 +629,7 @@ impl Engine { -> Option { let mut call = self.hub.accountshipping().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -655,8 +661,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -667,7 +672,7 @@ impl Engine { -> Option { let mut call = self.hub.accountshipping().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -705,8 +710,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -715,11 +719,14 @@ impl Engine { fn _accountshipping_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountShipping = Default::default(); + let mut request = api::AccountShipping::default(); 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); + 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" @@ -738,9 +745,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -768,8 +776,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -778,11 +785,14 @@ impl Engine { fn _accountshipping_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountShipping = Default::default(); + let mut request = api::AccountShipping::default(); 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); + 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" @@ -801,9 +811,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -831,8 +842,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -841,10 +851,10 @@ impl Engine { fn _accountstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountstatusesCustomBatchRequest = Default::default(); + let mut request = api::AccountstatusesCustomBatchRequest::default(); let mut call = self.hub.accountstatuses().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -864,9 +874,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -888,8 +899,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -900,7 +910,7 @@ impl Engine { -> Option { let mut call = self.hub.accountstatuses().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -932,8 +942,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -944,7 +953,7 @@ impl Engine { -> Option { let mut call = self.hub.accountstatuses().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -982,8 +991,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -992,11 +1000,14 @@ impl Engine { fn _accounttax_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccounttaxCustomBatchRequest = Default::default(); + let mut request = api::AccounttaxCustomBatchRequest::default(); let mut call = self.hub.accounttax().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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" @@ -1015,9 +1026,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1039,8 +1051,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1051,7 +1062,7 @@ impl Engine { -> Option { let mut call = self.hub.accounttax().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1083,8 +1094,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1095,7 +1105,7 @@ impl Engine { -> Option { let mut call = self.hub.accounttax().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1133,8 +1143,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1143,11 +1152,14 @@ impl Engine { fn _accounttax_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountTax = Default::default(); + let mut request = api::AccountTax::default(); 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); + 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" @@ -1166,9 +1178,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1196,8 +1209,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1206,11 +1218,14 @@ impl Engine { fn _accounttax_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::AccountTax = Default::default(); + let mut request = api::AccountTax::default(); 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); + 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" @@ -1229,9 +1244,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1259,8 +1275,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1269,10 +1284,10 @@ impl Engine { fn _datafeeds_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::DatafeedsCustomBatchRequest = Default::default(); + let mut request = api::DatafeedsCustomBatchRequest::default(); let mut call = self.hub.datafeeds().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1292,9 +1307,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1316,8 +1332,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1328,7 +1343,7 @@ impl Engine { -> Option { let mut call = self.hub.datafeeds().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1359,7 +1374,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1370,7 +1384,7 @@ impl Engine { -> Option { let mut call = self.hub.datafeeds().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1402,8 +1416,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1412,10 +1425,10 @@ impl Engine { fn _datafeeds_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Datafeed = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1435,9 +1448,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1468,43 +1482,43 @@ impl Engine { }, "format.file-encoding" => { request_format_init(&mut request); - request.format.as_mut().unwrap().file_encoding = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().file_encoding = Some(value.unwrap_or("").to_string()); }, "format.quoting-mode" => { request_format_init(&mut request); - request.format.as_mut().unwrap().quoting_mode = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().quoting_mode = Some(value.unwrap_or("").to_string()); }, "format.column-delimiter" => { request_format_init(&mut request); - request.format.as_mut().unwrap().column_delimiter = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().column_delimiter = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.username" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().username = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.hour" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().hour = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer"); + request.fetch_schedule.as_mut().unwrap().hour = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer")); }, "fetch-schedule.fetch-url" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().fetch_url = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().fetch_url = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.weekday" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().weekday = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().weekday = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.time-zone" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().time_zone = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.password" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().password = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.day-of-month" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().day_of_month = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer"); + request.fetch_schedule.as_mut().unwrap().day_of_month = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer")); }, "target-country" => { request_fetch_schedule_init(&mut request); @@ -1517,9 +1531,9 @@ impl Engine { "intended-destinations" => { request_fetch_schedule_init(&mut request); if request.intended_destinations.is_none() { - request.intended_destinations = Some(Default::default()); + request.intended_destinations = Some(Default::default()); } - request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_fetch_schedule_init(&mut request); @@ -1546,8 +1560,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1558,7 +1571,7 @@ impl Engine { -> Option { let mut call = self.hub.datafeeds().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1596,8 +1609,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1606,10 +1618,10 @@ impl Engine { fn _datafeeds_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Datafeed = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1629,9 +1641,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1662,43 +1675,43 @@ impl Engine { }, "format.file-encoding" => { request_format_init(&mut request); - request.format.as_mut().unwrap().file_encoding = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().file_encoding = Some(value.unwrap_or("").to_string()); }, "format.quoting-mode" => { request_format_init(&mut request); - request.format.as_mut().unwrap().quoting_mode = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().quoting_mode = Some(value.unwrap_or("").to_string()); }, "format.column-delimiter" => { request_format_init(&mut request); - request.format.as_mut().unwrap().column_delimiter = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().column_delimiter = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.username" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().username = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.hour" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().hour = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer"); + request.fetch_schedule.as_mut().unwrap().hour = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer")); }, "fetch-schedule.fetch-url" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().fetch_url = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().fetch_url = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.weekday" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().weekday = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().weekday = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.time-zone" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().time_zone = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.password" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().password = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.day-of-month" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().day_of_month = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer"); + request.fetch_schedule.as_mut().unwrap().day_of_month = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer")); }, "target-country" => { request_fetch_schedule_init(&mut request); @@ -1711,9 +1724,9 @@ impl Engine { "intended-destinations" => { request_fetch_schedule_init(&mut request); if request.intended_destinations.is_none() { - request.intended_destinations = Some(Default::default()); + request.intended_destinations = Some(Default::default()); } - request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_fetch_schedule_init(&mut request); @@ -1740,8 +1753,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1750,10 +1762,10 @@ impl Engine { fn _datafeeds_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Datafeed = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1773,9 +1785,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1806,43 +1819,43 @@ impl Engine { }, "format.file-encoding" => { request_format_init(&mut request); - request.format.as_mut().unwrap().file_encoding = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().file_encoding = Some(value.unwrap_or("").to_string()); }, "format.quoting-mode" => { request_format_init(&mut request); - request.format.as_mut().unwrap().quoting_mode = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().quoting_mode = Some(value.unwrap_or("").to_string()); }, "format.column-delimiter" => { request_format_init(&mut request); - request.format.as_mut().unwrap().column_delimiter = value.unwrap_or("").to_string(); + request.format.as_mut().unwrap().column_delimiter = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.username" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().username = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.hour" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().hour = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer"); + request.fetch_schedule.as_mut().unwrap().hour = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.hour", "integer")); }, "fetch-schedule.fetch-url" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().fetch_url = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().fetch_url = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.weekday" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().weekday = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().weekday = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.time-zone" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().time_zone = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().time_zone = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.password" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().password = value.unwrap_or("").to_string(); + request.fetch_schedule.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "fetch-schedule.day-of-month" => { request_fetch_schedule_init(&mut request); - request.fetch_schedule.as_mut().unwrap().day_of_month = arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer"); + request.fetch_schedule.as_mut().unwrap().day_of_month = Some(arg_from_str(value.unwrap_or("-0"), err, "fetch-schedule.day-of-month", "integer")); }, "target-country" => { request_fetch_schedule_init(&mut request); @@ -1855,9 +1868,9 @@ impl Engine { "intended-destinations" => { request_fetch_schedule_init(&mut request); if request.intended_destinations.is_none() { - request.intended_destinations = Some(Default::default()); + request.intended_destinations = Some(Default::default()); } - request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.intended_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_fetch_schedule_init(&mut request); @@ -1884,8 +1897,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1894,10 +1906,10 @@ impl Engine { fn _datafeedstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::DatafeedstatusesCustomBatchRequest = Default::default(); + let mut request = api::DatafeedstatusesCustomBatchRequest::default(); let mut call = self.hub.datafeedstatuses().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1917,9 +1929,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1941,8 +1954,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1953,7 +1965,7 @@ impl Engine { -> Option { let mut call = self.hub.datafeedstatuses().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1985,8 +1997,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1997,7 +2008,7 @@ impl Engine { -> Option { let mut call = self.hub.datafeedstatuses().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2035,8 +2046,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2045,10 +2055,10 @@ impl Engine { fn _inventory_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InventoryCustomBatchRequest = Default::default(); + let mut request = api::InventoryCustomBatchRequest::default(); let mut call = self.hub.inventory().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2068,9 +2078,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2092,8 +2103,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2102,10 +2112,10 @@ impl Engine { fn _inventory_set(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::InventorySetRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2125,9 +2135,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2149,19 +2160,19 @@ impl Engine { }, "price.currency" => { request_price_init(&mut request); - request.price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "price.value" => { request_price_init(&mut request); - request.price.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.price.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "sale-price.currency" => { request_sale_price_init(&mut request); - request.sale_price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.sale_price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "sale-price.value" => { request_sale_price_init(&mut request); - request.sale_price.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.sale_price.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "availability" => { request_sale_price_init(&mut request); @@ -2188,8 +2199,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2198,10 +2208,10 @@ impl Engine { fn _products_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProductsCustomBatchRequest = Default::default(); + let mut request = api::ProductsCustomBatchRequest::default(); let mut call = self.hub.products().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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")); @@ -2224,9 +2234,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2248,8 +2259,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2260,7 +2270,7 @@ impl Engine { -> Option { let mut call = self.hub.products().delete(&self.opt.arg_merchant_id, &self.opt.arg_product_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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")); @@ -2294,7 +2304,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2305,7 +2314,7 @@ impl Engine { -> Option { let mut call = self.hub.products().get(&self.opt.arg_merchant_id, &self.opt.arg_product_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2337,8 +2346,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2347,10 +2355,10 @@ impl Engine { fn _products_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::Product = Default::default(); + 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); + 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")); @@ -2373,12 +2381,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_installment_amount_init(request: &mut api::Product) { + request_installment_init(request); + if request.installment.as_mut().unwrap().amount.is_none() { + request.installment.as_mut().unwrap().amount = Some(Default::default()); + } + } + fn request_installment_init(request: &mut api::Product) { if request.installment.is_none() { request.installment = Some(Default::default()); @@ -2448,15 +2464,15 @@ impl Engine { }, "additional-image-links" => { if request.additional_image_links.is_none() { - request.additional_image_links = Some(Default::default()); + request.additional_image_links = Some(Default::default()); } - request.additional_image_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.additional_image_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "adwords-labels" => { if request.adwords_labels.is_none() { - request.adwords_labels = Some(Default::default()); + request.adwords_labels = Some(Default::default()); } - request.adwords_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.adwords_labels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "item-group-id" => { request.item_group_id = Some(value.unwrap_or("").to_string()); @@ -2505,18 +2521,18 @@ impl Engine { }, "unit-pricing-measure.value" => { request_unit_pricing_measure_init(&mut request); - request.unit_pricing_measure.as_mut().unwrap().value = arg_from_str(value.unwrap_or("0.0"), err, "unit-pricing-measure.value", "number"); + request.unit_pricing_measure.as_mut().unwrap().value = Some(arg_from_str(value.unwrap_or("0.0"), err, "unit-pricing-measure.value", "number")); }, "unit-pricing-measure.unit" => { request_unit_pricing_measure_init(&mut request); - request.unit_pricing_measure.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.unit_pricing_measure.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "validated-destinations" => { request_unit_pricing_measure_init(&mut request); if request.validated_destinations.is_none() { - request.validated_destinations = Some(Default::default()); + request.validated_destinations = Some(Default::default()); } - request.validated_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.validated_destinations.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_unit_pricing_measure_init(&mut request); @@ -2536,11 +2552,11 @@ impl Engine { }, "price.currency" => { request_price_init(&mut request); - request.price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "price.value" => { request_price_init(&mut request); - request.price.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.price.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "channel" => { request_price_init(&mut request); @@ -2548,23 +2564,23 @@ impl Engine { }, "loyalty-points.ratio" => { request_loyalty_points_init(&mut request); - request.loyalty_points.as_mut().unwrap().ratio = arg_from_str(value.unwrap_or("0.0"), err, "loyalty-points.ratio", "number"); + request.loyalty_points.as_mut().unwrap().ratio = Some(arg_from_str(value.unwrap_or("0.0"), err, "loyalty-points.ratio", "number")); }, "loyalty-points.name" => { request_loyalty_points_init(&mut request); - request.loyalty_points.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.loyalty_points.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "loyalty-points.points-value" => { request_loyalty_points_init(&mut request); - request.loyalty_points.as_mut().unwrap().points_value = value.unwrap_or("").to_string(); + request.loyalty_points.as_mut().unwrap().points_value = Some(value.unwrap_or("").to_string()); }, "shipping-height.value" => { request_shipping_height_init(&mut request); - request.shipping_height.as_mut().unwrap().value = arg_from_str(value.unwrap_or("0.0"), err, "shipping-height.value", "number"); + request.shipping_height.as_mut().unwrap().value = Some(arg_from_str(value.unwrap_or("0.0"), err, "shipping-height.value", "number")); }, "shipping-height.unit" => { request_shipping_height_init(&mut request); - request.shipping_height.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.shipping_height.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "content-language" => { request_shipping_height_init(&mut request); @@ -2592,11 +2608,11 @@ impl Engine { }, "shipping-length.value" => { request_shipping_length_init(&mut request); - request.shipping_length.as_mut().unwrap().value = arg_from_str(value.unwrap_or("0.0"), err, "shipping-length.value", "number"); + request.shipping_length.as_mut().unwrap().value = Some(arg_from_str(value.unwrap_or("0.0"), err, "shipping-length.value", "number")); }, "shipping-length.unit" => { request_shipping_length_init(&mut request); - request.shipping_length.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.shipping_length.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "link" => { request_shipping_length_init(&mut request); @@ -2648,30 +2664,30 @@ impl Engine { }, "unit-pricing-base-measure.value" => { request_unit_pricing_base_measure_init(&mut request); - request.unit_pricing_base_measure.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.unit_pricing_base_measure.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "unit-pricing-base-measure.unit" => { request_unit_pricing_base_measure_init(&mut request); - request.unit_pricing_base_measure.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.unit_pricing_base_measure.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "installment.amount.currency" => { - request_installment_init(&mut request); - request.installment.as_mut().unwrap().amount.currency = value.unwrap_or("").to_string(); + request_installment_amount_init(&mut request); + request.installment.as_mut().unwrap().amount.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "installment.amount.value" => { - request_installment_init(&mut request); - request.installment.as_mut().unwrap().amount.value = value.unwrap_or("").to_string(); + request_installment_amount_init(&mut request); + request.installment.as_mut().unwrap().amount.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "installment.months" => { - request_installment_init(&mut request); - request.installment.as_mut().unwrap().months = value.unwrap_or("").to_string(); + request_installment_amount_init(&mut request); + request.installment.as_mut().unwrap().months = Some(value.unwrap_or("").to_string()); }, "sizes" => { request_installment_init(&mut request); if request.sizes.is_none() { - request.sizes = Some(Default::default()); + request.sizes = Some(Default::default()); } - request.sizes.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.sizes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "gender" => { request_installment_init(&mut request); @@ -2679,19 +2695,19 @@ impl Engine { }, "shipping-width.value" => { request_shipping_width_init(&mut request); - request.shipping_width.as_mut().unwrap().value = arg_from_str(value.unwrap_or("0.0"), err, "shipping-width.value", "number"); + request.shipping_width.as_mut().unwrap().value = Some(arg_from_str(value.unwrap_or("0.0"), err, "shipping-width.value", "number")); }, "shipping-width.unit" => { request_shipping_width_init(&mut request); - request.shipping_width.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.shipping_width.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "shipping-weight.value" => { request_shipping_weight_init(&mut request); - request.shipping_weight.as_mut().unwrap().value = arg_from_str(value.unwrap_or("0.0"), err, "shipping-weight.value", "number"); + request.shipping_weight.as_mut().unwrap().value = Some(arg_from_str(value.unwrap_or("0.0"), err, "shipping-weight.value", "number")); }, "shipping-weight.unit" => { request_shipping_weight_init(&mut request); - request.shipping_weight.as_mut().unwrap().unit = value.unwrap_or("").to_string(); + request.shipping_weight.as_mut().unwrap().unit = Some(value.unwrap_or("").to_string()); }, "identifier-exists" => { request_shipping_weight_init(&mut request); @@ -2703,11 +2719,11 @@ impl Engine { }, "sale-price.currency" => { request_sale_price_init(&mut request); - request.sale_price.as_mut().unwrap().currency = value.unwrap_or("").to_string(); + request.sale_price.as_mut().unwrap().currency = Some(value.unwrap_or("").to_string()); }, "sale-price.value" => { request_sale_price_init(&mut request); - request.sale_price.as_mut().unwrap().value = value.unwrap_or("").to_string(); + request.sale_price.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "product-type" => { request_sale_price_init(&mut request); @@ -2716,9 +2732,9 @@ impl Engine { "display-ads-similar-ids" => { request_sale_price_init(&mut request); if request.display_ads_similar_ids.is_none() { - request.display_ads_similar_ids = Some(Default::default()); + request.display_ads_similar_ids = Some(Default::default()); } - request.display_ads_similar_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.display_ads_similar_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "custom-label1" => { request_sale_price_init(&mut request); @@ -2749,8 +2765,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2761,7 +2776,7 @@ impl Engine { -> Option { let mut call = self.hub.products().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2799,8 +2814,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2809,10 +2823,10 @@ impl Engine { fn _productstatuses_custombatch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option { - let mut request: api::ProductstatusesCustomBatchRequest = Default::default(); + let mut request = api::ProductstatusesCustomBatchRequest::default(); let mut call = self.hub.productstatuses().custombatch(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2832,9 +2846,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2856,8 +2871,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2868,7 +2882,7 @@ impl Engine { -> Option { let mut call = self.hub.productstatuses().get(&self.opt.arg_merchant_id, &self.opt.arg_product_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2900,8 +2914,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2912,7 +2925,7 @@ impl Engine { -> Option { let mut call = self.hub.productstatuses().list(&self.opt.arg_merchant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2950,8 +2963,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2983,7 +2995,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_accountshipping { + } + else if self.opt.cmd_accountshipping { if self.opt.cmd_custombatch { call_result = self._accountshipping_custombatch(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2997,7 +3010,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_accountstatuses { + } + else if self.opt.cmd_accountstatuses { if self.opt.cmd_custombatch { call_result = self._accountstatuses_custombatch(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3007,7 +3021,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_accounttax { + } + else if self.opt.cmd_accounttax { if self.opt.cmd_custombatch { call_result = self._accounttax_custombatch(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3021,7 +3036,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_datafeeds { + } + else if self.opt.cmd_datafeeds { if self.opt.cmd_custombatch { call_result = self._datafeeds_custombatch(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -3039,7 +3055,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_datafeedstatuses { + } + else if self.opt.cmd_datafeedstatuses { if self.opt.cmd_custombatch { call_result = self._datafeedstatuses_custombatch(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3049,7 +3066,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_inventory { + } + else if self.opt.cmd_inventory { if self.opt.cmd_custombatch { call_result = self._inventory_custombatch(dry_run, &mut err); } else if self.opt.cmd_set { @@ -3057,7 +3075,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_products { + } + else if self.opt.cmd_products { if self.opt.cmd_custombatch { call_result = self._products_custombatch(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -3071,7 +3090,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_productstatuses { + } + else if self.opt.cmd_productstatuses { if self.opt.cmd_custombatch { call_result = self._productstatuses_custombatch(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3101,21 +3121,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "content2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "content2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "content2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "content2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::ShoppingContent::new(hyper::Client::new(), auth), + hub: api::ShoppingContent::new(client, auth), }; match engine._doit(true) { @@ -3135,12 +3171,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/content2/Cargo.toml b/gen/content2/Cargo.toml index 7249379fff..911b7e4f41 100644 --- a/gen/content2/Cargo.toml +++ b/gen/content2/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-content2" -version = "0.1.5+20150317" -authors = ["Sebastian Thiel "] +version = "0.1.5+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" homepage = "https://developers.google.com/shopping-content/v2/" diff --git a/gen/content2/README.md b/gen/content2/README.md index 0c3999fea2..689b800b7b 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+20150317*, where *20150317* 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.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*. Everything else about the *Shopping Content* *v2* API can be found at the [official documentation site](https://developers.google.com/shopping-content/v2/). @@ -116,7 +116,7 @@ let mut hub = ShoppingContent::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Account = Default::default(); +let mut req = Account::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/content2/src/cmn.rs b/gen/content2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/content2/src/cmn.rs +++ b/gen/content2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/content2/src/lib.rs b/gen/content2/src/lib.rs index 0ca240d6ab..714d300a01 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+20150317*, where *20150317* 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.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*. //! //! Everything else about the *Shopping Content* *v2* API can be found at the //! [official documentation site](https://developers.google.com/shopping-content/v2/). @@ -117,7 +117,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Account = Default::default(); +//! let mut req = Account::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -292,7 +292,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -386,11 +386,11 @@ impl<'a, C, A> ShoppingContent #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Errors { /// The message of the first error in errors. - pub message: String, + pub message: Option, /// The HTTP status of the first error in errors. - pub code: u32, + pub code: Option, /// A list of errors. - pub errors: Vec, + pub errors: Option>, } impl Part for Errors {} @@ -403,13 +403,13 @@ impl Part for Errors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductAspect { /// Whether the aspect is required, excluded or should be validated. - pub intention: String, + pub intention: Option, /// The name of the aspect. #[serde(rename="aspectName")] - pub aspect_name: String, + pub aspect_name: Option, /// The name of the destination. Leave out to apply to all destinations. #[serde(rename="destinationName")] - pub destination_name: String, + pub destination_name: Option, } impl Part for ProductAspect {} @@ -423,13 +423,13 @@ impl Part for ProductAspect {} pub struct ProductsCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#productsCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// The inserted product. Only defined if the method is insert and if the request was successful. - pub product: Product, + pub product: Option, } impl Part for ProductsCustomBatchResponseEntry {} @@ -447,9 +447,9 @@ impl Part for ProductsCustomBatchResponseEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccounttaxCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#accounttaxCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for AccounttaxCustomBatchResponse {} @@ -467,9 +467,9 @@ impl ResponseResult for AccounttaxCustomBatchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountshippingCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#accountshippingCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for AccountshippingCustomBatchResponse {} @@ -487,9 +487,9 @@ impl ResponseResult for AccountshippingCustomBatchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InventoryCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#inventoryCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for InventoryCustomBatchResponse {} @@ -502,10 +502,10 @@ impl ResponseResult for InventoryCustomBatchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountUser { /// Whether user is an admin. - pub admin: bool, + pub admin: Option, /// User's email address. #[serde(rename="emailAddress")] - pub email_address: String, + pub email_address: Option, } impl Part for AccountUser {} @@ -518,9 +518,9 @@ impl Part for AccountUser {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountShippingRateTableCell { /// The rate applicable if the cell conditions are matched. - pub rate: Price, + pub rate: Option, /// Conditions for which the cell is valid. All cells in a table must use the same dimension or pair of dimensions among price, weight, shipping label or delivery location. If no condition is specified, the cell acts as a catch-all and matches all the elements that are not matched by other cells in this dimension. - pub condition: AccountShippingCondition, + pub condition: Option, } impl Part for AccountShippingRateTableCell {} @@ -556,9 +556,9 @@ impl RequestValue for ProductstatusesCustomBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatafeedsCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#datafeedsCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for DatafeedsCustomBatchResponse {} @@ -572,19 +572,19 @@ impl ResponseResult for DatafeedsCustomBatchResponse {} pub struct AccountShippingLocationGroup { /// A postal code range representing a city or a set of cities. #[serde(rename="postalCodeRanges")] - pub postal_code_ranges: Vec, + pub postal_code_ranges: Option>, /// The country in which this location group is, represented as ISO 3166-1 Alpha-2 code. - pub country: String, + pub country: Option, /// A location ID (also called criteria ID) representing administrative areas, smaller country subdivisions (counties), or cities. #[serde(rename="locationIds")] - pub location_ids: Vec, + pub location_ids: Option>, /// The name of the location group. - pub name: String, + pub name: Option, /// A postal code representing a city or a set of cities. /// - A single postal code (e.g., 12345) /// - A postal code prefix followed by a star (e.g., 1234*) #[serde(rename="postalCodes")] - pub postal_codes: Vec, + pub postal_codes: Option>, } impl Part for AccountShippingLocationGroup {} @@ -602,7 +602,7 @@ impl Part for AccountShippingLocationGroup {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InventorySetResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#inventorySetResponse". - pub kind: String, + pub kind: Option, } impl ResponseResult for InventorySetResponse {} @@ -621,28 +621,28 @@ impl ResponseResult for InventorySetResponse {} pub struct ProductStatus { /// Date on which the item expires in Google Shopping, in ISO 8601 format. #[serde(rename="googleExpirationDate")] - pub google_expiration_date: String, + pub google_expiration_date: Option, /// The intended destinations for the product. #[serde(rename="destinationStatuses")] - pub destination_statuses: Vec, + pub destination_statuses: Option>, /// The title of the product. - pub title: String, + pub title: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#productStatus". - pub kind: String, + pub kind: Option, /// Date on which the item has been last updated, in ISO 8601 format. #[serde(rename="lastUpdateDate")] - pub last_update_date: String, + pub last_update_date: Option, /// The link to the product. - pub link: String, + pub link: Option, /// Date on which the item has been created, in ISO 8601 format. #[serde(rename="creationDate")] - pub creation_date: String, + pub creation_date: Option, /// A list of data quality issues associated with the product. #[serde(rename="dataQualityIssues")] - pub data_quality_issues: Vec, + pub data_quality_issues: Option>, /// The id of the product for which status is reported. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl ResponseResult for ProductStatus {} @@ -655,22 +655,22 @@ impl ResponseResult for ProductStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatafeedFetchSchedule { /// An optional user name for fetch_url. - pub username: String, + pub username: Option, /// An optional password for fetch_url. - pub password: String, + pub password: Option, /// The day of the week the feed file should be fetched. - pub weekday: String, + pub weekday: Option, /// The hour of the day the feed file should be fetched (0-24). - pub hour: u32, + pub hour: Option, /// Time zone used for schedule. UTC by default. E.g., "America/Los_Angeles". #[serde(rename="timeZone")] - pub time_zone: String, + pub time_zone: Option, /// The URL where the feed file can be fetched. Google Merchant Center will support automatic scheduled uploads using the HTTP, HTTPS, FTP, or SFTP protocols, so the value will need to be a valid link using one of those four protocols. #[serde(rename="fetchUrl")] - pub fetch_url: String, + pub fetch_url: Option, /// The day of the month the feed file should be fetched (1-31). #[serde(rename="dayOfMonth")] - pub day_of_month: u32, + pub day_of_month: Option, } impl Part for DatafeedFetchSchedule {} @@ -687,24 +687,27 @@ impl Part for DatafeedFetchSchedule {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatafeedStatus { - /// The number of items in the feed that were valid. - #[serde(rename="itemsValid")] - pub items_valid: String, /// Identifies what kind of resource this is. Value: the fixed string "content#datafeedStatus". - pub kind: String, + pub kind: Option, /// The list of errors occurring in the feed. - pub errors: Vec, - /// The processing status of the feed. - #[serde(rename="processingStatus")] - pub processing_status: String, + pub errors: Option>, + /// The list of errors occurring in the feed. + pub warnings: Option>, /// The number of items in the feed that were processed. #[serde(rename="itemsTotal")] - pub items_total: String, + pub items_total: Option, + /// The processing status of the feed. + #[serde(rename="processingStatus")] + pub processing_status: Option, + /// The last date at which the feed was uploaded. + #[serde(rename="lastUploadDate")] + pub last_upload_date: Option, + /// The number of items in the feed that were valid. + #[serde(rename="itemsValid")] + pub items_valid: Option, /// The ID of the feed for which the status is reported. #[serde(rename="datafeedId")] - pub datafeed_id: String, - /// The list of errors occurring in the feed. - pub warnings: Vec, + pub datafeed_id: Option, } impl ResponseResult for DatafeedStatus {} @@ -718,15 +721,15 @@ impl ResponseResult for DatafeedStatus {} pub struct DatafeedstatusesCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The ID of the data feed to get or delete. #[serde(rename="datafeedId")] - pub datafeed_id: String, + pub datafeed_id: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, } impl Part for DatafeedstatusesCustomBatchRequestEntry {} @@ -740,14 +743,14 @@ impl Part for DatafeedstatusesCustomBatchRequestEntry {} pub struct AccounttaxCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The retrieved or updated account tax settings. #[serde(rename="accountTax")] - pub account_tax: AccountTax, + pub account_tax: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accounttaxCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, } impl Part for AccounttaxCustomBatchResponseEntry {} @@ -783,11 +786,11 @@ impl RequestValue for AccountstatusesCustomBatchRequest {} pub struct AccountShippingShippingServiceCostRule { /// Final calculation method to be used only in leaf nodes. #[serde(rename="calculationMethod")] - pub calculation_method: AccountShippingShippingServiceCalculationMethod, + pub calculation_method: Option, /// Condition for this rule to be applicable. If no condition is specified, the rule acts as a catch-all. - pub condition: AccountShippingCondition, + pub condition: Option, /// Subsequent rules to be applied, only for inner nodes. The last child must not specify a condition and acts as a catch-all. - pub children: Vec, + pub children: Option>, } impl Part for AccountShippingShippingServiceCostRule {} @@ -821,7 +824,7 @@ pub struct Account { /// Indicates whether the merchant sells adult content. #[serde(rename="adultContent")] pub adult_content: Option, - /// List of linked AdWords accounts. + /// List of linked AdWords accounts, active or pending approval. To create a new link request, add a new link with status active to the list. It will remain is state pending until approved or rejected in the AdWords interface. To delete an active link or to cancel a link request, remove it from the list. #[serde(rename="adwordsLinks")] pub adwords_links: Option>, /// The merchant's website. @@ -849,10 +852,10 @@ impl ResponseResult for Account {} pub struct AccountIdentifier { /// The aggregator ID, set for aggregators and subaccounts (in that case, it represents the aggregator of the subaccount). #[serde(rename="aggregatorId")] - pub aggregator_id: String, + pub aggregator_id: Option, /// The merchant account ID, set for individual accounts and subaccounts. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, } impl Part for AccountIdentifier {} @@ -866,11 +869,11 @@ impl Part for AccountIdentifier {} pub struct InventoryCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#inventoryCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, } impl Part for InventoryCustomBatchResponseEntry {} @@ -883,9 +886,9 @@ impl Part for InventoryCustomBatchResponseEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductCustomGroup { /// The sub-attributes. - pub attributes: Vec, + pub attributes: Option>, /// The name of the group. Underscores will be replaced by spaces upon insertion. - pub name: String, + pub name: Option, } impl Part for ProductCustomGroup {} @@ -902,9 +905,9 @@ pub struct ProductShippingDimension { /// Acceptable values are: /// - "cm" /// - "in" - pub unit: String, + pub unit: Option, /// The dimension of the product used to calculate the shipping cost of the item. - pub value: f64, + pub value: Option, } impl Part for ProductShippingDimension {} @@ -918,12 +921,12 @@ impl Part for ProductShippingDimension {} pub struct AccountstatusesCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// The requested account status. Defined if and only if the request was successful. #[serde(rename="accountStatus")] - pub account_status: AccountStatus, + pub account_status: Option, } impl Part for AccountstatusesCustomBatchResponseEntry {} @@ -937,15 +940,15 @@ impl Part for AccountstatusesCustomBatchResponseEntry {} pub struct AccountstatusesCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The ID of the (sub-)account whose status to get. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// The method (get). - pub method: String, + pub method: Option, } impl Part for AccountstatusesCustomBatchRequestEntry {} @@ -964,11 +967,11 @@ impl Part for AccountstatusesCustomBatchRequestEntry {} pub struct AccounttaxListResponse { /// The token for the retrieval of the next page of account tax settings. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accounttaxListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for AccounttaxListResponse {} @@ -999,11 +1002,11 @@ impl RequestValue for DatafeedstatusesCustomBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ErrorType { /// The error code. - pub reason: String, + pub reason: Option, /// A description of the error. - pub message: String, + pub message: Option, /// The domain of the error. - pub domain: String, + pub domain: Option, } impl Part for ErrorType {} @@ -1017,11 +1020,11 @@ impl Part for ErrorType {} pub struct DatafeedsCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// The requested data feed. Defined if and only if the request was successful. - pub datafeed: Datafeed, + pub datafeed: Option, } impl Part for DatafeedsCustomBatchResponseEntry {} @@ -1035,18 +1038,18 @@ impl Part for DatafeedsCustomBatchResponseEntry {} pub struct AccountshippingCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The ID of the account for which to get/update account shipping settings. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// The account shipping settings to update. Only defined if the method is update. #[serde(rename="accountShipping")] - pub account_shipping: AccountShipping, + pub account_shipping: Option, /// no description provided - pub method: String, + pub method: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, } impl Part for AccountshippingCustomBatchRequestEntry {} @@ -1065,11 +1068,11 @@ impl Part for AccountshippingCustomBatchRequestEntry {} pub struct DatafeedsListResponse { /// The token for the retrieval of the next page of datafeeds. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#datafeedsListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for DatafeedsListResponse {} @@ -1083,21 +1086,21 @@ impl ResponseResult for DatafeedsListResponse {} pub struct ProductShipping { /// The numeric id of a location that the shipping rate applies to as defined in the AdWords API. #[serde(rename="locationId")] - pub location_id: String, + pub location_id: Option, /// A free-form description of the service class or delivery speed. - pub service: String, + pub service: Option, /// The postal code range that the shipping rate applies to, represented by a postal code, a postal code prefix followed by a * wildcard, a range between two postal codes or two postal code prefixes of equal length. #[serde(rename="postalCode")] - pub postal_code: String, + pub postal_code: Option, /// The two-letter ISO 3166 country code for the country to which an item will ship. - pub country: String, + pub country: Option, /// Fixed shipping price, represented as a number. - pub price: Price, + pub price: Option, /// The geographic region to which a shipping rate applies (e.g. zip code). - pub region: String, + pub region: Option, /// The location where the shipping is applicable, represented by a location group name. #[serde(rename="locationGroupName")] - pub location_group_name: String, + pub location_group_name: Option, } impl Part for ProductShipping {} @@ -1137,17 +1140,17 @@ impl ResponseResult for AccountTax {} pub struct ProductsCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The product to insert. Only required if the method is insert. - pub product: Product, + pub product: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, /// The ID of the product to get or delete. Only defined if the method is get or delete. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl Part for ProductsCustomBatchRequestEntry {} @@ -1161,13 +1164,13 @@ impl Part for ProductsCustomBatchRequestEntry {} pub struct AccountsCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The retrieved, created, or updated account. Not defined if the method was delete. - pub account: Account, + pub account: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accountsCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, } impl Part for AccountsCustomBatchResponseEntry {} @@ -1203,9 +1206,9 @@ impl RequestValue for AccountsCustomBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductstatusesCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#productstatusesCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for ProductstatusesCustomBatchResponse {} @@ -1219,23 +1222,23 @@ impl ResponseResult for ProductstatusesCustomBatchResponse {} pub struct AccountShippingCarrierRate { /// Shipping origin represented as a postal code. #[serde(rename="shippingOrigin")] - pub shipping_origin: String, + pub shipping_origin: Option, /// The carrier that is responsible for the shipping, such as "UPS", "FedEx", or "USPS". - pub carrier: String, + pub carrier: Option, /// The name of the carrier rate. - pub name: String, + pub name: Option, /// Sale country for which this carrier rate is valid, represented as an ISO 3166-1 Alpha-2 code. #[serde(rename="saleCountry")] - pub sale_country: i64, + pub sale_country: Option, /// The carrier service, such as "Ground" or "2Day". #[serde(rename="carrierService")] - pub carrier_service: String, + pub carrier_service: Option, /// Additive shipping rate modifier. #[serde(rename="modifierFlatRate")] - pub modifier_flat_rate: Price, + pub modifier_flat_rate: Option, /// Multiplicative shipping rate modifier in percent. Represented as a floating point number without the percentage character. #[serde(rename="modifierPercent")] - pub modifier_percent: String, + pub modifier_percent: Option, } impl Part for AccountShippingCarrierRate {} @@ -1302,18 +1305,18 @@ impl ResponseResult for Datafeed {} pub struct AccountShippingShippingServiceCalculationMethod { /// Percentage of the price, represented as a floating point number without the percentage character. #[serde(rename="percentageRate")] - pub percentage_rate: String, + pub percentage_rate: Option, /// Name of the carrier rate to use for the calculation. #[serde(rename="carrierRate")] - pub carrier_rate: String, + pub carrier_rate: Option, /// Name of the rate table to use for the calculation. #[serde(rename="rateTable")] - pub rate_table: String, + pub rate_table: Option, /// Delivery is excluded. Valid only within cost rules tree. - pub excluded: bool, + pub excluded: Option, /// Fixed price shipping, represented as a floating point number associated with a currency. #[serde(rename="flatRate")] - pub flat_rate: Price, + pub flat_rate: Option, } impl Part for AccountShippingShippingServiceCalculationMethod {} @@ -1326,20 +1329,20 @@ impl Part for AccountShippingShippingServiceCalculationMethod {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductTax { /// The percentage of tax rate that applies to the item price. - pub rate: f64, + pub rate: Option, /// The numeric id of a location that the tax rate applies to as defined in the AdWords API. #[serde(rename="locationId")] - pub location_id: String, + pub location_id: Option, /// The postal code range that the tax rate applies to, represented by a ZIP code, a ZIP code prefix using * wildcard, a range between two ZIP codes or two ZIP code prefixes of equal length. Examples: 94114, 94*, 94002-95460, 94*-95*. #[serde(rename="postalCode")] - pub postal_code: String, + pub postal_code: Option, /// The country within which the item is taxed, specified with a two-letter ISO 3166 country code. - pub country: String, + pub country: Option, /// The geographic region to which the tax rate applies. - pub region: String, + pub region: Option, /// Set to true if tax is charged on shipping. #[serde(rename="taxShip")] - pub tax_ship: bool, + pub tax_ship: Option, } impl Part for ProductTax {} @@ -1357,9 +1360,9 @@ impl Part for ProductTax {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatafeedstatusesCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#datafeedstatusesCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for DatafeedstatusesCustomBatchResponse {} @@ -1373,17 +1376,17 @@ impl ResponseResult for DatafeedstatusesCustomBatchResponse {} pub struct AccountsCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The account to create or update. Only defined if the method is insert or update. - pub account: Account, + pub account: Option, /// The ID of the account to get or delete. Only defined if the method is get or delete. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, } impl Part for AccountsCustomBatchRequestEntry {} @@ -1401,13 +1404,13 @@ impl Part for AccountsCustomBatchRequestEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountsAuthInfoResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#accountsAuthInfoResponse". - pub kind: String, + pub kind: Option, /// The account identifiers corresponding to the authenticated user. /// - For an individual account: only the merchant ID is defined /// - For an aggregator: only the aggregator ID is defined /// - For a subaccount of an MCA: both the merchant ID and the aggregator ID are defined. #[serde(rename="accountIdentifiers")] - pub account_identifiers: Vec, + pub account_identifiers: Option>, } impl ResponseResult for AccountsAuthInfoResponse {} @@ -1444,11 +1447,11 @@ impl RequestValue for ProductsCustomBatchRequest {} pub struct DatafeedstatusesListResponse { /// The token for the retrieval of the next page of datafeed statuses. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#datafeedstatusesListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for DatafeedstatusesListResponse {} @@ -1461,9 +1464,9 @@ impl ResponseResult for DatafeedstatusesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductUnitPricingMeasure { /// The unit of the measure. - pub unit: String, + pub unit: Option, /// The measure of an item. - pub value: f64, + pub value: Option, } impl Part for ProductUnitPricingMeasure {} @@ -1481,9 +1484,9 @@ impl Part for ProductUnitPricingMeasure {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountstatusesCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#accountstatusesCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for AccountstatusesCustomBatchResponse {} @@ -1501,13 +1504,13 @@ impl ResponseResult for AccountstatusesCustomBatchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountStatus { /// Identifies what kind of resource this is. Value: the fixed string "content#accountStatus". - pub kind: String, + pub kind: Option, /// A list of data quality issues. #[serde(rename="dataQualityIssues")] - pub data_quality_issues: Vec, + pub data_quality_issues: Option>, /// The ID of the account for which the status is reported. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, } impl ResponseResult for AccountStatus {} @@ -1520,9 +1523,9 @@ impl ResponseResult for AccountStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductInstallment { /// The amount the buyer has to pay per month. - pub amount: Price, + pub amount: Option, /// The number of installments the buyer has to pay. - pub months: String, + pub months: Option, } impl Part for ProductInstallment {} @@ -1536,12 +1539,12 @@ impl Part for ProductInstallment {} pub struct DatafeedstatusesCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// The requested data feed status. Defined if and only if the request was successful. #[serde(rename="datafeedStatus")] - pub datafeed_status: DatafeedStatus, + pub datafeed_status: Option, } impl Part for DatafeedstatusesCustomBatchResponseEntry {} @@ -1554,19 +1557,19 @@ impl Part for DatafeedstatusesCustomBatchResponseEntry {} #[derive(Default, Clone, Debug, Serialize)] pub struct Inventory { /// Identifies what kind of resource this is. Value: the fixed string "content#inventory". - pub kind: String, + pub kind: Option, /// The sale price of the product. Mandatory if sale_price_effective_date is defined. #[serde(rename="salePrice")] - pub sale_price: Price, + pub sale_price: Option, /// A date range represented by a pair of ISO 8601 dates separated by a space, comma, or slash. Both dates might be specified as 'null' if undecided. #[serde(rename="salePriceEffectiveDate")] - pub sale_price_effective_date: String, + pub sale_price_effective_date: Option, /// The price of the product. - pub price: Price, + pub price: Option, /// The availability of the product. - pub availability: String, + pub availability: Option, /// The quantity of the product. Must be equal to or greater than zero. Supported only for local products. - pub quantity: u32, + pub quantity: Option, } impl Part for Inventory {} @@ -1579,12 +1582,12 @@ impl Part for Inventory {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountShippingRateTable { /// One-dimensional table cells define one condition along the same dimension. Bi-dimensional table cells use two dimensions with respectively M and N distinct values and must contain exactly M * N cells with distinct conditions (for each possible value pairs). - pub content: Vec, + pub content: Option>, /// Sale country for which this table is valid, represented as an ISO 3166-1 Alpha-2 code. #[serde(rename="saleCountry")] - pub sale_country: i64, + pub sale_country: Option, /// The name of the rate table. - pub name: String, + pub name: Option, } impl Part for AccountShippingRateTable {} @@ -1598,11 +1601,11 @@ impl Part for AccountShippingRateTable {} pub struct ProductStatusDestinationStatus { /// The destination's approval status. #[serde(rename="approvalStatus")] - pub approval_status: String, + pub approval_status: Option, /// The name of the destination - pub destination: String, + pub destination: Option, /// Whether the destination is required, excluded, selected by default or should be validated. - pub intention: String, + pub intention: Option, } impl Part for ProductStatusDestinationStatus {} @@ -1634,18 +1637,18 @@ impl RequestValue for AccounttaxCustomBatchRequest {} pub struct InventoryCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The code of the store for which to update price and availability. Use online to update price and availability of an online product. #[serde(rename="storeCode")] - pub store_code: String, + pub store_code: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// Price and availability of the product. - pub inventory: Inventory, + pub inventory: Option, /// The ID of the product for which to update price and availability. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl Part for InventoryCustomBatchRequestEntry {} @@ -1663,9 +1666,9 @@ impl Part for InventoryCustomBatchRequestEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductsCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#productsCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for ProductsCustomBatchResponse {} @@ -1684,11 +1687,11 @@ impl ResponseResult for ProductsCustomBatchResponse {} pub struct AccountshippingListResponse { /// The token for the retrieval of the next page of account shipping settings. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accountshippingListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for AccountshippingListResponse {} @@ -1702,17 +1705,17 @@ impl ResponseResult for AccountshippingListResponse {} pub struct AccountStatusExampleItem { /// Unique item ID as specified in the uploaded product data. #[serde(rename="itemId")] - pub item_id: String, + pub item_id: Option, /// The item value that was submitted. #[serde(rename="submittedValue")] - pub submitted_value: String, + pub submitted_value: Option, /// Landing page of the item. - pub link: String, + pub link: Option, /// The actual value on the landing page. #[serde(rename="valueOnLandingPage")] - pub value_on_landing_page: String, + pub value_on_landing_page: Option, /// Title of the item. - pub title: String, + pub title: Option, } impl Part for AccountStatusExampleItem {} @@ -1726,15 +1729,15 @@ impl Part for AccountStatusExampleItem {} pub struct ProductstatusesCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, /// The ID of the product whose status to get. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option, } impl Part for ProductstatusesCustomBatchRequestEntry {} @@ -1747,9 +1750,9 @@ impl Part for ProductstatusesCustomBatchRequestEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Price { /// The currency of the price. - pub currency: String, + pub currency: Option, /// The price represented as a number. - pub value: String, + pub value: Option, } impl Part for Price {} @@ -1762,13 +1765,13 @@ impl Part for Price {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatafeedStatusError { /// The number of occurrences of the error in the feed. - pub count: String, + pub count: Option, /// The error message, e.g., "Invalid price". - pub message: String, + pub message: Option, /// The code of the error, e.g., "validation/invalid_value". - pub code: String, + pub code: Option, /// A list of example occurrences of the error, grouped by product. - pub examples: Vec, + pub examples: Option>, } impl Part for DatafeedStatusError {} @@ -1782,12 +1785,12 @@ impl Part for DatafeedStatusError {} pub struct DatafeedStatusExample { /// The ID of the example item. #[serde(rename="itemId")] - pub item_id: String, + pub item_id: Option, /// The problematic value. - pub value: String, + pub value: Option, /// Line number in the data feed where the example is found. #[serde(rename="lineNumber")] - pub line_number: String, + pub line_number: Option, } impl Part for DatafeedStatusExample {} @@ -1800,9 +1803,9 @@ impl Part for DatafeedStatusExample {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductShippingWeight { /// The unit of value. - pub unit: String, + pub unit: Option, /// The weight of the product used to calculate the shipping cost of the item. - pub value: f64, + pub value: Option, } impl Part for ProductShippingWeight {} @@ -1816,18 +1819,18 @@ impl Part for ProductShippingWeight {} pub struct AccounttaxCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The account tax settings to update. Only defined if the method is update. #[serde(rename="accountTax")] - pub account_tax: AccountTax, + pub account_tax: Option, /// The ID of the account for which to get/update account tax settings. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, } impl Part for AccounttaxCustomBatchRequestEntry {} @@ -1875,9 +1878,9 @@ impl ResponseResult for AccountShipping {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductUnitPricingBaseMeasure { /// The unit of the denominator. - pub unit: String, + pub unit: Option, /// The denominator of the unit price. - pub value: String, + pub value: Option, } impl Part for ProductUnitPricingBaseMeasure {} @@ -1890,19 +1893,19 @@ impl Part for ProductUnitPricingBaseMeasure {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountTaxTaxRule { /// Country code in which tax is applicable. - pub country: String, + pub country: Option, /// Explicit tax rate in percent, represented as a floating point number without the percentage character. Must not be negative. #[serde(rename="ratePercent")] - pub rate_percent: String, + pub rate_percent: Option, /// If true, shipping charges are also taxed. #[serde(rename="shippingTaxed")] - pub shipping_taxed: bool, + pub shipping_taxed: Option, /// State (or province) is which the tax is applicable, described by its location id (also called criteria id). #[serde(rename="locationId")] - pub location_id: String, + pub location_id: Option, /// Whether the tax rate is taken from a global tax table or specified explicitly. #[serde(rename="useGlobalRate")] - pub use_global_rate: bool, + pub use_global_rate: Option, } impl Part for AccountTaxTaxRule {} @@ -1915,14 +1918,14 @@ impl Part for AccountTaxTaxRule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductCustomAttribute { /// Free-form unit of the attribute. Unit can only be used for values of type INT or FLOAT. - pub unit: String, + pub unit: Option, /// The type of the attribute. #[serde(rename="type")] - pub type_: String, + pub type_: Option, /// The name of the attribute. Underscores will be replaced by spaces upon insertion. - pub name: String, + pub name: Option, /// The value of the attribute. - pub value: String, + pub value: Option, } impl Part for ProductCustomAttribute {} @@ -1941,11 +1944,11 @@ impl Part for ProductCustomAttribute {} pub struct AccountstatusesListResponse { /// The token for the retrieval of the next page of account statuses. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accountstatusesListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for AccountstatusesListResponse {} @@ -1959,25 +1962,25 @@ impl ResponseResult for AccountstatusesListResponse {} pub struct AccountShippingCondition { /// Maximum shipping weight. Forms an interval between the maximum of smaller weight (exclusive) and this weight (inclusive). #[serde(rename="weightMax")] - pub weight_max: Weight, + pub weight_max: Option, /// Delivery location in terms of a location ID. Can be used to represent administrative areas, smaller country subdivisions, or cities. #[serde(rename="deliveryLocationId")] - pub delivery_location_id: String, + pub delivery_location_id: Option, /// Shipping label of the product. The products with the label are matched. #[serde(rename="shippingLabel")] - pub shipping_label: String, + pub shipping_label: Option, /// Delivery location in terms of a location group name. A location group with this name must be specified among location groups. #[serde(rename="deliveryLocationGroup")] - pub delivery_location_group: String, + pub delivery_location_group: Option, /// Delivery location in terms of a postal code. #[serde(rename="deliveryPostalCode")] - pub delivery_postal_code: String, + pub delivery_postal_code: Option, /// Maximum shipping price. Forms an interval between the maximum of smaller prices (exclusive) and this price (inclusive). #[serde(rename="priceMax")] - pub price_max: Price, + pub price_max: Option, /// Delivery location in terms of a postal code range. #[serde(rename="deliveryPostalCodeRange")] - pub delivery_postal_code_range: AccountShippingPostalCodeRange, + pub delivery_postal_code_range: Option, } impl Part for AccountShippingCondition {} @@ -2213,23 +2216,23 @@ impl ResponseResult for Product {} pub struct ProductStatusDataQualityIssue { /// The value the attribute had at time of evaluation. #[serde(rename="valueProvided")] - pub value_provided: String, + pub value_provided: Option, /// The severity of the data quality issue. - pub severity: String, + pub severity: Option, /// The time stamp of the data quality issue. - pub timestamp: String, + pub timestamp: Option, /// A more detailed error string. - pub detail: String, + pub detail: Option, /// The attribute name that is relevant for the issue. - pub location: String, + pub location: Option, /// The value of that attribute that was found on the landing page #[serde(rename="valueOnLandingPage")] - pub value_on_landing_page: String, + pub value_on_landing_page: Option, /// The id of the data quality issue. - pub id: String, + pub id: Option, /// The fetch status for landing_page_errors. #[serde(rename="fetchStatus")] - pub fetch_status: String, + pub fetch_status: Option, } impl Part for ProductStatusDataQualityIssue {} @@ -2248,11 +2251,11 @@ impl Part for ProductStatusDataQualityIssue {} pub struct ProductsListResponse { /// The token for the retrieval of the next page of products. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#productsListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for ProductsListResponse {} @@ -2265,18 +2268,18 @@ impl ResponseResult for ProductsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountShippingShippingService { /// Whether the shipping service is available. - pub active: bool, + pub active: Option, /// Decision tree for "complicated" shipping cost calculation. #[serde(rename="costRuleTree")] - pub cost_rule_tree: AccountShippingShippingServiceCostRule, + pub cost_rule_tree: Option, /// Sale country for which this service can be used, represented as an ISO 3166-1 Alpha-2 code. #[serde(rename="saleCountry")] - pub sale_country: i64, + pub sale_country: Option, /// Calculation method for the "simple" case that needs no rules. #[serde(rename="calculationMethod")] - pub calculation_method: AccountShippingShippingServiceCalculationMethod, + pub calculation_method: Option, /// The name of this shipping service. - pub name: String, + pub name: Option, } impl Part for AccountShippingShippingService {} @@ -2290,14 +2293,14 @@ impl Part for AccountShippingShippingService {} pub struct AccountshippingCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accountshippingCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, /// A list of errors defined if and only if the request failed. - pub errors: Errors, + pub errors: Option, /// The retrieved or updated account shipping settings. #[serde(rename="accountShipping")] - pub account_shipping: AccountShipping, + pub account_shipping: Option, } impl Part for AccountshippingCustomBatchResponseEntry {} @@ -2338,10 +2341,10 @@ impl RequestValue for InventorySetRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProductDestination { /// Whether the destination is required, excluded or should be validated. - pub intention: String, + pub intention: Option, /// The name of the destination. #[serde(rename="destinationName")] - pub destination_name: String, + pub destination_name: Option, } impl Part for ProductDestination {} @@ -2359,9 +2362,9 @@ impl Part for ProductDestination {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountsCustomBatchResponse { /// Identifies what kind of resource this is. Value: the fixed string "content#accountsCustomBatchResponse". - pub kind: String, + pub kind: Option, /// The result of the execution of the batch requests. - pub entries: Vec, + pub entries: Option>, } impl ResponseResult for AccountsCustomBatchResponse {} @@ -2375,17 +2378,17 @@ impl ResponseResult for AccountsCustomBatchResponse {} pub struct DatafeedsCustomBatchRequestEntry { /// An entry ID, unique within the batch request. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// The ID of the data feed to get or delete. #[serde(rename="datafeedId")] - pub datafeed_id: String, + pub datafeed_id: Option, /// The data feed to insert. - pub datafeed: Datafeed, + pub datafeed: Option, /// The ID of the managing account. #[serde(rename="merchantId")] - pub merchant_id: String, + pub merchant_id: Option, /// no description provided - pub method: String, + pub method: Option, } impl Part for DatafeedsCustomBatchRequestEntry {} @@ -2404,11 +2407,11 @@ impl Part for DatafeedsCustomBatchRequestEntry {} pub struct ProductstatusesListResponse { /// The token for the retrieval of the next page of products statuses. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#productstatusesListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for ProductstatusesListResponse {} @@ -2421,9 +2424,9 @@ impl ResponseResult for ProductstatusesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Weight { /// The weight unit. - pub unit: String, + pub unit: Option, /// The weight represented as a number. - pub value: String, + pub value: Option, } impl Part for Weight {} @@ -2437,25 +2440,25 @@ impl Part for Weight {} pub struct AccountStatusDataQualityIssue { /// Actual value displayed on the landing page. #[serde(rename="displayedValue")] - pub displayed_value: String, + pub displayed_value: Option, /// Severity of the problem. - pub severity: String, + pub severity: Option, /// Last time the account was checked for this issue. #[serde(rename="lastChecked")] - pub last_checked: String, + pub last_checked: Option, /// Country for which this issue is reported. - pub country: String, + pub country: Option, /// Example items featuring the issue. #[serde(rename="exampleItems")] - pub example_items: Vec, + pub example_items: Option>, /// Submitted value that causes the issue. #[serde(rename="submittedValue")] - pub submitted_value: String, + pub submitted_value: Option, /// Number of items in the account found to have the said issue. #[serde(rename="numItems")] - pub num_items: u32, + pub num_items: Option, /// Issue identifier. - pub id: String, + pub id: Option, } impl Part for AccountStatusDataQualityIssue {} @@ -2474,11 +2477,11 @@ impl Part for AccountStatusDataQualityIssue {} pub struct AccountsListResponse { /// The token for the retrieval of the next page of accounts. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#accountsListResponse". - pub kind: String, + pub kind: Option, /// no description provided - pub resources: Vec, + pub resources: Option>, } impl ResponseResult for AccountsListResponse {} @@ -2492,14 +2495,14 @@ impl ResponseResult for AccountsListResponse {} pub struct ProductstatusesCustomBatchResponseEntry { /// The ID of the request entry this entry responds to. #[serde(rename="batchId")] - pub batch_id: u32, + pub batch_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "content#productstatusesCustomBatchResponseEntry". - pub kind: String, + pub kind: Option, /// A list of errors, if the request failed. - pub errors: Errors, + pub errors: Option, /// The requested product status. Only defined if the request was successful. #[serde(rename="productStatus")] - pub product_status: ProductStatus, + pub product_status: Option, } impl Part for ProductstatusesCustomBatchResponseEntry {} @@ -2530,12 +2533,12 @@ impl RequestValue for AccountshippingCustomBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LoyaltyPoints { /// The ratio of a point when converted to currency. Google assumes currency based on Merchant Center settings. If ratio is left out, it defaults to 1.0. - pub ratio: f64, + pub ratio: Option, /// Name of loyalty points program. It is recommended to limit the name to 12 full-width characters or 24 Roman characters. - pub name: String, + pub name: Option, /// The retailer's loyalty points in absolute value. #[serde(rename="pointsValue")] - pub points_value: String, + pub points_value: Option, } impl Part for LoyaltyPoints {} @@ -2567,13 +2570,13 @@ impl RequestValue for DatafeedsCustomBatchRequest {} pub struct DatafeedFormat { /// Character encoding scheme of the data feed. If not specified, the encoding will be auto-detected. #[serde(rename="fileEncoding")] - pub file_encoding: String, + pub file_encoding: Option, /// Specifies how double quotes are interpreted. If not specified, the mode will be auto-detected. Ignored for non-DSV data feeds. #[serde(rename="quotingMode")] - pub quoting_mode: String, + pub quoting_mode: Option, /// Delimiter for the separation of values in a delimiter-separated values feed. If not specified, the delimiter will be auto-detected. Ignored for non-DSV data feeds. #[serde(rename="columnDelimiter")] - pub column_delimiter: String, + pub column_delimiter: Option, } impl Part for DatafeedFormat {} @@ -2585,11 +2588,11 @@ impl Part for DatafeedFormat {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountAdwordsLink { - /// Status of the link between this Merchant Center account and the AdWords account. - pub status: String, + /// Status of the link between this Merchant Center account and the AdWords account. Upon retrieval, it represents the actual status of the link and can be either active if it was approved in Google AdWords or pending if it's pending approval. Upon insertion, it represents the intended status of the link. Re-uploading a link with status active when it's still pending or with status pending when it's already active will have no effect: the status will remain unchanged. Re-uploading a link with deprecated status inactive is equivalent to not submitting the link at all and will delete the link if it was active or cancel the link request if it was pending. + pub status: Option, /// Customer ID of the AdWords account. #[serde(rename="adwordsId")] - pub adwords_id: String, + pub adwords_id: Option, } impl Part for AccountAdwordsLink {} @@ -2604,9 +2607,9 @@ impl Part for AccountAdwordsLink {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountShippingPostalCodeRange { /// The first (inclusive) postal code or prefix of the range. - pub start: String, + pub start: Option, /// The last (inclusive) postal code or prefix of the range. - pub end: String, + pub end: Option, } impl Part for AccountShippingPostalCodeRange {} @@ -2666,6 +2669,7 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { AccounttaxCustombatchCall { hub: self.hub, _request: request.clone(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2687,6 +2691,7 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { _request: request.clone(), _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -2727,6 +2732,7 @@ impl<'a, C, A> AccounttaxMethods<'a, C, A> { _request: request.clone(), _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3688,6 +3694,7 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { _request: request.clone(), _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3709,6 +3716,7 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { _request: request.clone(), _merchant_id: merchant_id.to_string(), _account_id: account_id.to_string(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3726,6 +3734,7 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { AccountshippingCustombatchCall { hub: self.hub, _request: request.clone(), + _dry_run: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -3787,12 +3796,13 @@ impl<'a, C, A> AccountshippingMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccounttaxCustomBatchRequest = Default::default(); +/// let mut req = AccounttaxCustomBatchRequest::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.accounttax().custombatch(&req) +/// .dry_run(false) /// .doit(); /// # } /// ``` @@ -3801,6 +3811,7 @@ pub struct AccounttaxCustombatchCall<'a, C, A> hub: &'a ShoppingContent, _request: AccounttaxCustomBatchRequest, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -3822,8 +3833,11 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3853,16 +3867,20 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3926,6 +3944,13 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut AccounttaxCustombatchCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -4005,12 +4030,13 @@ impl<'a, C, A> AccounttaxCustombatchCall<'a, C, A> where C: BorrowMut _request: AccountTax, _merchant_id: String, _account_id: String, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -4042,10 +4069,13 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "content.accounttax.patch", http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4099,16 +4129,20 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4192,6 +4226,13 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, self._account_id = new_value.to_string(); self } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> AccounttaxPatchCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -4271,8 +4312,8 @@ impl<'a, C, A> AccounttaxPatchCall<'a, C, A> where C: BorrowMut, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounttax().list("merchantId") -/// .page_token("justo") -/// .max_results(100) +/// .page_token("erat") +/// .max_results(66) /// .doit(); /// # } /// ``` @@ -4362,16 +4403,20 @@ impl<'a, C, A> AccounttaxListCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4525,12 +4570,13 @@ impl<'a, C, A> AccounttaxListCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccountTax = Default::default(); +/// let mut req = AccountTax::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.accounttax().update(&req, "merchantId", "accountId") +/// .dry_run(true) /// .doit(); /// # } /// ``` @@ -4541,6 +4587,7 @@ pub struct AccounttaxUpdateCall<'a, C, A> _request: AccountTax, _merchant_id: String, _account_id: String, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -4562,10 +4609,13 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, }; dlg.begin(MethodInfo { id: "content.accounttax.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -4619,16 +4669,20 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4712,6 +4766,13 @@ impl<'a, C, A> AccounttaxUpdateCall<'a, C, A> where C: BorrowMut, self._account_id = new_value.to_string(); self } + /// Flag to run the request in dry-run mode. + /// + /// Sets the *dry run* query property to the given value. + pub fn dry_run(mut self, new_value: bool) -> AccounttaxUpdateCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -4874,16 +4935,20 @@ impl<'a, C, A> AccounttaxGetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5116,16 +5181,20 @@ impl<'a, C, A> DatafeedstatuseGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5273,8 +5342,8 @@ impl<'a, C, A> DatafeedstatuseGetCall<'a, C, A> where C: BorrowMut DatafeedstatuseListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5525,7 +5598,7 @@ impl<'a, C, A> DatafeedstatuseListCall<'a, C, A> where C: BorrowMut DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5741,7 +5818,7 @@ impl<'a, C, A> DatafeedstatuseCustombatchCall<'a, C, A> where C: BorrowMut DatafeedCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6042,16 +6123,20 @@ impl<'a, C, A> DatafeedGetCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6199,7 +6284,7 @@ impl<'a, C, A> DatafeedGetCall<'a, C, A> where C: BorrowMut, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Datafeed = Default::default(); +/// let mut req = Datafeed::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6293,16 +6378,20 @@ impl<'a, C, A> DatafeedPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6545,16 +6634,20 @@ impl<'a, C, A> DatafeedDeleteCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6692,7 +6785,7 @@ impl<'a, C, A> DatafeedDeleteCall<'a, C, A> where C: BorrowMut, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Datafeed = Default::default(); +/// let mut req = Datafeed::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6784,16 +6877,20 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6945,8 +7042,8 @@ impl<'a, C, A> DatafeedInsertCall<'a, C, A> where C: BorrowMut, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.datafeeds().list("merchantId") -/// .page_token("et") -/// .max_results(31) +/// .page_token("sea") +/// .max_results(46) /// .doit(); /// # } /// ``` @@ -7036,16 +7133,20 @@ impl<'a, C, A> DatafeedListCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7199,7 +7300,7 @@ impl<'a, C, A> DatafeedListCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Datafeed = Default::default(); +/// let mut req = Datafeed::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7293,16 +7394,20 @@ impl<'a, C, A> DatafeedUpdateCall<'a, C, A> where C: BorrowMut, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7546,16 +7651,20 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7705,8 +7814,8 @@ impl<'a, C, A> ProductstatuseGetCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.productstatuses().list("merchantId") -/// .page_token("sadipscing") -/// .max_results(53) +/// .page_token("elitr") +/// .max_results(4) /// .doit(); /// # } /// ``` @@ -7796,16 +7905,20 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7959,7 +8072,7 @@ impl<'a, C, A> ProductstatuseListCall<'a, C, A> where C: BorrowMut ProductstatuseCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8232,16 +8349,20 @@ impl<'a, C, A> AccountAuthinfoCall<'a, C, A> where C: BorrowMut, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8371,7 +8492,7 @@ impl<'a, C, A> AccountAuthinfoCall<'a, C, A> where C: BorrowMut, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8465,16 +8586,20 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8720,16 +8845,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8879,7 +9008,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8973,16 +9102,20 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9145,8 +9278,8 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().list("merchantId") -/// .page_token("invidunt") -/// .max_results(19) +/// .page_token("Lorem") +/// .max_results(92) /// .doit(); /// # } /// ``` @@ -9236,16 +9369,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9481,16 +9618,20 @@ impl<'a, C, A> AccountDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -9630,7 +9771,7 @@ impl<'a, C, A> AccountDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccountsCustomBatchRequest = Default::default(); +/// let mut req = AccountsCustomBatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9696,16 +9837,20 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9848,7 +9993,7 @@ impl<'a, C, A> AccountCustombatchCall<'a, C, A> where C: BorrowMut AccountInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10102,7 +10251,7 @@ impl<'a, C, A> AccountInsertCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InventorySetRequest = Default::default(); +/// let mut req = InventorySetRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10198,16 +10347,20 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10380,7 +10533,7 @@ impl<'a, C, A> InventorySetCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InventoryCustomBatchRequest = Default::default(); +/// let mut req = InventoryCustomBatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10446,16 +10599,20 @@ impl<'a, C, A> InventoryCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10681,16 +10838,20 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10840,8 +11001,8 @@ impl<'a, C, A> AccountstatuseGetCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accountstatuses().list("merchantId") -/// .page_token("amet") -/// .max_results(78) +/// .page_token("ut") +/// .max_results(85) /// .doit(); /// # } /// ``` @@ -10931,16 +11092,20 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11092,7 +11257,7 @@ impl<'a, C, A> AccountstatuseListCall<'a, C, A> where C: BorrowMut AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11310,8 +11479,8 @@ impl<'a, C, A> AccountstatuseCustombatchCall<'a, C, A> where C: BorrowMut ProductListCall<'a, C, A> where C: BorrowMut, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11647,16 +11820,20 @@ impl<'a, C, A> ProductGetCall<'a, C, A> where C: BorrowMut, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11893,16 +12070,20 @@ impl<'a, C, A> ProductDeleteCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -12049,7 +12230,7 @@ impl<'a, C, A> ProductDeleteCall<'a, C, A> where C: BorrowMut, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ProductsCustomBatchRequest = Default::default(); +/// let mut req = ProductsCustomBatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12120,16 +12301,20 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12279,7 +12464,7 @@ impl<'a, C, A> ProductCustombatchCall<'a, C, A> where C: BorrowMut ProductInsertCall<'a, C, A> where C: BorrowMut, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12545,8 +12734,8 @@ impl<'a, C, A> ProductInsertCall<'a, C, A> where C: BorrowMut, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accountshipping().list("merchantId") -/// .page_token("gubergren") -/// .max_results(81) +/// .page_token("vero") +/// .max_results(73) /// .doit(); /// # } /// ``` @@ -12636,16 +12825,20 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12799,12 +12992,13 @@ impl<'a, C, A> AccountshippingListCall<'a, C, A> where C: BorrowMut _request: AccountShipping, _merchant_id: String, _account_id: String, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -12836,10 +13031,13 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -12893,16 +13091,20 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12986,6 +13188,13 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut AccountshippingPatchCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -13065,12 +13274,13 @@ impl<'a, C, A> AccountshippingPatchCall<'a, C, A> where C: BorrowMut _request: AccountShipping, _merchant_id: String, _account_id: String, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13102,10 +13313,13 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((5 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("merchantId", self._merchant_id.to_string())); params.push(("accountId", self._account_id.to_string())); - for &field in ["alt", "merchantId", "accountId"].iter() { + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "merchantId", "accountId", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13159,16 +13373,20 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13252,6 +13470,13 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut AccountshippingUpdateCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -13331,12 +13556,13 @@ impl<'a, C, A> AccountshippingUpdateCall<'a, C, A> where C: BorrowMut hub: &'a ShoppingContent, _request: AccountshippingCustomBatchRequest, + _dry_run: Option, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, _scopes: BTreeMap @@ -13366,8 +13593,11 @@ impl<'a, C, A> AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if let Some(value) = self._dry_run { + params.push(("dryRun", value.to_string())); + } + for &field in ["alt", "dryRun"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -13397,16 +13627,20 @@ impl<'a, C, A> AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13470,6 +13704,13 @@ impl<'a, C, A> AccountshippingCustombatchCall<'a, C, A> where C: BorrowMut AccountshippingCustombatchCall<'a, C, A> { + self._dry_run = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -13632,16 +13873,20 @@ impl<'a, C, A> AccountshippingGetCall<'a, C, A> where C: BorrowMut token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/coordinate1-cli/Cargo.toml b/gen/coordinate1-cli/Cargo.toml deleted file mode 100644 index 50e5614ff5..0000000000 --- a/gen/coordinate1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-coordinate1-cli" -version = "0.0.1+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" -homepage = "https://developers.google.com/coordinate/" -documentation = "http://byron.github.io/google-apis-rs/google_coordinate1_cli" -license = "MIT" -keywords = ["coordinate", "google", "cli"] - -[[bin]] -name = "coordinate1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-coordinate1] -path = "../coordinate1" diff --git a/gen/coordinate1-cli/LICENSE.md b/gen/coordinate1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/coordinate1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ - -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/coordinate1-cli/README.md b/gen/coordinate1-cli/README.md deleted file mode 100644 index 79383e596c..0000000000 --- a/gen/coordinate1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO COORDINATE:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/coordinate1-cli/mkdocs.yml b/gen/coordinate1-cli/mkdocs.yml deleted file mode 100644 index 56fb9f231b..0000000000 --- a/gen/coordinate1-cli/mkdocs.yml +++ /dev/null @@ -1,28 +0,0 @@ -site_name: coordinate v0.0.1+20141215 -site_url: http://byron.github.io/google-apis-rs/google-coordinate1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/coordinate1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['custom-field-def_list.md', 'Custom Field Def', 'List'] -- ['jobs_get.md', 'Jobs', 'Get'] -- ['jobs_insert.md', 'Jobs', 'Insert'] -- ['jobs_list.md', 'Jobs', 'List'] -- ['jobs_patch.md', 'Jobs', 'Patch'] -- ['jobs_update.md', 'Jobs', 'Update'] -- ['location_list.md', 'Location', 'List'] -- ['schedule_get.md', 'Schedule', 'Get'] -- ['schedule_patch.md', 'Schedule', 'Patch'] -- ['schedule_update.md', 'Schedule', 'Update'] -- ['team_list.md', 'Team', 'List'] -- ['worker_list.md', 'Worker', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/coordinate1-cli/src/cmn.rs b/gen/coordinate1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/coordinate1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - ::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern =", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/coordinate1-cli/src/main.rs b/gen/coordinate1-cli/src/main.rs deleted file mode 100644 index 6dfe1e3457..0000000000 --- a/gen/coordinate1-cli/src/main.rs +++ /dev/null @@ -1,1110 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_coordinate1 as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - 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 TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Coordinate<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _custom_field_def_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.custom_field_def().list(&self.opt.arg_team_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _jobs_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.jobs().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _jobs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Job = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_state_init(request: &mut api::Job) { - if request.state.is_none() { - request.state = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "state.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "state.customer-name" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_name = value.unwrap_or("").to_string(); - }, - "state.title" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().title = value.unwrap_or("").to_string(); - }, - "state.note" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().note.push(value.unwrap_or("").to_string()); - }, - "state.assignee" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().assignee = value.unwrap_or("").to_string(); - }, - "state.customer-phone-number" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_phone_number = value.unwrap_or("").to_string(); - }, - "state.location.lat" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lat = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lat", "number"); - }, - "state.location.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.kind = value.unwrap_or("").to_string(); - }, - "state.location.address-line" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.address_line.push(value.unwrap_or("").to_string()); - }, - "state.location.lng" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lng = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lng", "number"); - }, - "state.progress" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().progress = value.unwrap_or("").to_string(); - }, - "state.custom-fields.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().custom_fields.kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _jobs_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.jobs().list(&self.opt.arg_team_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "min-modified-timestamp-ms" => { - call = call.min_modified_timestamp_ms(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _jobs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Job = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_state_init(request: &mut api::Job) { - if request.state.is_none() { - request.state = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "state.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "state.customer-name" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_name = value.unwrap_or("").to_string(); - }, - "state.title" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().title = value.unwrap_or("").to_string(); - }, - "state.note" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().note.push(value.unwrap_or("").to_string()); - }, - "state.assignee" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().assignee = value.unwrap_or("").to_string(); - }, - "state.customer-phone-number" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_phone_number = value.unwrap_or("").to_string(); - }, - "state.location.lat" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lat = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lat", "number"); - }, - "state.location.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.kind = value.unwrap_or("").to_string(); - }, - "state.location.address-line" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.address_line.push(value.unwrap_or("").to_string()); - }, - "state.location.lng" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lng = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lng", "number"); - }, - "state.progress" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().progress = value.unwrap_or("").to_string(); - }, - "state.custom-fields.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().custom_fields.kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _jobs_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Job = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_state_init(request: &mut api::Job) { - if request.state.is_none() { - request.state = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "state.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "state.customer-name" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_name = value.unwrap_or("").to_string(); - }, - "state.title" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().title = value.unwrap_or("").to_string(); - }, - "state.note" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().note.push(value.unwrap_or("").to_string()); - }, - "state.assignee" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().assignee = value.unwrap_or("").to_string(); - }, - "state.customer-phone-number" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().customer_phone_number = value.unwrap_or("").to_string(); - }, - "state.location.lat" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lat = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lat", "number"); - }, - "state.location.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.kind = value.unwrap_or("").to_string(); - }, - "state.location.address-line" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.address_line.push(value.unwrap_or("").to_string()); - }, - "state.location.lng" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().location.lng = arg_from_str(value.unwrap_or("0.0"), err, "state.location.lng", "number"); - }, - "state.progress" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().progress = value.unwrap_or("").to_string(); - }, - "state.custom-fields.kind" => { - request_state_init(&mut request); - request.state.as_mut().unwrap().custom_fields.kind = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _location_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.location().list(&self.opt.arg_team_id, &self.opt.arg_worker_email, &self.opt.arg_start_timestamp_ms); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schedule_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.schedule().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schedule_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Schedule = Default::default(); - 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); - match key { - "start-time" => { - call = call.start_time(value.unwrap_or("")); - }, - "end-time" => { - call = call.end_time(value.unwrap_or("")); - }, - "duration" => { - call = call.duration(value.unwrap_or("")); - }, - "all-day" => { - call = call.all_day(arg_from_str(value.unwrap_or("false"), err, "all-day", "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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _schedule_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Schedule = Default::default(); - 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); - match key { - "start-time" => { - call = call.start_time(value.unwrap_or("")); - }, - "end-time" => { - call = call.end_time(value.unwrap_or("")); - }, - "duration" => { - call = call.duration(value.unwrap_or("")); - }, - "all-day" => { - call = call.all_day(arg_from_str(value.unwrap_or("false"), err, "all-day", "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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _team_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.team().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "worker" => { - call = call.worker(arg_from_str(value.unwrap_or("false"), err, "worker", "boolean")); - }, - "dispatcher" => { - call = call.dispatcher(arg_from_str(value.unwrap_or("false"), err, "dispatcher", "boolean")); - }, - "admin" => { - call = call.admin(arg_from_str(value.unwrap_or("false"), err, "admin", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _worker_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.worker().list(&self.opt.arg_team_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_custom_field_def { - if self.opt.cmd_list { - call_result = self._custom_field_def_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_jobs { - if self.opt.cmd_get { - call_result = self._jobs_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._jobs_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._jobs_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._jobs_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._jobs_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_location { - if self.opt.cmd_list { - call_result = self._location_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_schedule { - if self.opt.cmd_get { - call_result = self._schedule_get(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._schedule_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._schedule_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_team { - if self.opt.cmd_list { - call_result = self._team_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_worker { - if self.opt.cmd_list { - call_result = self._worker_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "coordinate1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "coordinate1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Coordinate::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/coordinate1/Cargo.toml b/gen/coordinate1/Cargo.toml index 8654894bc1..c73092cc31 100644 --- a/gen/coordinate1/Cargo.toml +++ b/gen/coordinate1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-coordinate1" version = "0.1.5+20141215" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/coordinate/" diff --git a/gen/coordinate1/README.md b/gen/coordinate1/README.md index c00c008741..89ebb17c60 100644 --- a/gen/coordinate1/README.md +++ b/gen/coordinate1/README.md @@ -107,7 +107,7 @@ let mut hub = Coordinate::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Job = Default::default(); +let mut req = Job::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/coordinate1/src/cmn.rs b/gen/coordinate1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/coordinate1/src/cmn.rs +++ b/gen/coordinate1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/coordinate1/src/lib.rs b/gen/coordinate1/src/lib.rs index cfb998c11b..6246d22a76 100644 --- a/gen/coordinate1/src/lib.rs +++ b/gen/coordinate1/src/lib.rs @@ -108,7 +108,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Job = Default::default(); +//! let mut req = Job::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -297,7 +297,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Job = Default::default(); +/// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -398,14 +398,14 @@ impl<'a, C, A> Coordinate<C, A> pub struct LocationListResponse { /// A token to provide to get the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Locations in the collection. - pub items: Vec<LocationRecord>, + pub items: Option<Vec<LocationRecord>>, /// Identifies this object as a list of locations. - pub kind: String, + pub kind: Option<String>, /// Pagination information for token pagination. #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, } impl ResponseResult for LocationListResponse {} @@ -418,11 +418,11 @@ impl ResponseResult for LocationListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobChange { /// Time at which this change was applied. - pub timestamp: String, + pub timestamp: Option<String>, /// Identifies this object as a job change. - pub kind: String, + pub kind: Option<String>, /// Change applied to the job. Only the fields that were changed are set. - pub state: JobState, + pub state: Option<JobState>, } impl Part for JobChange {} @@ -435,11 +435,11 @@ impl Part for JobChange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EnumItemDef { /// Whether the enum item is active. Jobs may contain inactive enum values; however, setting an enum to an inactive value when creating or updating a job will result in a 500 error. - pub active: bool, + pub active: Option<bool>, /// Identifies this object as an enum item definition. - pub kind: String, + pub kind: Option<String>, /// Custom field value. - pub value: String, + pub value: Option<String>, } impl Part for EnumItemDef {} @@ -457,9 +457,9 @@ impl Part for EnumItemDef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomFieldDefListResponse { /// Collection of custom field definitions in a team. - pub items: Vec<CustomFieldDef>, + pub items: Option<Vec<CustomFieldDef>>, /// Identifies this object as a collection of custom field definitions in a team. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CustomFieldDefListResponse {} @@ -473,12 +473,12 @@ impl ResponseResult for CustomFieldDefListResponse {} pub struct TokenPagination { /// A token to provide to get the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A token to provide to get the previous page of results. #[serde(rename="previousPageToken")] - pub previous_page_token: String, + pub previous_page_token: Option<String>, /// Identifies this object as pagination information. - pub kind: String, + pub kind: Option<String>, } impl Part for TokenPagination {} @@ -491,14 +491,14 @@ impl Part for TokenPagination {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Location { /// Latitude. - pub lat: f64, + pub lat: Option<f64>, /// Identifies this object as a location. - pub kind: String, + pub kind: Option<String>, /// Address. #[serde(rename="addressLine")] - pub address_line: Vec<String>, + pub address_line: Option<Vec<String>>, /// Longitude. - pub lng: f64, + pub lng: Option<f64>, } impl Part for Location {} @@ -511,11 +511,11 @@ impl Part for Location {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Team { /// Identifies this object as a team. - pub kind: String, + pub kind: Option<String>, /// Team id, as found in a coordinate team url e.g. https://coordinate.google.com/f/xyz where "xyz" is the team id. - pub id: String, + pub id: Option<String>, /// Team name - pub name: String, + pub name: Option<String>, } impl Part for Team {} @@ -528,26 +528,26 @@ impl Part for Team {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobState { /// Identifies this object as a job state. - pub kind: String, + pub kind: Option<String>, /// Customer name. #[serde(rename="customerName")] - pub customer_name: String, + pub customer_name: Option<String>, /// Job title. - pub title: String, + pub title: Option<String>, /// Note added to the job. - pub note: Vec<String>, + pub note: Option<Vec<String>>, /// Email address of the assignee, or the string "DELETED_USER" if the account is no longer available. - pub assignee: String, + pub assignee: Option<String>, /// Customer phone number. #[serde(rename="customerPhoneNumber")] - pub customer_phone_number: String, + pub customer_phone_number: Option<String>, /// Job location. - pub location: Location, + pub location: Option<Location>, /// Job progress. - pub progress: String, + pub progress: Option<String>, /// Custom fields. #[serde(rename="customFields")] - pub custom_fields: CustomFields, + pub custom_fields: Option<CustomFields>, } impl Part for JobState {} @@ -560,10 +560,10 @@ impl Part for JobState {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomFields { /// Identifies this object as a collection of custom fields. - pub kind: String, + pub kind: Option<String>, /// Collection of custom fields. #[serde(rename="customField")] - pub custom_field: Vec<CustomField>, + pub custom_field: Option<Vec<CustomField>>, } impl Part for CustomFields {} @@ -581,9 +581,9 @@ impl Part for CustomFields {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WorkerListResponse { /// Workers in the collection. - pub items: Vec<Worker>, + pub items: Option<Vec<Worker>>, /// Identifies this object as a list of workers. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for WorkerListResponse {} @@ -596,17 +596,17 @@ impl ResponseResult for WorkerListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocationRecord { /// Latitude. - pub latitude: f64, + pub latitude: Option<f64>, /// The collection time in milliseconds since the epoch. #[serde(rename="collectionTime")] - pub collection_time: String, + pub collection_time: Option<String>, /// The location accuracy in meters. This is the radius of a 95% confidence interval around the location measurement. #[serde(rename="confidenceRadius")] - pub confidence_radius: f64, + pub confidence_radius: Option<f64>, /// Identifies this object as a location. - pub kind: String, + pub kind: Option<String>, /// Longitude. - pub longitude: f64, + pub longitude: Option<f64>, } impl Part for LocationRecord {} @@ -656,9 +656,9 @@ impl ResponseResult for Schedule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TeamListResponse { /// Teams in the collection. - pub items: Vec<Team>, + pub items: Option<Vec<Team>>, /// Identifies this object as a list of teams. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for TeamListResponse {} @@ -677,11 +677,11 @@ impl ResponseResult for TeamListResponse {} pub struct JobListResponse { /// A token to provide to get the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Jobs in the collection. - pub items: Vec<Job>, + pub items: Option<Vec<Job>>, /// Identifies this object as a list of jobs. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for JobListResponse {} @@ -694,9 +694,9 @@ impl ResponseResult for JobListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Worker { /// Identifies this object as a worker. - pub kind: String, + pub kind: Option<String>, /// Worker email address. If a worker has been deleted from your team, the email address will appear as DELETED_USER. - pub id: String, + pub id: Option<String>, } impl Part for Worker {} @@ -740,21 +740,21 @@ impl ResponseResult for Job {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomFieldDef { /// Identifies this object as a custom field definition. - pub kind: String, + pub kind: Option<String>, /// List of enum items for this custom field. Populated only if the field type is enum. Enum fields appear as 'lists' in the Coordinate web and mobile UI. - pub enumitems: Vec<EnumItemDef>, + pub enumitems: Option<Vec<EnumItemDef>>, /// Custom field name. - pub name: String, + pub name: Option<String>, /// Custom field type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Whether the field is required for checkout. #[serde(rename="requiredForCheckout")] - pub required_for_checkout: bool, + pub required_for_checkout: Option<bool>, /// Whether the field is enabled. - pub enabled: bool, + pub enabled: Option<bool>, /// Custom field id. - pub id: String, + pub id: Option<String>, } impl Part for CustomFieldDef {} @@ -767,12 +767,12 @@ impl Part for CustomFieldDef {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomField { /// Identifies this object as a custom field. - pub kind: String, + pub kind: Option<String>, /// Custom field id. #[serde(rename="customFieldId")] - pub custom_field_id: String, + pub custom_field_id: Option<String>, /// Custom field value. - pub value: String, + pub value: Option<String>, } impl Part for CustomField {} @@ -1419,16 +1419,20 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1578,7 +1582,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Job = Default::default(); +/// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1726,16 +1730,20 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1969,7 +1977,7 @@ impl<'a, C, A> JobUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Job = Default::default(); +/// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2117,16 +2125,20 @@ impl<'a, C, A> JobPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2456,16 +2468,20 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2626,7 +2642,7 @@ impl<'a, C, A> JobListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Job = Default::default(); +/// let mut req = Job::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2755,16 +2771,20 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2993,7 +3013,7 @@ impl<'a, C, A> JobInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Schedule = Default::default(); +/// let mut req = Schedule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3107,16 +3127,20 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3307,7 +3331,7 @@ impl<'a, C, A> ScheduleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Schedule = Default::default(); +/// let mut req = Schedule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3421,16 +3445,20 @@ impl<'a, C, A> SchedulePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3704,16 +3732,20 @@ impl<'a, C, A> ScheduleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3944,16 +3976,20 @@ impl<'a, C, A> WorkerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4188,16 +4224,20 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4441,16 +4481,20 @@ impl<'a, C, A> TeamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4682,16 +4726,20 @@ impl<'a, C, A> CustomFieldDefListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/customsearch1-cli/Cargo.toml b/gen/customsearch1-cli/Cargo.toml deleted file mode 100644 index 8e4df44ba7..0000000000 --- a/gen/customsearch1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-customsearch1-cli" -version = "0.0.1+20131205" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with customsearch (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1-cli" -homepage = "https://developers.google.com/custom-search/v1/using_rest" -documentation = "http://byron.github.io/google-apis-rs/google_customsearch1_cli" -license = "MIT" -keywords = ["customsearch", "google", "cli"] - -[[bin]] -name = "customsearch1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-customsearch1] -path = "../customsearch1" diff --git a/gen/customsearch1-cli/LICENSE.md b/gen/customsearch1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/customsearch1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/customsearch1-cli/README.md b/gen/customsearch1-cli/README.md deleted file mode 100644 index 260a95e544..0000000000 --- a/gen/customsearch1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO CUSTOMSEARCH:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/customsearch1-cli/mkdocs.yml b/gen/customsearch1-cli/mkdocs.yml deleted file mode 100644 index 4f2a14ddf7..0000000000 --- a/gen/customsearch1-cli/mkdocs.yml +++ /dev/null @@ -1,17 +0,0 @@ -site_name: customsearch v0.0.1+20131205 -site_url: http://byron.github.io/google-apis-rs/google-customsearch1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/customsearch1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['cse_list.md', 'Cse', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/customsearch1-cli/src/cmn.rs b/gen/customsearch1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/customsearch1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/customsearch1-cli/src/main.rs b/gen/customsearch1-cli/src/main.rs deleted file mode 100644 index 86abceac2d..0000000000 --- a/gen/customsearch1-cli/src/main.rs +++ /dev/null @@ -1,262 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_customsearch1 as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - 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> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Customsearch<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _cse_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.cse().list(&self.opt.arg_q); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start" => { - call = call.start(arg_from_str(value.unwrap_or("-0"), err, "start", "integer")); - }, - "sort" => { - call = call.sort(value.unwrap_or("")); - }, - "site-search-filter" => { - call = call.site_search_filter(value.unwrap_or("")); - }, - "site-search" => { - call = call.site_search(value.unwrap_or("")); - }, - "search-type" => { - call = call.search_type(value.unwrap_or("")); - }, - "safe" => { - call = call.safe(value.unwrap_or("")); - }, - "rights" => { - call = call.rights(value.unwrap_or("")); - }, - "related-site" => { - call = call.related_site(value.unwrap_or("")); - }, - "or-terms" => { - call = call.or_terms(value.unwrap_or("")); - }, - "num" => { - call = call.num(arg_from_str(value.unwrap_or("-0"), err, "num", "integer")); - }, - "lr" => { - call = call.lr(value.unwrap_or("")); - }, - "low-range" => { - call = call.low_range(value.unwrap_or("")); - }, - "link-site" => { - call = call.link_site(value.unwrap_or("")); - }, - "img-type" => { - call = call.img_type(value.unwrap_or("")); - }, - "img-size" => { - call = call.img_size(value.unwrap_or("")); - }, - "img-dominant-color" => { - call = call.img_dominant_color(value.unwrap_or("")); - }, - "img-color-type" => { - call = call.img_color_type(value.unwrap_or("")); - }, - "hq" => { - call = call.hq(value.unwrap_or("")); - }, - "hl" => { - call = call.hl(value.unwrap_or("")); - }, - "high-range" => { - call = call.high_range(value.unwrap_or("")); - }, - "googlehost" => { - call = call.googlehost(value.unwrap_or("")); - }, - "gl" => { - call = call.gl(value.unwrap_or("")); - }, - "filter" => { - call = call.filter(value.unwrap_or("")); - }, - "file-type" => { - call = call.file_type(value.unwrap_or("")); - }, - "exclude-terms" => { - call = call.exclude_terms(value.unwrap_or("")); - }, - "exact-terms" => { - call = call.exact_terms(value.unwrap_or("")); - }, - "date-restrict" => { - call = call.date_restrict(value.unwrap_or("")); - }, - "cx" => { - call = call.cx(value.unwrap_or("")); - }, - "cref" => { - call = call.cref(value.unwrap_or("")); - }, - "cr" => { - call = call.cr(value.unwrap_or("")); - }, - "c2coff" => { - call = call.c2coff(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_cse { - if self.opt.cmd_list { - call_result = self._cse_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "customsearch1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "customsearch1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Customsearch::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/customsearch1/Cargo.toml b/gen/customsearch1/Cargo.toml index 311edc162f..9f30355854 100644 --- a/gen/customsearch1/Cargo.toml +++ b/gen/customsearch1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-customsearch1" version = "0.1.5+20131205" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/custom-search/v1/using_rest" diff --git a/gen/customsearch1/src/cmn.rs b/gen/customsearch1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/customsearch1/src/cmn.rs +++ b/gen/customsearch1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/customsearch1/src/lib.rs b/gen/customsearch1/src/lib.rs index 1516e35e80..0cdbc7448d 100644 --- a/gen/customsearch1/src/lib.rs +++ b/gen/customsearch1/src/lib.rs @@ -367,24 +367,24 @@ impl<'a, C, A> Customsearch<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultImage { /// no description provided - pub width: i32, + pub width: Option<i32>, /// no description provided #[serde(rename="contextLink")] - pub context_link: String, + pub context_link: Option<String>, /// no description provided #[serde(rename="thumbnailWidth")] - pub thumbnail_width: i32, + pub thumbnail_width: Option<i32>, /// no description provided #[serde(rename="thumbnailLink")] - pub thumbnail_link: String, + pub thumbnail_link: Option<String>, /// no description provided #[serde(rename="byteSize")] - pub byte_size: i32, + pub byte_size: Option<i32>, /// no description provided #[serde(rename="thumbnailHeight")] - pub thumbnail_height: i32, + pub thumbnail_height: Option<i32>, /// no description provided - pub height: i32, + pub height: Option<i32>, } impl NestedType for ResultImage {} @@ -403,22 +403,22 @@ impl Part for ResultImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Search { /// no description provided - pub promotions: Vec<Promotion>, + pub promotions: Option<Vec<Promotion>>, /// no description provided - pub kind: String, + pub kind: Option<String>, /// no description provided - pub url: SearchUrl, + pub url: Option<SearchUrl>, /// no description provided - pub items: Vec<ResultType>, + pub items: Option<Vec<ResultType>>, /// no description provided - pub context: Context, + pub context: Option<Context>, /// no description provided - pub queries: HashMap<String, Vec<Query>>, + pub queries: Option<HashMap<String, Vec<Query>>>, /// no description provided - pub spelling: SearchSpelling, + pub spelling: Option<SearchSpelling>, /// no description provided #[serde(rename="searchInformation")] - pub search_information: SearchSearchInformation, + pub search_information: Option<SearchSearchInformation>, } impl ResponseResult for Search {} @@ -431,11 +431,11 @@ impl ResponseResult for Search {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PromotionImage { /// no description provided - pub source: String, + pub source: Option<String>, /// no description provided - pub height: i32, + pub height: Option<i32>, /// no description provided - pub width: i32, + pub width: Option<i32>, } impl NestedType for PromotionImage {} @@ -450,9 +450,9 @@ impl Part for PromotionImage {} pub struct SearchUrl { /// no description provided #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// no description provided - pub template: String, + pub template: Option<String>, } impl NestedType for SearchUrl {} @@ -467,10 +467,10 @@ impl Part for SearchUrl {} pub struct SearchSpelling { /// no description provided #[serde(rename="correctedQuery")] - pub corrected_query: String, + pub corrected_query: Option<String>, /// no description provided #[serde(rename="htmlCorrectedQuery")] - pub html_corrected_query: String, + pub html_corrected_query: Option<String>, } impl NestedType for SearchSpelling {} @@ -484,14 +484,14 @@ impl Part for SearchSpelling {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PromotionBodyLines { /// no description provided - pub url: String, + pub url: Option<String>, /// no description provided #[serde(rename="htmlTitle")] - pub html_title: String, + pub html_title: Option<String>, /// no description provided - pub link: String, + pub link: Option<String>, /// no description provided - pub title: String, + pub title: Option<String>, } impl NestedType for PromotionBodyLines {} @@ -505,42 +505,42 @@ impl Part for PromotionBodyLines {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultType { /// no description provided - pub kind: String, + pub kind: Option<String>, /// no description provided - pub labels: Vec<ResultLabels>, + pub labels: Option<Vec<ResultLabels>>, /// no description provided - pub title: String, + pub title: Option<String>, /// no description provided #[serde(rename="displayLink")] - pub display_link: String, + pub display_link: Option<String>, /// no description provided #[serde(rename="cacheId")] - pub cache_id: String, + pub cache_id: Option<String>, /// no description provided #[serde(rename="formattedUrl")] - pub formatted_url: String, + pub formatted_url: Option<String>, /// no description provided #[serde(rename="htmlFormattedUrl")] - pub html_formatted_url: String, + pub html_formatted_url: Option<String>, /// no description provided - pub pagemap: HashMap<String, Vec<HashMap<String, String>>>, + pub pagemap: Option<HashMap<String, Vec<HashMap<String, String>>>>, /// no description provided #[serde(rename="fileFormat")] - pub file_format: String, + pub file_format: Option<String>, /// no description provided - pub snippet: String, + pub snippet: Option<String>, /// no description provided #[serde(rename="htmlSnippet")] - pub html_snippet: String, + pub html_snippet: Option<String>, /// no description provided - pub link: String, + pub link: Option<String>, /// no description provided - pub image: ResultImage, + pub image: Option<ResultImage>, /// no description provided - pub mime: String, + pub mime: Option<String>, /// no description provided #[serde(rename="htmlTitle")] - pub html_title: String, + pub html_title: Option<String>, } impl Part for ResultType {} @@ -553,9 +553,9 @@ impl Part for ResultType {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Context { /// no description provided - pub facets: Vec<Vec<ContextFacets>>, + pub facets: Option<Vec<Vec<ContextFacets>>>, /// no description provided - pub title: String, + pub title: Option<String>, } impl Part for Context {} @@ -568,11 +568,11 @@ impl Part for Context {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContextFacets { /// no description provided - pub label_with_op: String, + pub label_with_op: Option<String>, /// no description provided - pub anchor: String, + pub anchor: Option<String>, /// no description provided - pub label: String, + pub label: Option<String>, } impl NestedType for ContextFacets {} @@ -587,102 +587,102 @@ impl Part for ContextFacets {} pub struct Query { /// no description provided #[serde(rename="dateRestrict")] - pub date_restrict: String, + pub date_restrict: Option<String>, /// no description provided #[serde(rename="inputEncoding")] - pub input_encoding: String, + pub input_encoding: Option<String>, /// no description provided #[serde(rename="orTerms")] - pub or_terms: String, + pub or_terms: Option<String>, /// no description provided #[serde(rename="highRange")] - pub high_range: String, + pub high_range: Option<String>, /// no description provided - pub cx: String, + pub cx: Option<String>, /// no description provided #[serde(rename="startPage")] - pub start_page: i32, + pub start_page: Option<i32>, /// no description provided #[serde(rename="disableCnTwTranslation")] - pub disable_cn_tw_translation: String, + pub disable_cn_tw_translation: Option<String>, /// no description provided - pub cr: String, + pub cr: Option<String>, /// no description provided #[serde(rename="imgType")] - pub img_type: String, + pub img_type: Option<String>, /// no description provided #[serde(rename="relatedSite")] - pub related_site: String, + pub related_site: Option<String>, /// no description provided - pub gl: String, + pub gl: Option<String>, /// no description provided #[serde(rename="searchType")] - pub search_type: String, + pub search_type: Option<String>, /// no description provided - pub title: String, + pub title: Option<String>, /// no description provided #[serde(rename="googleHost")] - pub google_host: String, + pub google_host: Option<String>, /// no description provided #[serde(rename="fileType")] - pub file_type: String, + pub file_type: Option<String>, /// no description provided #[serde(rename="imgDominantColor")] - pub img_dominant_color: String, + pub img_dominant_color: Option<String>, /// no description provided #[serde(rename="siteSearch")] - pub site_search: String, + pub site_search: Option<String>, /// no description provided - pub cref: String, + pub cref: Option<String>, /// no description provided - pub sort: String, + pub sort: Option<String>, /// no description provided - pub hq: String, + pub hq: Option<String>, /// no description provided #[serde(rename="outputEncoding")] - pub output_encoding: String, + pub output_encoding: Option<String>, /// no description provided - pub safe: String, + pub safe: Option<String>, /// no description provided #[serde(rename="searchTerms")] - pub search_terms: String, + pub search_terms: Option<String>, /// no description provided #[serde(rename="exactTerms")] - pub exact_terms: String, + pub exact_terms: Option<String>, /// no description provided #[serde(rename="imgColorType")] - pub img_color_type: String, + pub img_color_type: Option<String>, /// no description provided - pub hl: String, + pub hl: Option<String>, /// no description provided #[serde(rename="totalResults")] - pub total_results: String, + pub total_results: Option<String>, /// no description provided #[serde(rename="lowRange")] - pub low_range: String, + pub low_range: Option<String>, /// no description provided - pub count: i32, + pub count: Option<i32>, /// no description provided #[serde(rename="imgSize")] - pub img_size: String, + pub img_size: Option<String>, /// no description provided - pub language: String, + pub language: Option<String>, /// no description provided - pub rights: String, + pub rights: Option<String>, /// no description provided #[serde(rename="startIndex")] - pub start_index: i32, + pub start_index: Option<i32>, /// no description provided #[serde(rename="excludeTerms")] - pub exclude_terms: String, + pub exclude_terms: Option<String>, /// no description provided - pub filter: String, + pub filter: Option<String>, /// no description provided #[serde(rename="linkSite")] - pub link_site: String, + pub link_site: Option<String>, /// no description provided #[serde(rename="siteSearchFilter")] - pub site_search_filter: String, + pub site_search_filter: Option<String>, } impl Part for Query {} @@ -696,19 +696,19 @@ impl Part for Query {} pub struct Promotion { /// no description provided #[serde(rename="bodyLines")] - pub body_lines: Vec<PromotionBodyLines>, + pub body_lines: Option<Vec<PromotionBodyLines>>, /// no description provided - pub title: String, + pub title: Option<String>, /// no description provided - pub link: String, + pub link: Option<String>, /// no description provided #[serde(rename="displayLink")] - pub display_link: String, + pub display_link: Option<String>, /// no description provided #[serde(rename="htmlTitle")] - pub html_title: String, + pub html_title: Option<String>, /// no description provided - pub image: PromotionImage, + pub image: Option<PromotionImage>, } impl Part for Promotion {} @@ -722,16 +722,16 @@ impl Part for Promotion {} pub struct SearchSearchInformation { /// no description provided #[serde(rename="formattedSearchTime")] - pub formatted_search_time: String, + pub formatted_search_time: Option<String>, /// no description provided #[serde(rename="formattedTotalResults")] - pub formatted_total_results: String, + pub formatted_total_results: Option<String>, /// no description provided #[serde(rename="totalResults")] - pub total_results: String, + pub total_results: Option<String>, /// no description provided #[serde(rename="searchTime")] - pub search_time: f64, + pub search_time: Option<f64>, } impl NestedType for SearchSearchInformation {} @@ -746,11 +746,11 @@ impl Part for SearchSearchInformation {} pub struct ResultLabels { /// no description provided #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// no description provided - pub label_with_op: String, + pub label_with_op: Option<String>, /// no description provided - pub name: String, + pub name: Option<String>, } impl NestedType for ResultLabels {} diff --git a/gen/dataflow1_b4-cli/Cargo.toml b/gen/dataflow1_b4-cli/Cargo.toml deleted file mode 100644 index 8617519c98..0000000000 --- a/gen/dataflow1_b4-cli/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-dataflow1_b4-cli" -version = "0.0.1+20150401" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dataflow (protocol v1b4)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dataflow1_b4-cli" -documentation = "http://byron.github.io/google-apis-rs/google_dataflow1_b4_cli" -license = "MIT" -keywords = ["dataflow", "google", "cli"] - -[[bin]] -name = "dataflow1-b4" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-dataflow1_b4] -path = "../dataflow1_b4" diff --git a/gen/dataflow1_b4-cli/LICENSE.md b/gen/dataflow1_b4-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dataflow1_b4-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dataflow1_b4-cli/README.md b/gen/dataflow1_b4-cli/README.md deleted file mode 100644 index 5156a139a7..0000000000 --- a/gen/dataflow1_b4-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO DATAFLOW:V1B4 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/dataflow1_b4-cli/mkdocs.yml b/gen/dataflow1_b4-cli/mkdocs.yml deleted file mode 100644 index 7c7d9095f2..0000000000 --- a/gen/dataflow1_b4-cli/mkdocs.yml +++ /dev/null @@ -1,16 +0,0 @@ -site_name: dataflow v0.0.1+20150401 -site_url: http://byron.github.io/google-apis-rs/google-dataflow1_b4-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dataflow1_b4-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/dataflow1_b4-cli/src/cmn.rs b/gen/dataflow1_b4-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/dataflow1_b4-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/dataflow1_b4-cli/src/main.rs b/gen/dataflow1_b4-cli/src/main.rs deleted file mode 100644 index 13da9f8991..0000000000 --- a/gen/dataflow1_b4-cli/src/main.rs +++ /dev/null @@ -1,118 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_dataflow1_b4 as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - dataflow1-b4 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Dataflow<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "dataflow1-b4-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "dataflow1-b4", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Dataflow::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/dataflow1_b4/Cargo.toml b/gen/dataflow1_b4/Cargo.toml deleted file mode 100644 index 11b6631364..0000000000 --- a/gen/dataflow1_b4/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-dataflow1_b4" -version = "0.1.5+20150401" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dataflow (protocol v1b4)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dataflow1_b4" -documentation = "http://byron.github.io/google-apis-rs/google_dataflow1_b4" -license = "MIT" -keywords = ["dataflow", "google", "protocol", "web", "api"] - - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -url = "*" -serde = ">= 0.3.0" -serde_macros = "*" diff --git a/gen/dataflow1_b4/LICENSE.md b/gen/dataflow1_b4/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dataflow1_b4/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dataflow1_b4/README.md b/gen/dataflow1_b4/README.md deleted file mode 100644 index c33eddfca1..0000000000 --- a/gen/dataflow1_b4/README.md +++ /dev/null @@ -1,142 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/api/README.md.mako' -DO NOT EDIT ! ---> -The `google-dataflow1_b4` library allows access to all features of the *Google dataflow* service. - -This documentation was generated from *dataflow* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *dataflow:v1b4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. -# Features - -It seems there is nothing you can do here ... . - - - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_dataflow1_b4/struct.Dataflow.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.CallBuilder.html)** - * operations to apply to *Resources* - -All *structures* are marked with applicable traits to further categorize them and ease browsing. - -Generally speaking, you can invoke *Activities* like this: - -```Rust,ignore -let r = hub.resource().activity(...).doit() -``` - - -The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` -supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be -specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. -The `doit()` method performs the actual communication with the server and returns the respective result. - -# Usage - -## Setting up your Project - -To use this library, you would put the following lines into your `Cargo.toml` file: - -```toml -[dependencies] -google-dataflow1_b4 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_dataflow1_b4 as dataflow1_b4; - -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use dataflow1_b4::Dataflow; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: ApplicationSecret = Default::default(); -// Instantiate the authenticator. It will choose a suitable authentication flow for you, -// unless you replace `None` with the desired Flow. -// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about -// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and -// retrieve them from storage. -let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - <MemoryStorage as Default>::default(), None); -let mut hub = Dataflow::new(hyper::Client::new(), auth); - -``` - -## Handling Errors - -All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_dataflow1_b4/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dataflow1_b4/../yup-oauth2/trait.AuthenticatorDelegate.html). - -When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This -makes the system potentially resilient to all kinds of errors. - -## Uploads and Downloads -If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google_dataflow1_b4/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.ResponseResult.html), it will return that by default. -You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making -this call: `.param("alt", "media")`. - -Methods supporting uploads can do so using up to 2 different protocols: -*simple* and *resumable*. The distinctiveness of each is represented by customized -`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. - -## Customization and Callbacks - -You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.CallBuilder.html) before making the final `doit()` call. -Respective methods will be called to provide progress information, as well as determine whether the system should -retry on failure. - -The [delegate trait](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. - -## Optional Parts in Server-Requests - -All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.Part.html) which are identifiable by name, which will be sent to -the server to indicate either the set parts of the request or the desired parts in the response. - -## Builder Arguments - -Using [method builders](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. -These will always take a single argument, for which the following statements are true. - -* [PODs][wiki-pod] are handed by copy -* strings are passed as `&str` -* [request values](http://byron.github.io/google-apis-rs/google_dataflow1_b4/trait.RequestValue.html) are borrowed - -Arguments will always be copied or cloned into the builder, to make them independent of their original life times. - -[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure -[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern -[google-go-api]: https://github.com/google/google-api-go-client - -# License -The **dataflow1_b4** library was generated by Sebastian Thiel, and is placed -under the *MIT* license. -You can read the full text at the repository's [license file][repo-license]. - -[repo-license]: https://github.com/Byron/google-apis-rs/LICENSE.md diff --git a/gen/dataflow1_b4/src/lib.rs b/gen/dataflow1_b4/src/lib.rs deleted file mode 100644 index 3c128163c9..0000000000 --- a/gen/dataflow1_b4/src/lib.rs +++ /dev/null @@ -1,255 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/api/lib.rs.mako' -// DO NOT EDIT ! - -//! This documentation was generated from *dataflow* crate version *0.1.5+20150401*, where *20150401* is the exact revision of the *dataflow:v1b4* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dataflow1_b4). -//! # Features -//! -//! It seems there is nothing you can do here ... . -//! -//! -//! -//! -//! -//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html). -//! -//! # Structure of this Library -//! -//! The API is structured into the following primary items: -//! -//! * **[Hub](struct.Dataflow.html)** -//! * a central object to maintain state and allow accessing all *Activities* -//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn -//! allow access to individual [*Call Builders*](trait.CallBuilder.html) -//! * **[Resources](trait.Resource.html)** -//! * primary types that you can apply *Activities* to -//! * a collection of properties and *Parts* -//! * **[Parts](trait.Part.html)** -//! * a collection of properties -//! * never directly used in *Activities* -//! * **[Activities](trait.CallBuilder.html)** -//! * operations to apply to *Resources* -//! -//! All *structures* are marked with applicable traits to further categorize them and ease browsing. -//! -//! Generally speaking, you can invoke *Activities* like this: -//! -//! ```Rust,ignore -//! let r = hub.resource().activity(...).doit() -//! ``` -//! -//! -//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` -//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be -//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. -//! The `doit()` method performs the actual communication with the server and returns the respective result. -//! -//! # Usage -//! -//! ## Setting up your Project -//! -//! To use this library, you would put the following lines into your `Cargo.toml` file: -//! -//! ```toml -//! [dependencies] -//! google-dataflow1_b4 = "*" -//! ``` -//! -//! ## A complete example -//! -//! ```test_harness,no_run -//! extern crate hyper; -//! extern crate yup_oauth2 as oauth2; -//! extern crate google_dataflow1_b4 as dataflow1_b4; -//! -//! # #[test] fn egal() { -//! use std::default::Default; -//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use dataflow1_b4::Dataflow; -//! -//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and -//! // `client_secret`, among other things. -//! let secret: ApplicationSecret = Default::default(); -//! // Instantiate the authenticator. It will choose a suitable authentication flow for you, -//! // unless you replace `None` with the desired Flow. -//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about -//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and -//! // retrieve them from storage. -//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -//! hyper::Client::new(), -//! <MemoryStorage as Default>::default(), None); -//! let mut hub = Dataflow::new(hyper::Client::new(), auth); -//! # } -//! ``` -//! -//! ## Handling Errors -//! -//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of -//! the doit() methods, or handed as possibly intermediate results to either the -//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html). -//! -//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This -//! makes the system potentially resilient to all kinds of errors. -//! -//! ## Uploads and Downloads -//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be -//! read by you to obtain the media. -//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default. -//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making -//! this call: `.param("alt", "media")`. -//! -//! Methods supporting uploads can do so using up to 2 different protocols: -//! *simple* and *resumable*. The distinctiveness of each is represented by customized -//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. -//! -//! ## Customization and Callbacks -//! -//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the -//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call. -//! Respective methods will be called to provide progress information, as well as determine whether the system should -//! retry on failure. -//! -//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. -//! -//! ## Optional Parts in Server-Requests -//! -//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and -//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -//! are valid. -//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to -//! the server to indicate either the set parts of the request or the desired parts in the response. -//! -//! ## Builder Arguments -//! -//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. -//! These will always take a single argument, for which the following statements are true. -//! -//! * [PODs][wiki-pod] are handed by copy -//! * strings are passed as `&str` -//! * [request values](trait.RequestValue.html) are borrowed -//! -//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times. -//! -//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure -//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern -//! [google-go-api]: https://github.com/google/google-api-go-client -//! -//! -#![feature(std_misc)] -// Unused attributes happen thanks to defined, but unused structures -// We don't warn about this, as depending on the API, some data structures or facilities are never used. -// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any -// unused imports in fully featured APIs. Same with unused_mut ... . -#![allow(unused_imports, unused_mut, dead_code)] -// Required for serde annotations -#![feature(custom_derive, custom_attribute, plugin, slice_patterns)] -#![plugin(serde_macros)] - -#[macro_use] -extern crate hyper; -extern crate serde; -extern crate yup_oauth2 as oauth2; -extern crate mime; -extern crate url; - -mod cmn; - -use std::collections::HashMap; -use std::cell::RefCell; -use std::borrow::BorrowMut; -use std::default::Default; -use std::collections::BTreeMap; -use serde::json; -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}; - - -// ############## -// UTILITIES ### -// ############ - - - - -// ######## -// HUB ### -// ###### - -/// Central instance to access all Dataflow related resource activities -/// -/// # Examples -/// -/// Instantiate a new hub -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_dataflow1_b4 as dataflow1_b4; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dataflow1_b4::Dataflow; -/// -/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and -/// // `client_secret`, among other things. -/// let secret: ApplicationSecret = Default::default(); -/// // Instantiate the authenticator. It will choose a suitable authentication flow for you, -/// // unless you replace `None` with the desired Flow. -/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about -/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and -/// // retrieve them from storage. -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// <MemoryStorage as Default>::default(), None); -/// let mut hub = Dataflow::new(hyper::Client::new(), auth); -/// # } -/// ``` -/// -pub struct Dataflow<C, A> { - client: RefCell<C>, - auth: RefCell<A>, - _user_agent: String, -} - -impl<'a, C, A> Hub for Dataflow<C, A> {} - -impl<'a, C, A> Dataflow<C, A> - where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - pub fn new(client: C, authenticator: A) -> Dataflow<C, A> { - Dataflow { - client: RefCell::new(client), - auth: RefCell::new(authenticator), - _user_agent: "google-api-rust-client/0.1.5".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`. - /// - /// Returns the previously set user-agent. - pub fn user_agent(&mut self, agent_name: String) -> String { - let prev = self._user_agent.clone(); - self._user_agent = agent_name; - prev - } -} - - - -// ################### -// MethodBuilders ### -// ################# - - - -// ################### -// CallBuilders ### -// ################# - diff --git a/gen/datastore1_beta2-cli/Cargo.toml b/gen/datastore1_beta2-cli/Cargo.toml index 1e614b7b90..21f69fab5c 100644 --- a/gen/datastore1_beta2-cli/Cargo.toml +++ b/gen/datastore1_beta2-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-datastore1_beta2-cli" -version = "0.0.1+20140916" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/datastore/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/datastore1_beta2-cli/mkdocs.yml b/gen/datastore1_beta2-cli/mkdocs.yml index 7057d99aa7..f41a6c43dd 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+20140916 +site_name: datastore v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/datastore1_beta2-cli/src/cmn.rs +++ b/gen/datastore1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/datastore1_beta2-cli/src/main.rs b/gen/datastore1_beta2-cli/src/main.rs index ec371bdd68..68e59747b5 100644 --- a/gen/datastore1_beta2-cli/src/main.rs +++ b/gen/datastore1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -37,6 +38,12 @@ Configuration: 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. "); mod cmn; @@ -58,10 +65,10 @@ struct Engine { impl Engine { fn _datasets_allocate_ids(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AllocateIdsRequest = Default::default(); + let mut request = api::AllocateIdsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -81,9 +88,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -105,8 +113,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -115,10 +122,10 @@ impl Engine { fn _datasets_begin_transaction(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::BeginTransactionRequest = Default::default(); + let mut request = api::BeginTransactionRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -138,9 +145,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -165,8 +173,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -175,10 +182,10 @@ impl Engine { fn _datasets_commit(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CommitRequest = Default::default(); + let mut request = api::CommitRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -198,9 +205,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -222,7 +230,7 @@ impl Engine { }, "mutation.force" => { request_mutation_init(&mut request); - request.mutation.as_mut().unwrap().force = arg_from_str(value.unwrap_or("false"), err, "mutation.force", "boolean"); + 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()))); @@ -241,8 +249,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -251,10 +258,10 @@ impl Engine { fn _datasets_lookup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LookupRequest = Default::default(); + let mut request = api::LookupRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -274,9 +281,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -289,11 +297,11 @@ impl Engine { match &field_name.to_string()[..] { "read-options.transaction" => { request_read_options_init(&mut request); - request.read_options.as_mut().unwrap().transaction = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -312,8 +320,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -322,10 +329,10 @@ impl Engine { fn _datasets_rollback(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RollbackRequest = Default::default(); + let mut request = api::RollbackRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -345,9 +352,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -372,8 +380,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -382,10 +389,10 @@ impl Engine { fn _datasets_run_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RunQueryRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -405,9 +412,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -423,6 +431,76 @@ impl Engine { } } + fn request_query_filter_composite_filter_init(request: &mut api::RunQueryRequest) { + request_query_filter_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().composite_filter.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().composite_filter = Some(Default::default()); + } + } + + fn request_query_filter_init(request: &mut api::RunQueryRequest) { + request_query_init(request); + if request.query.as_mut().unwrap().filter.is_none() { + request.query.as_mut().unwrap().filter = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_init(request: &mut api::RunQueryRequest) { + request_query_filter_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_property_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().property.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().property = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_entity_value_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_value_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_entity_value_key_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_value_entity_value_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_entity_value_key_partition_id_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_value_entity_value_key_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key.as_mut().unwrap().partition_id.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key.as_mut().unwrap().partition_id = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_key_value_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_value_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value = Some(Default::default()); + } + } + + fn request_query_filter_property_filter_value_key_value_partition_id_init(request: &mut api::RunQueryRequest) { + request_query_filter_property_filter_value_key_value_init(request); + if request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value.as_mut().unwrap().partition_id.is_none() { + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value.as_mut().unwrap().partition_id = Some(Default::default()); + } + } + fn request_query_init(request: &mut api::RunQueryRequest) { if request.query.is_none() { request.query = Some(Default::default()); @@ -437,108 +515,108 @@ impl Engine { match &field_name.to_string()[..] { "query.filter.composite-filter.operator" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.composite_filter.operator = value.unwrap_or("").to_string(); + 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()); }, "query.filter.property-filter.operator" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.operator = value.unwrap_or("").to_string(); + request_query_filter_property_filter_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().operator = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.property.name" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.property.name = value.unwrap_or("").to_string(); + request_query_filter_property_filter_property_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().property.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.entity-value.key.partition-id.namespace" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.entity_value.key.partition_id.namespace = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_entity_value_key_partition_id_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key.as_mut().unwrap().partition_id.as_mut().unwrap().namespace = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.entity-value.key.partition-id.dataset-id" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.entity_value.key.partition_id.dataset_id = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_entity_value_key_partition_id_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().entity_value.as_mut().unwrap().key.as_mut().unwrap().partition_id.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.double-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.double_value = arg_from_str(value.unwrap_or("0.0"), err, "query.filter.property-filter.value.double-value", "number"); + request_query_filter_property_filter_value_entity_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().double_value = Some(arg_from_str(value.unwrap_or("0.0"), err, "query.filter.property-filter.value.double-value", "number")); }, "query.filter.property-filter.value.integer-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.integer_value = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_entity_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().integer_value = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.meaning" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.meaning = arg_from_str(value.unwrap_or("-0"), err, "query.filter.property-filter.value.meaning", "integer"); + request_query_filter_property_filter_value_entity_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().meaning = Some(arg_from_str(value.unwrap_or("-0"), err, "query.filter.property-filter.value.meaning", "integer")); }, "query.filter.property-filter.value.date-time-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.date_time_value = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_entity_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().date_time_value = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.key-value.partition-id.namespace" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.key_value.partition_id.namespace = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_key_value_partition_id_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value.as_mut().unwrap().partition_id.as_mut().unwrap().namespace = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.key-value.partition-id.dataset-id" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.key_value.partition_id.dataset_id = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_key_value_partition_id_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().key_value.as_mut().unwrap().partition_id.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.string-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.string_value = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_key_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().string_value = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.indexed" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.indexed = arg_from_str(value.unwrap_or("false"), err, "query.filter.property-filter.value.indexed", "boolean"); + request_query_filter_property_filter_value_key_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().indexed = Some(arg_from_str(value.unwrap_or("false"), err, "query.filter.property-filter.value.indexed", "boolean")); }, "query.filter.property-filter.value.blob-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.blob_value = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_key_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().blob_value = Some(value.unwrap_or("").to_string()); }, "query.filter.property-filter.value.boolean-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.boolean_value = arg_from_str(value.unwrap_or("false"), err, "query.filter.property-filter.value.boolean-value", "boolean"); + request_query_filter_property_filter_value_key_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().boolean_value = Some(arg_from_str(value.unwrap_or("false"), err, "query.filter.property-filter.value.boolean-value", "boolean")); }, "query.filter.property-filter.value.blob-key-value" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().filter.property_filter.value.blob_key_value = value.unwrap_or("").to_string(); + request_query_filter_property_filter_value_key_value_init(&mut request); + request.query.as_mut().unwrap().filter.as_mut().unwrap().property_filter.as_mut().unwrap().value.as_mut().unwrap().blob_key_value = Some(value.unwrap_or("").to_string()); }, "query.start-cursor" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().start_cursor = value.unwrap_or("").to_string(); + request_query_filter_init(&mut request); + request.query.as_mut().unwrap().start_cursor = Some(value.unwrap_or("").to_string()); }, "query.end-cursor" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().end_cursor = value.unwrap_or("").to_string(); + request_query_filter_init(&mut request); + request.query.as_mut().unwrap().end_cursor = Some(value.unwrap_or("").to_string()); }, "query.limit" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().limit = arg_from_str(value.unwrap_or("-0"), err, "query.limit", "integer"); + request_query_filter_init(&mut request); + request.query.as_mut().unwrap().limit = Some(arg_from_str(value.unwrap_or("-0"), err, "query.limit", "integer")); }, "query.offset" => { - request_query_init(&mut request); - request.query.as_mut().unwrap().offset = arg_from_str(value.unwrap_or("-0"), err, "query.offset", "integer"); + request_query_filter_init(&mut request); + request.query.as_mut().unwrap().offset = Some(arg_from_str(value.unwrap_or("-0"), err, "query.offset", "integer")); }, "partition-id.namespace" => { request_partition_id_init(&mut request); - request.partition_id.as_mut().unwrap().namespace = value.unwrap_or("").to_string(); + request.partition_id.as_mut().unwrap().namespace = Some(value.unwrap_or("").to_string()); }, "partition-id.dataset-id" => { request_partition_id_init(&mut request); - request.partition_id.as_mut().unwrap().dataset_id = value.unwrap_or("").to_string(); + request.partition_id.as_mut().unwrap().dataset_id = Some(value.unwrap_or("").to_string()); }, "gql-query.query-string" => { request_gql_query_init(&mut request); - request.gql_query.as_mut().unwrap().query_string = value.unwrap_or("").to_string(); + request.gql_query.as_mut().unwrap().query_string = Some(value.unwrap_or("").to_string()); }, "gql-query.allow-literal" => { request_gql_query_init(&mut request); - request.gql_query.as_mut().unwrap().allow_literal = arg_from_str(value.unwrap_or("false"), err, "gql-query.allow-literal", "boolean"); + request.gql_query.as_mut().unwrap().allow_literal = Some(arg_from_str(value.unwrap_or("false"), err, "gql-query.allow-literal", "boolean")); }, "read-options.transaction" => { request_read_options_init(&mut request); - request.read_options.as_mut().unwrap().transaction = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -557,8 +635,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -606,21 +683,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "datastore1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "datastore1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "datastore1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "datastore1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Datastore::new(hyper::Client::new(), auth), + hub: api::Datastore::new(client, auth), }; match engine._doit(true) { @@ -640,12 +733,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 9847f38bd6..4d504658d9 100644 --- a/gen/datastore1_beta2/Cargo.toml +++ b/gen/datastore1_beta2/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-datastore1_beta2" -version = "0.1.5+20140916" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/datastore/" diff --git a/gen/datastore1_beta2/README.md b/gen/datastore1_beta2/README.md index 23c1600b69..f74806748d 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+20140916*, where *20140916* 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.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*. Everything else about the *datastore* *v1_beta2* API can be found at the [official documentation site](https://developers.google.com/datastore/). @@ -93,7 +93,7 @@ let mut hub = Datastore::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: LookupRequest = Default::default(); +let mut req = LookupRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/datastore1_beta2/src/cmn.rs b/gen/datastore1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/datastore1_beta2/src/cmn.rs +++ b/gen/datastore1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/datastore1_beta2/src/lib.rs b/gen/datastore1_beta2/src/lib.rs index 38c7430755..16fb04970c 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+20140916*, where *20140916* 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.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*. //! //! Everything else about the *datastore* *v1_beta2* API can be found at the //! [official documentation site](https://developers.google.com/datastore/). @@ -94,7 +94,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: LookupRequest = Default::default(); +//! let mut req = LookupRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -277,7 +277,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LookupRequest = Default::default(); +/// let mut req = LookupRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -349,10 +349,10 @@ impl<'a, C, A> Datastore<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PartitionId { /// The namespace. - pub namespace: String, + pub namespace: Option<String>, /// The dataset ID. #[serde(rename="datasetId")] - pub dataset_id: String, + pub dataset_id: Option<String>, } impl Part for PartitionId {} @@ -370,9 +370,9 @@ impl Part for PartitionId {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AllocateIdsResponse { /// The keys specified in the request (in the same order), each with its key path completed with a newly allocated ID. - pub keys: Vec<Key>, + pub keys: Option<Vec<Key>>, /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, } impl ResponseResult for AllocateIdsResponse {} @@ -411,9 +411,9 @@ impl RequestValue for LookupRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BeginTransactionResponse { /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, /// The transaction identifier (always present). - pub transaction: String, + pub transaction: Option<String>, } impl ResponseResult for BeginTransactionResponse {} @@ -449,9 +449,9 @@ impl RequestValue for AllocateIdsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RunQueryResponse { /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, /// A batch of query results (always present). - pub batch: QueryResultBatch, + pub batch: Option<QueryResultBatch>, } impl ResponseResult for RunQueryResponse {} @@ -464,18 +464,18 @@ impl ResponseResult for RunQueryResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct Mutation { /// Entities to insert. Each inserted entity's key must have a complete path and must not be reserved/read-only. - pub insert: Vec<Entity>, + pub insert: Option<Vec<Entity>>, /// Ignore a user specified read-only period. Optional. - pub force: bool, + pub force: Option<bool>, /// Insert entities with a newly allocated ID. Each inserted entity's key must omit the final identifier in its path and must not be reserved/read-only. #[serde(rename="insertAutoId")] - pub insert_auto_id: Vec<Entity>, + pub insert_auto_id: Option<Vec<Entity>>, /// Keys of entities to delete. Each key must have a complete key path and must not be reserved/read-only. - pub delete: Vec<Key>, + pub delete: Option<Vec<Key>>, /// Entities to update. Each updated entity's key must have a complete path and must not be reserved/read-only. - pub update: Vec<Entity>, + pub update: Option<Vec<Entity>>, /// Entities to upsert. Each upserted entity's key must have a complete path and must not be reserved/read-only. - pub upsert: Vec<Entity>, + pub upsert: Option<Vec<Entity>>, } impl Part for Mutation {} @@ -493,10 +493,10 @@ impl Part for Mutation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommitResponse { /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, /// The result of performing the mutation (if any). #[serde(rename="mutationResult")] - pub mutation_result: MutationResult, + pub mutation_result: Option<MutationResult>, } impl ResponseResult for CommitResponse {} @@ -510,19 +510,19 @@ impl ResponseResult for CommitResponse {} pub struct QueryResultBatch { /// The state of the query after the current batch. One of notFinished, moreResultsAfterLimit, noMoreResults. #[serde(rename="moreResults")] - pub more_results: String, + pub more_results: Option<String>, /// The number of results skipped because of Query.offset. #[serde(rename="skippedResults")] - pub skipped_results: i32, + pub skipped_results: Option<i32>, /// A cursor that points to the position after the last result in the batch. May be absent. TODO(arfuller): Once all plans produce cursors update documentation here. #[serde(rename="endCursor")] - pub end_cursor: String, + pub end_cursor: Option<String>, /// The results for this batch. #[serde(rename="entityResults")] - pub entity_results: Vec<EntityResult>, + pub entity_results: Option<Vec<EntityResult>>, /// The result type for every entity in entityResults. full for full entities, projection for entities with only projected properties, keyOnly for entities with only a key. #[serde(rename="entityResultType")] - pub entity_result_type: String, + pub entity_result_type: Option<String>, } impl Part for QueryResultBatch {} @@ -535,7 +535,7 @@ impl Part for QueryResultBatch {} #[derive(Default, Clone, Debug, Serialize)] pub struct PropertyReference { /// The name of the property. - pub name: String, + pub name: Option<String>, } impl Part for PropertyReference {} @@ -548,7 +548,7 @@ impl Part for PropertyReference {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EntityResult { /// The resulting entity. - pub entity: Entity, + pub entity: Option<Entity>, } impl Part for EntityResult {} @@ -566,7 +566,7 @@ impl Part for EntityResult {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RollbackResponse { /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, } impl ResponseResult for RollbackResponse {} @@ -580,16 +580,16 @@ impl ResponseResult for RollbackResponse {} pub struct GqlQuery { /// When false, the query string must not contain a literal. #[serde(rename="allowLiteral")] - pub allow_literal: bool, + pub allow_literal: Option<bool>, /// A named argument must set field GqlQueryArg.name. No two named arguments may have the same name. For each non-reserved named binding site in the query string, there must be a named argument with that name, but not necessarily the inverse. #[serde(rename="nameArgs")] - pub name_args: Vec<GqlQueryArg>, + pub name_args: Option<Vec<GqlQueryArg>>, /// The query string. #[serde(rename="queryString")] - pub query_string: String, + pub query_string: Option<String>, /// Numbered binding site @1 references the first numbered argument, effectively using 1-based indexing, rather than the usual 0. A numbered argument must NOT set field GqlQueryArg.name. For each binding site numbered i in query_string, there must be an ith numbered argument. The inverse must also be true. #[serde(rename="numberArgs")] - pub number_args: Vec<GqlQueryArg>, + pub number_args: Option<Vec<GqlQueryArg>>, } impl Part for GqlQuery {} @@ -602,10 +602,10 @@ impl Part for GqlQuery {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Key { /// The entity path. An entity path consists of one or more elements composed of a kind and a string or numerical identifier, which identify entities. The first element identifies a root entity, the second element identifies a child of the root entity, the third element a child of the second entity, and so forth. The entities identified by all prefixes of the path are called the element's ancestors. An entity path is always fully complete: ALL of the entity's ancestors are required to be in the path along with the entity identifier itself. The only exception is that in some documented cases, the identifier in the last path element (for the entity) itself may be omitted. A path can never be empty. The path can have at most 100 elements. - pub path: Vec<KeyPathElement>, + pub path: Option<Vec<KeyPathElement>>, /// Entities are partitioned into subsets, currently identified by a dataset (usually implicitly specified by the project) and namespace ID. Queries are scoped to a single partition. #[serde(rename="partitionId")] - pub partition_id: PartitionId, + pub partition_id: Option<PartitionId>, } impl Part for Key {} @@ -619,9 +619,9 @@ impl Part for Key {} pub struct PropertyExpression { /// The aggregation function to apply to the property. Optional. Can only be used when grouping by at least one property. Must then be set on all properties in the projection that are not being grouped by. Aggregation functions: first selects the first result as determined by the query's order. #[serde(rename="aggregationFunction")] - pub aggregation_function: String, + pub aggregation_function: Option<String>, /// The property to project. - pub property: PropertyReference, + pub property: Option<PropertyReference>, } impl Part for PropertyExpression {} @@ -635,10 +635,10 @@ impl Part for PropertyExpression {} pub struct MutationResult { /// Keys for insertAutoId entities. One per entity from the request, in the same order. #[serde(rename="insertAutoIdKeys")] - pub insert_auto_id_keys: Vec<Key>, + pub insert_auto_id_keys: Option<Vec<Key>>, /// Number of index writes. #[serde(rename="indexUpdates")] - pub index_updates: i32, + pub index_updates: Option<i32>, } impl Part for MutationResult {} @@ -651,10 +651,10 @@ impl Part for MutationResult {} #[derive(Default, Clone, Debug, Serialize)] pub struct ReadOptions { /// The transaction to use. Optional. - pub transaction: String, + pub transaction: Option<String>, /// The read consistency to use. One of default, strong, or eventual. Cannot be set when transaction is set. Lookup and ancestor queries default to strong, global queries default to eventual and cannot be set to strong. Optional. Default is default. #[serde(rename="readConsistency")] - pub read_consistency: String, + pub read_consistency: Option<String>, } impl Part for ReadOptions {} @@ -667,11 +667,11 @@ impl Part for ReadOptions {} #[derive(Default, Clone, Debug, Serialize)] pub struct PropertyFilter { /// The operator to filter by. One of lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, equal, or hasAncestor. - pub operator: String, + pub operator: Option<String>, /// The property to filter by. - pub property: PropertyReference, + pub property: Option<PropertyReference>, /// The value to compare the property to. - pub value: Value, + pub value: Option<Value>, } impl Part for PropertyFilter {} @@ -684,7 +684,7 @@ impl Part for PropertyFilter {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResponseHeader { /// Identifies what kind of resource this is. Value: the fixed string "datastore#responseHeader". - pub kind: String, + pub kind: Option<String>, } impl Part for ResponseHeader {} @@ -698,40 +698,40 @@ impl Part for ResponseHeader {} pub struct Value { /// An entity value. May have no key. May have a key with an incomplete key path. May have a reserved/read-only key. #[serde(rename="entityValue")] - pub entity_value: Entity, + pub entity_value: Option<Entity>, /// A double value. #[serde(rename="doubleValue")] - pub double_value: f64, + pub double_value: Option<f64>, /// A blob key value. #[serde(rename="blobKeyValue")] - pub blob_key_value: String, + pub blob_key_value: Option<String>, /// The meaning field is reserved and should not be used. - pub meaning: i32, + pub meaning: Option<i32>, /// A timestamp value. #[serde(rename="dateTimeValue")] - pub date_time_value: String, + pub date_time_value: Option<String>, /// A key value. #[serde(rename="keyValue")] - pub key_value: Key, - /// A blob value. May be a maximum of 1,000,000 bytes. + pub key_value: Option<Key>, + /// A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes. #[serde(rename="blobValue")] - pub blob_value: String, + pub blob_value: Option<String>, /// If the value should be indexed. /// /// The indexed property may be set for a null value. When indexed is true, stringValue is limited to 500 characters and the blob value is limited to 500 bytes. Input values by default have indexed set to true; however, you can explicitly set indexed to true if you want. (An output value never has indexed explicitly set to true.) If a value is itself an entity, it cannot have indexed set to true. - pub indexed: bool, - /// A UTF-8 encoded string value. + pub indexed: Option<bool>, + /// A UTF-8 encoded string value. When indexed is true, may have at most 500 characters. #[serde(rename="stringValue")] - pub string_value: String, - /// A list value. Cannot contain another list value. Cannot also have a meaning and indexing set. + pub string_value: Option<String>, + /// A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed. #[serde(rename="listValue")] - pub list_value: Vec<Value>, + pub list_value: Option<Vec<Value>>, /// A boolean value. #[serde(rename="booleanValue")] - pub boolean_value: bool, + pub boolean_value: Option<bool>, /// An integer value. #[serde(rename="integerValue")] - pub integer_value: String, + pub integer_value: Option<String>, } impl Part for Value {} @@ -745,10 +745,10 @@ impl Part for Value {} pub struct Filter { /// A composite filter. #[serde(rename="compositeFilter")] - pub composite_filter: CompositeFilter, + pub composite_filter: Option<CompositeFilter>, /// A filter on a property. #[serde(rename="propertyFilter")] - pub property_filter: PropertyFilter, + pub property_filter: Option<PropertyFilter>, } impl Part for Filter {} @@ -763,11 +763,11 @@ impl Part for Filter {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct KeyPathElement { /// The kind of the entity. A kind matching regex "__.*__" is reserved/read-only. A kind must not contain more than 500 characters. Cannot be "". - pub kind: String, + pub kind: Option<String>, /// The ID of the entity. Never equal to zero. Values less than zero are discouraged and will not be supported in the future. - pub id: String, + pub id: Option<String>, /// The name of the entity. A name matching regex "__.*__" is reserved/read-only. A name must not be more than 500 characters. Cannot be "". - pub name: String, + pub name: Option<String>, } impl Part for KeyPathElement {} @@ -781,40 +781,40 @@ impl Part for KeyPathElement {} pub struct Property { /// An entity value. May have no key. May have a key with an incomplete key path. May have a reserved/read-only key. #[serde(rename="entityValue")] - pub entity_value: Entity, + pub entity_value: Option<Entity>, /// A double value. #[serde(rename="doubleValue")] - pub double_value: f64, + pub double_value: Option<f64>, /// A blob key value. #[serde(rename="blobKeyValue")] - pub blob_key_value: String, + pub blob_key_value: Option<String>, /// The meaning field is reserved and should not be used. - pub meaning: i32, + pub meaning: Option<i32>, /// A timestamp value. #[serde(rename="dateTimeValue")] - pub date_time_value: String, + pub date_time_value: Option<String>, /// A key value. #[serde(rename="keyValue")] - pub key_value: Key, - /// A blob value. May be a maximum of 1,000,000 bytes. + pub key_value: Option<Key>, + /// A blob value. May be a maximum of 1,000,000 bytes. When indexed is true, may have at most 500 bytes. #[serde(rename="blobValue")] - pub blob_value: String, + pub blob_value: Option<String>, /// If the value should be indexed. /// /// The indexed property may be set for a null value. When indexed is true, stringValue is limited to 500 characters and the blob value is limited to 500 bytes. Input values by default have indexed set to true; however, you can explicitly set indexed to true if you want. (An output value never has indexed explicitly set to true.) If a value is itself an entity, it cannot have indexed set to true. - pub indexed: bool, - /// A UTF-8 encoded string value. + pub indexed: Option<bool>, + /// A UTF-8 encoded string value. When indexed is true, may have at most 500 characters. #[serde(rename="stringValue")] - pub string_value: String, - /// A list value. Cannot contain another list value. Cannot also have a meaning and indexing set. + pub string_value: Option<String>, + /// A list value. Cannot contain another list value. A Value instance that sets field list_value must not set field meaning or field indexed. #[serde(rename="listValue")] - pub list_value: Vec<Value>, + pub list_value: Option<Vec<Value>>, /// A boolean value. #[serde(rename="booleanValue")] - pub boolean_value: bool, + pub boolean_value: Option<bool>, /// An integer value. #[serde(rename="integerValue")] - pub integer_value: String, + pub integer_value: Option<String>, } impl Part for Property {} @@ -832,13 +832,13 @@ impl Part for Property {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LookupResponse { /// Entities found. - pub found: Vec<EntityResult>, + pub found: Option<Vec<EntityResult>>, /// no description provided - pub header: ResponseHeader, + pub header: Option<ResponseHeader>, /// A list of keys that were not looked up due to resource constraints. - pub deferred: Vec<Key>, + pub deferred: Option<Vec<Key>>, /// Entities not found, with only the key populated. - pub missing: Vec<EntityResult>, + pub missing: Option<Vec<EntityResult>>, } impl ResponseResult for LookupResponse {} @@ -851,9 +851,9 @@ impl ResponseResult for LookupResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct CompositeFilter { /// The operator for combining multiple filters. Only "and" is currently supported. - pub operator: String, + pub operator: Option<String>, /// The list of filters to combine. Must contain at least one filter. - pub filters: Vec<Filter>, + pub filters: Option<Vec<Filter>>, } impl Part for CompositeFilter {} @@ -918,7 +918,7 @@ impl RequestValue for RunQueryRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct KindExpression { /// The name of the kind. - pub name: String, + pub name: Option<String>, } impl Part for KindExpression {} @@ -931,11 +931,11 @@ impl Part for KindExpression {} #[derive(Default, Clone, Debug, Serialize)] pub struct GqlQueryArg { /// no description provided - pub cursor: String, + pub cursor: Option<String>, /// Must match regex "[A-Za-z_$][A-Za-z_$0-9]*". Must not match regex "__.*__". Must not be "". - pub name: String, + pub name: Option<String>, /// no description provided - pub value: Value, + pub value: Option<Value>, } impl Part for GqlQueryArg {} @@ -948,11 +948,11 @@ impl Part for GqlQueryArg {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Entity { /// The entity's properties. - pub properties: HashMap<String, Property>, + pub properties: Option<HashMap<String, Property>>, /// The entity's key. /// /// An entity must have a key, unless otherwise documented (for example, an entity in Value.entityValue may have no key). An entity's kind is its key's path's last element's kind, or null if it has no key. - pub key: Key, + pub key: Option<Key>, } impl Part for Entity {} @@ -1002,9 +1002,9 @@ impl RequestValue for BeginTransactionRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct PropertyOrder { /// The direction to order by. One of ascending or descending. Optional, defaults to ascending. - pub direction: String, + pub direction: Option<String>, /// The property to order by. - pub property: PropertyReference, + pub property: Option<PropertyReference>, } impl Part for PropertyOrder {} @@ -1018,25 +1018,25 @@ impl Part for PropertyOrder {} pub struct Query { /// A starting point for the query results. Optional. Query cursors are returned in query result batches. #[serde(rename="startCursor")] - pub start_cursor: String, + pub start_cursor: Option<String>, /// The kinds to query (if empty, returns entities from all kinds). - pub kinds: Vec<KindExpression>, + pub kinds: Option<Vec<KindExpression>>, /// The projection to return. If not set the entire entity is returned. - pub projection: Vec<PropertyExpression>, + pub projection: Option<Vec<PropertyExpression>>, /// The properties to group by (if empty, no grouping is applied to the result set). #[serde(rename="groupBy")] - pub group_by: Vec<PropertyReference>, + pub group_by: Option<Vec<PropertyReference>>, /// The filter to apply (optional). - pub filter: Filter, + pub filter: Option<Filter>, /// The maximum number of results to return. Applies after all other constraints. Optional. - pub limit: i32, + pub limit: Option<i32>, /// The number of results to skip. Applies before limit, but after all other constraints (optional, defaults to 0). - pub offset: i32, + pub offset: Option<i32>, /// An ending point for the query results. Optional. Query cursors are returned in query result batches. #[serde(rename="endCursor")] - pub end_cursor: String, + pub end_cursor: Option<String>, /// The order to apply to the query results (if empty, order is unspecified). - pub order: Vec<PropertyOrder>, + pub order: Option<Vec<PropertyOrder>>, } impl Part for Query {} @@ -1235,7 +1235,7 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CommitRequest = Default::default(); +/// let mut req = CommitRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1327,16 +1327,20 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1489,7 +1493,7 @@ impl<'a, C, A> DatasetCommitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AllocateIdsRequest = Default::default(); +/// let mut req = AllocateIdsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1581,16 +1585,20 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1743,7 +1751,7 @@ impl<'a, C, A> DatasetAllocateIdCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RollbackRequest = Default::default(); +/// let mut req = RollbackRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1835,16 +1843,20 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1997,7 +2009,7 @@ impl<'a, C, A> DatasetRollbackCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LookupRequest = Default::default(); +/// let mut req = LookupRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2089,16 +2101,20 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2251,7 +2267,7 @@ impl<'a, C, A> DatasetLookupCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RunQueryRequest = Default::default(); +/// let mut req = RunQueryRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2343,16 +2359,20 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2505,7 +2525,7 @@ impl<'a, C, A> DatasetRunQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BeginTransactionRequest = Default::default(); +/// let mut req = BeginTransactionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2597,16 +2617,20 @@ impl<'a, C, A> DatasetBeginTransactionCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/deploymentmanager2_beta1-cli/Cargo.toml b/gen/deploymentmanager2_beta1-cli/Cargo.toml index 8d20889b58..38188b30ec 100644 --- a/gen/deploymentmanager2_beta1-cli/Cargo.toml +++ b/gen/deploymentmanager2_beta1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-deploymentmanager2_beta1-cli" -version = "0.0.1+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/deployment-manager/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/deploymentmanager2_beta1-cli/mkdocs.yml b/gen/deploymentmanager2_beta1-cli/mkdocs.yml index 24e434880c..fcba2e0cf5 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+20150303 +site_name: deploymentmanager v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/deploymentmanager2_beta1-cli/src/cmn.rs +++ b/gen/deploymentmanager2_beta1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/deploymentmanager2_beta1-cli/src/main.rs b/gen/deploymentmanager2_beta1-cli/src/main.rs index 5d459ac706..ac2cce7dd5 100644 --- a/gen/deploymentmanager2_beta1-cli/src/main.rs +++ b/gen/deploymentmanager2_beta1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -42,6 +43,12 @@ Configuration: 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. "); mod cmn; @@ -65,7 +72,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().delete(&self.opt.arg_project, &self.opt.arg_deployment); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -97,8 +104,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -109,7 +115,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().get(&self.opt.arg_project, &self.opt.arg_deployment); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -141,8 +147,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -151,10 +156,10 @@ impl Engine { fn _deployments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Deployment = Default::default(); + let mut request = api::Deployment::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -174,9 +179,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -213,8 +219,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -225,7 +230,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -263,8 +268,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -275,7 +279,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.manifests().get(&self.opt.arg_project, &self.opt.arg_deployment, &self.opt.arg_manifest); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -307,8 +311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -319,7 +322,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.manifests().list(&self.opt.arg_project, &self.opt.arg_deployment); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -357,8 +360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -369,7 +371,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operations().get(&self.opt.arg_project, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -401,8 +403,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -413,7 +414,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operations().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -451,8 +452,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -463,7 +463,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.resources().get(&self.opt.arg_project, &self.opt.arg_deployment, &self.opt.arg_resource); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -495,8 +495,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -507,7 +506,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.resources().list(&self.opt.arg_project, &self.opt.arg_deployment); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -545,8 +544,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -557,7 +555,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.types().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -595,8 +593,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -620,7 +617,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_manifests { + } + else if self.opt.cmd_manifests { if self.opt.cmd_get { call_result = self._manifests_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -628,7 +626,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_operations { + } + else if self.opt.cmd_operations { if self.opt.cmd_get { call_result = self._operations_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -636,7 +635,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_resources { + } + else if self.opt.cmd_resources { if self.opt.cmd_get { call_result = self._resources_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -644,7 +644,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_types { + } + else if self.opt.cmd_types { if self.opt.cmd_list { call_result = self._types_list(dry_run, &mut err); } else { @@ -670,21 +671,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "deploymentmanager2-beta1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "deploymentmanager2-beta1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "deploymentmanager2-beta1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "deploymentmanager2-beta1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Deploymentmanager::new(hyper::Client::new(), auth), + hub: api::Deploymentmanager::new(client, auth), }; match engine._doit(true) { @@ -704,12 +721,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 cd1d60cf71..3c996be156 100644 --- a/gen/deploymentmanager2_beta1/Cargo.toml +++ b/gen/deploymentmanager2_beta1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-deploymentmanager2_beta1" -version = "0.1.5+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/deployment-manager/" diff --git a/gen/deploymentmanager2_beta1/README.md b/gen/deploymentmanager2_beta1/README.md index 16be92ac30..f3b602c934 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+20150303*, where *20150303* 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.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*. Everything else about the *deploymentmanager* *v2_beta1* API can be found at the [official documentation site](https://developers.google.com/deployment-manager/). diff --git a/gen/deploymentmanager2_beta1/src/cmn.rs b/gen/deploymentmanager2_beta1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/deploymentmanager2_beta1/src/cmn.rs +++ b/gen/deploymentmanager2_beta1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/deploymentmanager2_beta1/src/lib.rs b/gen/deploymentmanager2_beta1/src/lib.rs index 94ef2cc86b..c7f1924f2e 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+20150303*, where *20150303* 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.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*. //! //! Everything else about the *deploymentmanager* *v2_beta1* API can be found at the //! [official documentation site](https://developers.google.com/deployment-manager/). @@ -368,22 +368,22 @@ impl<'a, C, A> Deploymentmanager<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResourceType { /// ! [Output Only] A list of any errors that occurred during deployment. - pub errors: Vec<String>, + pub errors: Option<Vec<String>>, /// ! [Output Only] The name of the resource as it appears in the YAML config. - pub name: String, + pub name: Option<String>, /// ! [Output Only] The URL of the actual resource. - pub url: String, + pub url: Option<String>, /// ! [Output Only] URL of the manifest representing the current configuration ! of this resource. - pub manifest: String, + pub manifest: Option<String>, /// ! [Output Only] The state of the resource. - pub state: String, + pub state: Option<String>, /// ! [Output Only] The intended state of the resource. - pub intent: String, + pub intent: Option<String>, /// ! [Output Only] The type of the resource, for example ! ?compute.v1.instance?, or ?replicaPools.v1beta2.instanceGroupManager? #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option<String>, } impl Resource for ResourceType {} @@ -397,9 +397,9 @@ impl ResponseResult for ResourceType {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// ! A key for the warning data. - pub key: String, + pub key: Option<String>, /// ! A warning data value corresponding to the key. - pub value: String, + pub value: Option<String>, } impl NestedType for OperationWarningsData {} @@ -413,11 +413,11 @@ impl Part for OperationWarningsData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// ! Optional human-readable details for this warning. - pub message: String, + pub message: Option<String>, /// ! The warning type identifier for this warning. - pub code: String, + pub code: Option<String>, /// ! Metadata for this warning in 'key: value' format. - pub data: Vec<OperationWarningsData>, + pub data: Option<Vec<OperationWarningsData>>, } impl NestedType for OperationWarnings {} @@ -437,9 +437,9 @@ impl Part for OperationWarnings {} pub struct ResourcesListResponse { /// ! A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// ! Resources contained in this list response. - pub resources: Vec<ResourceType>, + pub resources: Option<Vec<ResourceType>>, } impl ResponseResult for ResourcesListResponse {} @@ -452,11 +452,11 @@ impl ResponseResult for ResourcesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// ! An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// ! The error type identifier for this error. - pub code: String, + pub code: Option<String>, /// ! Indicates the field in the request which caused the error. ! This property is optional. - pub location: String, + pub location: Option<String>, } impl NestedType for OperationErrorErrors {} @@ -477,16 +477,16 @@ impl Part for OperationErrorErrors {} pub struct Manifest { /// ! [Output Only] The fully-expanded configuration file, including any ! templates and references. #[serde(rename="evaluatedConfig")] - pub evaluated_config: String, + pub evaluated_config: Option<String>, /// v2beta1: YAML with config - described above v2beta2: YAML + templates. ! The YAML configuration for this manifest. - pub config: String, + pub config: Option<String>, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option<String>, /// [Output Only] Self link for the manifest. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// ! [Output Only] The name of the manifest. - pub name: String, + pub name: Option<String>, } impl Resource for Manifest {} @@ -500,7 +500,7 @@ impl ResponseResult for Manifest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// ! The array of errors encountered while processing this operation. - pub errors: Vec<OperationErrorErrors>, + pub errors: Option<Vec<OperationErrorErrors>>, } impl NestedType for OperationError {} @@ -519,7 +519,7 @@ impl Part for OperationError {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TypesListResponse { /// ! Types supported by Deployment Manager - pub types: Vec<Type>, + pub types: Option<Vec<Type>>, } impl ResponseResult for TypesListResponse {} @@ -538,9 +538,9 @@ impl ResponseResult for TypesListResponse {} pub struct DeploymentsListResponse { /// ! A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// ! The deployments contained in this response. - pub deployments: Vec<Deployment>, + pub deployments: Option<Vec<Deployment>>, } impl ResponseResult for DeploymentsListResponse {} @@ -591,9 +591,9 @@ impl ResponseResult for Deployment {} pub struct OperationsListResponse { /// ! A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// ! Operations contained in this list response. - pub operations: Vec<Operation>, + pub operations: Option<Vec<Operation>>, } impl ResponseResult for OperationsListResponse {} @@ -614,52 +614,52 @@ impl ResponseResult for OperationsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// ! [Output Only] Status of the operation. Can be one of the following: ! "PENDING", "RUNNING", or "DONE". - pub status: String, + pub status: Option<String>, /// ! [Output Only] The time that this operation was requested. ! This is in RFC 3339 format. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option<String>, /// ! [Output Only] If warning messages generated during processing of this ! operation, this field will be populated. - pub warnings: Vec<OperationWarnings>, + pub warnings: Option<Vec<OperationWarnings>>, /// ! [Output Only] If operation fails, the HTTP error message returned, ! e.g. NOT FOUND. #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option<String>, /// ! [Output Only] Unique target id which identifies a particular ! incarnation of the target. #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option<String>, /// ! [Output Only] URL of the resource the operation is mutating. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option<String>, /// ! [Output Only] The time that this operation was started by the server. ! This is in RFC 3339 format. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// ! [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option<String>, /// ! [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option<String>, /// ! [Output Only] Name of the operation. - pub name: String, + pub name: Option<String>, /// [Output Only] Self link for the manifest. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// ! [Output Only] Type of the operation. Examples include "insert", or ! "delete" #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option<String>, /// ! [Output Only] If errors occurred during processing of this operation, ! this field will be populated. - pub error: OperationError, + pub error: Option<OperationError>, /// ! [Output Only] An optional progress indicator that ranges from 0 to 100. ! There is no requirement that this be linear or support any granularity ! of operations. This should not be used to guess at when the operation will ! be complete. This number should be monotonically increasing as the ! operation progresses. - pub progress: i32, + pub progress: Option<i32>, /// ! [Output Only] The time that this operation was completed. This is in ! RFC3339 format. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// ! [Output Only] If operation fails, the HTTP error status code returned, ! e.g. 404. #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option<i32>, /// ! [Output Only] An optional textual description of the current status of ! the operation. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option<String>, /// ! [Output Only] User who requested the operation, for example ! "user@example.com" - pub user: String, + pub user: Option<String>, } impl Resource for Operation {} @@ -697,9 +697,9 @@ impl Resource for Type {} pub struct ManifestsListResponse { /// ! A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// ! Manifests contained in this list response. - pub manifests: Vec<Manifest>, + pub manifests: Option<Vec<Manifest>>, } impl ResponseResult for ManifestsListResponse {} @@ -1248,16 +1248,20 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1498,16 +1502,20 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1661,7 +1669,7 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Deployment = Default::default(); +/// let mut req = Deployment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1753,16 +1761,20 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1998,16 +2010,20 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2248,16 +2264,20 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2494,16 +2514,20 @@ impl<'a, C, A> DeploymentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2744,16 +2768,20 @@ impl<'a, C, A> TypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2992,16 +3020,20 @@ impl<'a, C, A> ResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3254,16 +3286,20 @@ impl<'a, C, A> ResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3520,16 +3556,20 @@ impl<'a, C, A> ManifestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3778,16 +3818,20 @@ impl<'a, C, A> ManifestGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/dfareporting2-cli/LICENSE.md b/gen/dfareporting2-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dfareporting2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dfareporting2-cli/README.md b/gen/dfareporting2-cli/README.md deleted file mode 100644 index a6943b5bb1..0000000000 --- a/gen/dfareporting2-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO DFAREPORTING:V2.0 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/dfareporting2-cli/src/cmn.rs b/gen/dfareporting2-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/dfareporting2-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/dfareporting2/LICENSE.md b/gen/dfareporting2/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dfareporting2/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dfareporting2/README.md b/gen/dfareporting2/README.md deleted file mode 100644 index 2b67c746ec..0000000000 --- a/gen/dfareporting2/README.md +++ /dev/null @@ -1,289 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/api/README.md.mako' -DO NOT EDIT ! ---> -The `google-dfareporting2` 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.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. - -Everything else about the *dfareporting* *v2* API can be found at the -[official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). -# Features - -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Dfareporting.html) ... - -* [account active ad summaries](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountActiveAdSummary.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountActiveAdSummaryGetCall.html) -* [account permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermissionGroup.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermissionGroupListCall.html) -* [account permissions](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermission.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPermissionListCall.html) -* [account user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUserProfile.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUserProfileGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUserProfileListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUserProfilePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUserProfileUpdateCall.html) -* [accounts](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Account.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AccountUpdateCall.html) -* [ads](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Ad.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdUpdateCall.html) -* [advertiser groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroup.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGroupUpdateCall.html) -* [advertisers](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Advertiser.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.AdvertiserUpdateCall.html) -* [browsers](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Browser.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.BrowserListCall.html) -* [campaign creative associations](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignCreativeAssociation.html) - * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignCreativeAssociationInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignCreativeAssociationListCall.html) -* [campaigns](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Campaign.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CampaignUpdateCall.html) -* [change logs](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ChangeLog.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ChangeLogGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ChangeLogListCall.html) -* [cities](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.City.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CityListCall.html) -* [connection types](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ConnectionType.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ConnectionTypeListCall.html) -* [content categories](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategory.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ContentCategoryUpdateCall.html) -* [countries](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Country.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CountryGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CountryListCall.html) -* [creative assets](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeAsset.html) - * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeAssetInsertCall.html) -* [creative field values](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValue.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValueDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValueGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValueInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValueListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValuePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldValueUpdateCall.html) -* [creative fields](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeField.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeFieldUpdateCall.html) -* [creative groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroup.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGroupUpdateCall.html) -* [creatives](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Creative.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeUpdateCall.html) -* [dimension values](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DimensionValue.html) - * [*query*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DimensionValueQueryCall.html) -* [directory site contacts](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySiteContact.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySiteContactGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySiteContactListCall.html) -* [directory sites](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySite.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySiteGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.DirectorySiteListCall.html) -* [event tags](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTag.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.EventTagUpdateCall.html) -* [files](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.File.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FileListCall.html) -* [floodlight activities](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivity.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityDeleteCall.html), [*generatetag*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityUpdateCall.html) -* [floodlight activity groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroup.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightActivityGroupUpdateCall.html) -* [floodlight configurations](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightConfiguration.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightConfigurationGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightConfigurationListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightConfigurationPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FloodlightConfigurationUpdateCall.html) -* [landing pages](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPage.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPageDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPageGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPageInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPageListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPagePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.LandingPageUpdateCall.html) -* [metros](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Metro.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.MetroListCall.html) -* [mobile carriers](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.MobileCarrier.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.MobileCarrierListCall.html) -* [operating system versions](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.OperatingSystemVersion.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.OperatingSystemVersionListCall.html) -* [operating systems](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.OperatingSystem.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.OperatingSystemListCall.html) -* [placement groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroup.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGroupUpdateCall.html) -* [placement strategies](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategy.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementStrategyUpdateCall.html) -* [placements](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Placement.html) - * [*generatetags*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlacementUpdateCall.html) -* [platform types](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlatformType.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PlatformTypeListCall.html) -* [postal codes](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PostalCode.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.PostalCodeListCall.html) -* [regions](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Region.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.RegionListCall.html) -* [reports](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Report.html) - * [*compatible fields query*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportCompatibleFieldQueryCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportDeleteCall.html), [*files get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportFileGetCall.html), [*files list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportFileListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportPatchCall.html), [*run*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportRunCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportUpdateCall.html) -* [sites](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Site.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SiteInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SiteListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SitePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SiteUpdateCall.html) -* [sizes](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Size.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SizeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SizeInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SizeListCall.html) -* [subaccounts](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Subaccount.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SubaccountGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SubaccountInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SubaccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SubaccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.SubaccountUpdateCall.html) -* [user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserProfile.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserProfileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserProfileListCall.html) -* [user role permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermissionGroup.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermissionGroupListCall.html) -* [user role permissions](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermission.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePermissionListCall.html) -* [user roles](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRole.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRoleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRoleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRoleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRoleListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRolePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.UserRoleUpdateCall.html) - - -Upload supported by ... - -* [*insert creative assets*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.CreativeAssetInsertCall.html) - -Download supported by ... - -* [*get files*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.FileGetCall.html) -* [*files get reports*](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.ReportFileGetCall.html) - - - -# Structure of this Library - -The API is structured into the following primary items: - -* **[Hub](http://byron.github.io/google-apis-rs/google_dfareporting2/struct.Dfareporting.html)** - * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Resource.html)** - * primary types that you can apply *Activities* to - * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Part.html)** - * a collection of properties - * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.CallBuilder.html)** - * operations to apply to *Resources* - -All *structures* are marked with applicable traits to further categorize them and ease browsing. - -Generally speaking, you can invoke *Activities* like this: - -```Rust,ignore -let r = hub.resource().activity(...).doit() -``` - -Or specifically ... - -```ignore -let r = hub.reports().run(...).doit() -let r = hub.reports().get(...).doit() -let r = hub.reports().list(...).doit() -let r = hub.reports().delete(...).doit() -let r = hub.reports().files_list(...).doit() -let r = hub.reports().insert(...).doit() -let r = hub.reports().patch(...).doit() -let r = hub.reports().compatible_fields_query(...).doit() -let r = hub.reports().update(...).doit() -let r = hub.reports().files_get(...).doit() -``` - -The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` -supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be -specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. -The `doit()` method performs the actual communication with the server and returns the respective result. - -# Usage - -## Setting up your Project - -To use this library, you would put the following lines into your `Cargo.toml` file: - -```toml -[dependencies] -google-dfareporting2 = "*" -``` - -## A complete example - -```Rust -extern crate hyper; -extern crate yup_oauth2 as oauth2; -extern crate google_dfareporting2 as dfareporting2; -use dfareporting2::{Result, Error}; -use std::default::Default; -use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use dfareporting2::Dfareporting; - -// Get an ApplicationSecret instance by some means. It contains the `client_id` and -// `client_secret`, among other things. -let secret: ApplicationSecret = Default::default(); -// Instantiate the authenticator. It will choose a suitable authentication flow for you, -// unless you replace `None` with the desired Flow. -// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about -// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and -// retrieve them from storage. -let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - <MemoryStorage as Default>::default(), None); -let mut hub = Dfareporting::new(hyper::Client::new(), auth); -// You can configure optional parameters by calling 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().list("profileId") - .sort_order("sit") - .sort_field("Stet") - .scope("sed") - .page_token("et") - .max_results(-18) - .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::MissingAPIKey - |Error::MissingToken - |Error::Cancelled - |Error::UploadSizeLimitExceeded(_, _) - |Error::Failure(_) - |Error::FieldClash(_) - |Error::JsonDecodeError(_) => println!("{}", e), - }, - Ok(res) => println!("Success: {:?}", res), -} - -``` -## Handling Errors - -All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_dfareporting2/enum.Result.html) enumeration as return value of -the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2/../yup-oauth2/trait.AuthenticatorDelegate.html). - -When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This -makes the system potentially resilient to all kinds of errors. - -## Uploads and Downloads -If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google_dfareporting2/enum.Result.html), should be -read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.ResponseResult.html), it will return that by default. -You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making -this call: `.param("alt", "media")`. - -Methods supporting uploads can do so using up to 2 different protocols: -*simple* and *resumable*. The distinctiveness of each is represented by customized -`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. - -## Customization and Callbacks - -You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.CallBuilder.html) before making the final `doit()` call. -Respective methods will be called to provide progress information, as well as determine whether the system should -retry on failure. - -The [delegate trait](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. - -## Optional Parts in Server-Requests - -All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses -are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.Part.html) which are identifiable by name, which will be sent to -the server to indicate either the set parts of the request or the desired parts in the response. - -## Builder Arguments - -Using [method builders](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. -These will always take a single argument, for which the following statements are true. - -* [PODs][wiki-pod] are handed by copy -* strings are passed as `&str` -* [request values](http://byron.github.io/google-apis-rs/google_dfareporting2/trait.RequestValue.html) are borrowed - -Arguments will always be copied or cloned into the builder, to make them independent of their original life times. - -[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure -[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern -[google-go-api]: https://github.com/google/google-api-go-client - -# License -The **dfareporting2** library was generated by Sebastian Thiel, and is placed -under the *MIT* license. -You can read the full text at the repository's [license file][repo-license]. - -[repo-license]: https://github.com/Byron/google-apis-rs/LICENSE.md diff --git a/gen/dfareporting2-cli/Cargo.toml b/gen/dfareporting2d1-cli/Cargo.toml similarity index 70% rename from gen/dfareporting2-cli/Cargo.toml rename to gen/dfareporting2d1-cli/Cargo.toml index 55f88992fc..420131fe9b 100644 --- a/gen/dfareporting2-cli/Cargo.toml +++ b/gen/dfareporting2d1-cli/Cargo.toml @@ -3,18 +3,18 @@ # DO NOT EDIT ! [package] -name = "google-dfareporting2-cli" +name = "google-dfareporting2d1-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dfareporting (protocol v2.0)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2-cli" +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" homepage = "https://developers.google.com/doubleclick-advertisers/reporting/" -documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2_cli" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d1_cli" license = "MIT" keywords = ["dfareporting", "google", "cli"] [[bin]] -name = "dfareporting2" +name = "dfareporting2d1" [dependencies] hyper = "*" @@ -23,8 +23,9 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" -[dependencies.google-dfareporting2] -path = "../dfareporting2" +[dependencies.google-dfareporting2d1] +path = "../dfareporting2d1" diff --git a/gen/admin1_directory-cli/LICENSE.md b/gen/dfareporting2d1-cli/LICENSE.md similarity index 100% rename from gen/admin1_directory-cli/LICENSE.md rename to gen/dfareporting2d1-cli/LICENSE.md diff --git a/gen/admin1_reports-cli/README.md b/gen/dfareporting2d1-cli/README.md similarity index 52% rename from gen/admin1_reports-cli/README.md rename to gen/dfareporting2d1-cli/README.md index d63739eb1c..85b7056f4c 100644 --- a/gen/admin1_reports-cli/README.md +++ b/gen/dfareporting2d1-cli/README.md @@ -1,4 +1,4 @@ -# HELLO ADMIN:REPORTS_V1 +# HELLO DFAREPORTING:V2.1 Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/dfareporting2-cli/mkdocs.yml b/gen/dfareporting2d1-cli/mkdocs.yml similarity index 86% rename from gen/dfareporting2-cli/mkdocs.yml rename to gen/dfareporting2d1-cli/mkdocs.yml index e8bc7d932c..db9b47504d 100644 --- a/gen/dfareporting2-cli/mkdocs.yml +++ b/gen/dfareporting2d1-cli/mkdocs.yml @@ -1,8 +1,8 @@ site_name: dfareporting v0.0.1+20150326 -site_url: http://byron.github.io/google-apis-rs/google-dfareporting2-cli +site_url: http://byron.github.io/google-apis-rs/google-dfareporting2d1-cli site_description: Write integrating applications with bcore -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2-cli +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1-cli docs_dir: docs site_dir: build_html @@ -15,6 +15,7 @@ pages: - ['account-permissions_get.md', 'Account Permissions', 'Get'] - ['account-permissions_list.md', 'Account Permissions', 'List'] - ['account-user-profiles_get.md', 'Account User Profiles', 'Get'] +- ['account-user-profiles_insert.md', 'Account User Profiles', 'Insert'] - ['account-user-profiles_list.md', 'Account User Profiles', 'List'] - ['account-user-profiles_patch.md', 'Account User Profiles', 'Patch'] - ['account-user-profiles_update.md', 'Account User Profiles', 'Update'] @@ -49,6 +50,7 @@ pages: - ['change-logs_get.md', 'Change Logs', 'Get'] - ['change-logs_list.md', 'Change Logs', 'List'] - ['cities_list.md', 'Cities', 'List'] +- ['connection-types_get.md', 'Connection Types', 'Get'] - ['connection-types_list.md', 'Connection Types', 'List'] - ['content-categories_delete.md', 'Content Categories', 'Delete'] - ['content-categories_get.md', 'Content Categories', 'Get'] @@ -85,6 +87,7 @@ pages: - ['directory-site-contacts_get.md', 'Directory Site Contacts', 'Get'] - ['directory-site-contacts_list.md', 'Directory Site Contacts', 'List'] - ['directory-sites_get.md', 'Directory Sites', 'Get'] +- ['directory-sites_insert.md', 'Directory Sites', 'Insert'] - ['directory-sites_list.md', 'Directory Sites', 'List'] - ['event-tags_delete.md', 'Event Tags', 'Delete'] - ['event-tags_get.md', 'Event Tags', 'Get'] @@ -111,6 +114,8 @@ pages: - ['floodlight-configurations_list.md', 'Floodlight Configurations', 'List'] - ['floodlight-configurations_patch.md', 'Floodlight Configurations', 'Patch'] - ['floodlight-configurations_update.md', 'Floodlight Configurations', 'Update'] +- ['inventory-items_get.md', 'Inventory Items', 'Get'] +- ['inventory-items_list.md', 'Inventory Items', 'List'] - ['landing-pages_delete.md', 'Landing Pages', 'Delete'] - ['landing-pages_get.md', 'Landing Pages', 'Get'] - ['landing-pages_insert.md', 'Landing Pages', 'Insert'] @@ -118,9 +123,16 @@ pages: - ['landing-pages_patch.md', 'Landing Pages', 'Patch'] - ['landing-pages_update.md', 'Landing Pages', 'Update'] - ['metros_list.md', 'Metros', 'List'] +- ['mobile-carriers_get.md', 'Mobile Carriers', 'Get'] - ['mobile-carriers_list.md', 'Mobile Carriers', 'List'] +- ['operating-system-versions_get.md', 'Operating System Versions', 'Get'] - ['operating-system-versions_list.md', 'Operating System Versions', 'List'] +- ['operating-systems_get.md', 'Operating Systems', 'Get'] - ['operating-systems_list.md', 'Operating Systems', 'List'] +- ['order-documents_get.md', 'Order Documents', 'Get'] +- ['order-documents_list.md', 'Order Documents', 'List'] +- ['orders_get.md', 'Orders', 'Get'] +- ['orders_list.md', 'Orders', 'List'] - ['placement-groups_get.md', 'Placement Groups', 'Get'] - ['placement-groups_insert.md', 'Placement Groups', 'Insert'] - ['placement-groups_list.md', 'Placement Groups', 'List'] @@ -138,9 +150,21 @@ pages: - ['placements_list.md', 'Placements', 'List'] - ['placements_patch.md', 'Placements', 'Patch'] - ['placements_update.md', 'Placements', 'Update'] +- ['platform-types_get.md', 'Platform Types', 'Get'] - ['platform-types_list.md', 'Platform Types', 'List'] +- ['postal-codes_get.md', 'Postal Codes', 'Get'] - ['postal-codes_list.md', 'Postal Codes', 'List'] +- ['projects_get.md', 'Projects', 'Get'] +- ['projects_list.md', 'Projects', 'List'] - ['regions_list.md', 'Regions', 'List'] +- ['remarketing-list-shares_get.md', 'Remarketing List Shares', 'Get'] +- ['remarketing-list-shares_patch.md', 'Remarketing List Shares', 'Patch'] +- ['remarketing-list-shares_update.md', 'Remarketing List Shares', 'Update'] +- ['remarketing-lists_get.md', 'Remarketing Lists', 'Get'] +- ['remarketing-lists_insert.md', 'Remarketing Lists', 'Insert'] +- ['remarketing-lists_list.md', 'Remarketing Lists', 'List'] +- ['remarketing-lists_patch.md', 'Remarketing Lists', 'Patch'] +- ['remarketing-lists_update.md', 'Remarketing Lists', 'Update'] - ['reports_compatible-fields-query.md', 'Reports', 'Compatible Fields Query'] - ['reports_delete.md', 'Reports', 'Delete'] - ['reports_files-get.md', 'Reports', 'Files Get'] @@ -164,6 +188,8 @@ pages: - ['subaccounts_list.md', 'Subaccounts', 'List'] - ['subaccounts_patch.md', 'Subaccounts', 'Patch'] - ['subaccounts_update.md', 'Subaccounts', 'Update'] +- ['targetable-remarketing-lists_get.md', 'Targetable Remarketing Lists', 'Get'] +- ['targetable-remarketing-lists_list.md', 'Targetable Remarketing Lists', 'List'] - ['user-profiles_get.md', 'User Profiles', 'Get'] - ['user-profiles_list.md', 'User Profiles', 'List'] - ['user-role-permission-groups_get.md', 'User Role Permission Groups', 'Get'] diff --git a/gen/admin1_reports-cli/src/cmn.rs b/gen/dfareporting2d1-cli/src/cmn.rs similarity index 84% rename from gen/admin1_reports-cli/src/cmn.rs rename to gen/dfareporting2d1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/admin1_reports-cli/src/cmn.rs +++ b/gen/dfareporting2d1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/dfareporting2-cli/src/main.rs b/gen/dfareporting2d1-cli/src/main.rs similarity index 75% rename from gen/dfareporting2-cli/src/main.rs rename to gen/dfareporting2d1-cli/src/main.rs index f8c9e621e3..00fdcb7e54 100644 --- a/gen/dfareporting2-cli/src/main.rs +++ b/gen/dfareporting2d1-cli/src/main.rs @@ -7,185 +7,212 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; extern crate mime; -extern crate google_dfareporting2 as api; +extern crate google_dfareporting2d1 as api; use std::env; use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - dfareporting2 [options] account-active-ad-summaries get <profile-id> <summary-account-id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-permission-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-permission-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-permissions get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-permissions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-user-profiles get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-user-profiles list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] account-user-profiles patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] account-user-profiles update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] accounts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] accounts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] accounts patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] accounts update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] ads get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] ads insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] ads list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] ads patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] ads update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertiser-groups delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] advertiser-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] advertiser-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertiser-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] advertiser-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertiser-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertisers get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] advertisers insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertisers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] advertisers patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] advertisers update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] browsers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] campaign-creative-associations insert <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] campaign-creative-associations list <profile-id> <campaign-id> [-p <v>]... [-o <out>] - dfareporting2 [options] campaigns get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] campaigns insert <profile-id> <default-landing-page-name> <default-landing-page-url> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] campaigns list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] campaigns patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] campaigns update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] change-logs get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] change-logs list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] cities list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] connection-types list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] content-categories delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] content-categories get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] content-categories insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] content-categories list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] content-categories patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] content-categories update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] countries get <profile-id> <dart-id> [-p <v>]... [-o <out>] - dfareporting2 [options] countries list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-assets insert <profile-id> <advertiser-id> -r <kv>... -u (simple|resumable) <file> <mime> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-field-values delete <profile-id> <creative-field-id> <id> [-p <v>]... - dfareporting2 [options] creative-field-values get <profile-id> <creative-field-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-field-values insert <profile-id> <creative-field-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-field-values list <profile-id> <creative-field-id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-field-values patch <profile-id> <creative-field-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-field-values update <profile-id> <creative-field-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-fields delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] creative-fields get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-fields insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-fields list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-fields patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-fields update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] creative-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creative-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creatives get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] creatives insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creatives list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] creatives patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] creatives update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] dimension-values query <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] directory-site-contacts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] directory-site-contacts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] directory-sites get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] directory-sites list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] event-tags delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] event-tags get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] event-tags insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] event-tags list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] event-tags patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] event-tags update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] files get <report-id> <file-id> [-p <v>]... [-o <out>] - dfareporting2 [options] files list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] floodlight-activities generatetag <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activities update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activity-groups delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] floodlight-activity-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activity-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activity-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activity-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-activity-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-configurations get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-configurations list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-configurations patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] floodlight-configurations update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] landing-pages delete <profile-id> <campaign-id> <id> [-p <v>]... - dfareporting2 [options] landing-pages get <profile-id> <campaign-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] landing-pages insert <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] landing-pages list <profile-id> <campaign-id> [-p <v>]... [-o <out>] - dfareporting2 [options] landing-pages patch <profile-id> <campaign-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] landing-pages update <profile-id> <campaign-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] metros list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] mobile-carriers list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] operating-system-versions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] operating-systems list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] placement-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] placement-groups insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placement-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] placement-groups patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placement-groups update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placement-strategies delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] placement-strategies get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] placement-strategies insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placement-strategies list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] placement-strategies patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placement-strategies update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placements generatetags <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] placements get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] placements insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placements list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] placements patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] placements update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] platform-types list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] postal-codes list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] regions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports compatible-fields-query <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] reports delete <profile-id> <report-id> [-p <v>]... - dfareporting2 [options] reports files-get <profile-id> <report-id> <file-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports files-list <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports get <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] reports list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports patch <profile-id> <report-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] reports run <profile-id> <report-id> [-p <v>]... [-o <out>] - dfareporting2 [options] reports update <profile-id> <report-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] sites get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] sites insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] sites list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] sites patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] sites update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] sizes get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] sizes insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] sizes list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] subaccounts get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] subaccounts insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] subaccounts list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] subaccounts patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] subaccounts update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] user-profiles get <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-profiles list [-p <v>]... [-o <out>] - dfareporting2 [options] user-role-permission-groups get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-role-permission-groups list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-role-permissions get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-role-permissions list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-roles delete <profile-id> <id> [-p <v>]... - dfareporting2 [options] user-roles get <profile-id> <id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-roles insert <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] user-roles list <profile-id> [-p <v>]... [-o <out>] - dfareporting2 [options] user-roles patch <profile-id> <id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 [options] user-roles update <profile-id> -r <kv>... [-p <v>]... [-o <out>] - dfareporting2 --help + 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> @@ -198,6 +225,12 @@ Configuration: 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. "); mod cmn; @@ -221,7 +254,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_active_ad_summaries().get(&self.opt.arg_profile_id, &self.opt.arg_summary_account_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -253,8 +286,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -265,7 +297,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_permission_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -297,8 +329,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -309,7 +340,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_permission_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -341,8 +372,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -353,7 +383,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_permissions().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -385,8 +415,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -397,7 +426,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_permissions().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -429,8 +458,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -441,7 +469,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_user_profiles().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -473,8 +501,194 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + 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(); + 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_advertiser_filter_init(request: &mut api::AccountUserProfile) { + if request.advertiser_filter.is_none() { + request.advertiser_filter = Some(Default::default()); + } + } + + fn request_campaign_filter_init(request: &mut api::AccountUserProfile) { + if request.campaign_filter.is_none() { + request.campaign_filter = Some(Default::default()); + } + } + + fn request_site_filter_init(request: &mut api::AccountUserProfile) { + if request.site_filter.is_none() { + request.site_filter = Some(Default::default()); + } + } + + fn request_user_role_filter_init(request: &mut api::AccountUserProfile) { + if request.user_role_filter.is_none() { + request.user_role_filter = Some(Default::default()); + } + } + + match &field_name.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "subaccount-id" => { + request.subaccount_id = Some(value.unwrap_or("").to_string()); + }, + "user-role-filter.object-ids" => { + request_user_role_filter_init(&mut request); + if request.user_role_filter.as_mut().unwrap().object_ids.is_none() { + request.user_role_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.user_role_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "user-role-filter.status" => { + request_user_role_filter_init(&mut request); + request.user_role_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); + }, + "user-role-filter.kind" => { + request_user_role_filter_init(&mut request); + request.user_role_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_user_role_filter_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + "locale" => { + request_user_role_filter_init(&mut request); + request.locale = Some(value.unwrap_or("").to_string()); + }, + "site-filter.object-ids" => { + request_site_filter_init(&mut request); + if request.site_filter.as_mut().unwrap().object_ids.is_none() { + request.site_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.site_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "site-filter.status" => { + request_site_filter_init(&mut request); + request.site_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); + }, + "site-filter.kind" => { + request_site_filter_init(&mut request); + request.site_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "comments" => { + request_site_filter_init(&mut request); + request.comments = Some(value.unwrap_or("").to_string()); + }, + "trafficker-type" => { + request_site_filter_init(&mut request); + request.trafficker_type = Some(value.unwrap_or("").to_string()); + }, + "advertiser-filter.object-ids" => { + request_advertiser_filter_init(&mut request); + if request.advertiser_filter.as_mut().unwrap().object_ids.is_none() { + request.advertiser_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.advertiser_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "advertiser-filter.status" => { + request_advertiser_filter_init(&mut request); + request.advertiser_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); + }, + "advertiser-filter.kind" => { + request_advertiser_filter_init(&mut request); + request.advertiser_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "campaign-filter.object-ids" => { + request_campaign_filter_init(&mut request); + if request.campaign_filter.as_mut().unwrap().object_ids.is_none() { + request.campaign_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.campaign_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "campaign-filter.status" => { + request_campaign_filter_init(&mut request); + request.campaign_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); + }, + "campaign-filter.kind" => { + request_campaign_filter_init(&mut request); + request.campaign_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "email" => { + request_campaign_filter_init(&mut request); + request.email = Some(value.unwrap_or("").to_string()); + }, + "user-role-id" => { + request_campaign_filter_init(&mut request); + request.user_role_id = Some(value.unwrap_or("").to_string()); + }, + "user-access-type" => { + request_campaign_filter_init(&mut request); + request.user_access_type = Some(value.unwrap_or("").to_string()); + }, + "active" => { + request_campaign_filter_init(&mut request); + request.active = Some(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "id" => { + request_campaign_filter_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_campaign_filter_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); + 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 } } @@ -485,7 +699,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.account_user_profiles().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-role-id" => { call = call.user_role_id(value.unwrap_or("")); @@ -544,8 +758,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -554,10 +767,10 @@ impl Engine { fn _account_user_profiles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AccountUserProfile = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -577,9 +790,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -616,15 +830,18 @@ impl Engine { }, "user-role-filter.object-ids" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.user_role_filter.as_mut().unwrap().object_ids.is_none() { + request.user_role_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.user_role_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "user-role-filter.status" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.user_role_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "user-role-filter.kind" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_role_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "name" => { request_user_role_filter_init(&mut request); @@ -636,15 +853,18 @@ impl Engine { }, "site-filter.object-ids" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.site_filter.as_mut().unwrap().object_ids.is_none() { + request.site_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.site_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "site-filter.status" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.site_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "site-filter.kind" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.site_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "comments" => { request_site_filter_init(&mut request); @@ -656,27 +876,33 @@ impl Engine { }, "advertiser-filter.object-ids" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.advertiser_filter.as_mut().unwrap().object_ids.is_none() { + request.advertiser_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.advertiser_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "advertiser-filter.status" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.advertiser_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "advertiser-filter.kind" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.advertiser_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "campaign-filter.object-ids" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.campaign_filter.as_mut().unwrap().object_ids.is_none() { + request.campaign_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.campaign_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "campaign-filter.status" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.campaign_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "campaign-filter.kind" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.campaign_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "email" => { request_campaign_filter_init(&mut request); @@ -719,8 +945,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -729,10 +954,10 @@ impl Engine { fn _account_user_profiles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AccountUserProfile = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -752,9 +977,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -791,15 +1017,18 @@ impl Engine { }, "user-role-filter.object-ids" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.user_role_filter.as_mut().unwrap().object_ids.is_none() { + request.user_role_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.user_role_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "user-role-filter.status" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.user_role_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "user-role-filter.kind" => { request_user_role_filter_init(&mut request); - request.user_role_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.user_role_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "name" => { request_user_role_filter_init(&mut request); @@ -811,15 +1040,18 @@ impl Engine { }, "site-filter.object-ids" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.site_filter.as_mut().unwrap().object_ids.is_none() { + request.site_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.site_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "site-filter.status" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.site_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "site-filter.kind" => { request_site_filter_init(&mut request); - request.site_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.site_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "comments" => { request_site_filter_init(&mut request); @@ -831,27 +1063,33 @@ impl Engine { }, "advertiser-filter.object-ids" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.advertiser_filter.as_mut().unwrap().object_ids.is_none() { + request.advertiser_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.advertiser_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "advertiser-filter.status" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.advertiser_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "advertiser-filter.kind" => { request_advertiser_filter_init(&mut request); - request.advertiser_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.advertiser_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "campaign-filter.object-ids" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().object_ids.push(value.unwrap_or("").to_string()); + if request.campaign_filter.as_mut().unwrap().object_ids.is_none() { + request.campaign_filter.as_mut().unwrap().object_ids = Some(Default::default()); + } + request.campaign_filter.as_mut().unwrap().object_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "campaign-filter.status" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.campaign_filter.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "campaign-filter.kind" => { request_campaign_filter_init(&mut request); - request.campaign_filter.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.campaign_filter.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "email" => { request_campaign_filter_init(&mut request); @@ -894,8 +1132,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -906,7 +1143,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.accounts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -938,8 +1175,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -950,7 +1186,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.accounts().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -1003,8 +1239,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1013,10 +1248,10 @@ impl Engine { fn _accounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1036,9 +1271,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1048,6 +1284,13 @@ impl Engine { } } + fn request_reports_configuration_lookback_configuration_init(request: &mut api::Account) { + request_reports_configuration_init(request); + if request.reports_configuration.as_mut().unwrap().lookback_configuration.is_none() { + request.reports_configuration.as_mut().unwrap().lookback_configuration = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1072,9 +1315,9 @@ impl Engine { }, "account-permission-ids" => { if request.account_permission_ids.is_none() { - request.account_permission_ids = Some(Default::default()); + request.account_permission_ids = Some(Default::default()); } - request.account_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.account_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "account-profile" => { request.account_profile = Some(value.unwrap_or("").to_string()); @@ -1087,19 +1330,19 @@ impl Engine { }, "reports-configuration.report-generation-time-zone-id" => { request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().report_generation_time_zone_id = value.unwrap_or("").to_string(); + request.reports_configuration.as_mut().unwrap().report_generation_time_zone_id = Some(value.unwrap_or("").to_string()); }, "reports-configuration.exposure-to-conversion-enabled" => { request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().exposure_to_conversion_enabled = arg_from_str(value.unwrap_or("false"), err, "reports-configuration.exposure-to-conversion-enabled", "boolean"); + request.reports_configuration.as_mut().unwrap().exposure_to_conversion_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "reports-configuration.exposure-to-conversion-enabled", "boolean")); }, "reports-configuration.lookback-configuration.click-duration" => { - request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().lookback_configuration.click_duration = arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.click-duration", "integer"); + request_reports_configuration_lookback_configuration_init(&mut request); + request.reports_configuration.as_mut().unwrap().lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.click-duration", "integer")); }, "reports-configuration.lookback-configuration.post-impression-activities-duration" => { - request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().lookback_configuration.post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.post-impression-activities-duration", "integer"); + request_reports_configuration_lookback_configuration_init(&mut request); + request.reports_configuration.as_mut().unwrap().lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.post-impression-activities-duration", "integer")); }, "currency-id" => { request_reports_configuration_init(&mut request); @@ -1128,9 +1371,9 @@ impl Engine { "available-permission-ids" => { request_reports_configuration_init(&mut request); if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); + request.available_permission_ids = Some(Default::default()); } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1149,8 +1392,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1159,10 +1401,10 @@ impl Engine { fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Account = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1182,9 +1424,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1194,6 +1437,13 @@ impl Engine { } } + fn request_reports_configuration_lookback_configuration_init(request: &mut api::Account) { + request_reports_configuration_init(request); + if request.reports_configuration.as_mut().unwrap().lookback_configuration.is_none() { + request.reports_configuration.as_mut().unwrap().lookback_configuration = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1218,9 +1468,9 @@ impl Engine { }, "account-permission-ids" => { if request.account_permission_ids.is_none() { - request.account_permission_ids = Some(Default::default()); + request.account_permission_ids = Some(Default::default()); } - request.account_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.account_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "account-profile" => { request.account_profile = Some(value.unwrap_or("").to_string()); @@ -1233,19 +1483,19 @@ impl Engine { }, "reports-configuration.report-generation-time-zone-id" => { request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().report_generation_time_zone_id = value.unwrap_or("").to_string(); + request.reports_configuration.as_mut().unwrap().report_generation_time_zone_id = Some(value.unwrap_or("").to_string()); }, "reports-configuration.exposure-to-conversion-enabled" => { request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().exposure_to_conversion_enabled = arg_from_str(value.unwrap_or("false"), err, "reports-configuration.exposure-to-conversion-enabled", "boolean"); + request.reports_configuration.as_mut().unwrap().exposure_to_conversion_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "reports-configuration.exposure-to-conversion-enabled", "boolean")); }, "reports-configuration.lookback-configuration.click-duration" => { - request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().lookback_configuration.click_duration = arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.click-duration", "integer"); + request_reports_configuration_lookback_configuration_init(&mut request); + request.reports_configuration.as_mut().unwrap().lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.click-duration", "integer")); }, "reports-configuration.lookback-configuration.post-impression-activities-duration" => { - request_reports_configuration_init(&mut request); - request.reports_configuration.as_mut().unwrap().lookback_configuration.post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.post-impression-activities-duration", "integer"); + request_reports_configuration_lookback_configuration_init(&mut request); + request.reports_configuration.as_mut().unwrap().lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "reports-configuration.lookback-configuration.post-impression-activities-duration", "integer")); }, "currency-id" => { request_reports_configuration_init(&mut request); @@ -1274,9 +1524,9 @@ impl Engine { "available-permission-ids" => { request_reports_configuration_init(&mut request); if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); + request.available_permission_ids = Some(Default::default()); } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1295,8 +1545,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1307,7 +1556,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.ads().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1339,8 +1588,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1349,10 +1597,10 @@ impl Engine { fn _ads_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Ad = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1372,9 +1620,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1426,6 +1675,13 @@ impl Engine { } } + fn request_delivery_schedule_frequency_cap_init(request: &mut api::Ad) { + request_delivery_schedule_init(request); + if request.delivery_schedule.as_mut().unwrap().frequency_cap.is_none() { + request.delivery_schedule.as_mut().unwrap().frequency_cap = Some(Default::default()); + } + } + fn request_delivery_schedule_init(request: &mut api::Ad) { if request.delivery_schedule.is_none() { request.delivery_schedule = Some(Default::default()); @@ -1471,11 +1727,11 @@ impl Engine { match &field_name.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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "campaign-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -1487,27 +1743,27 @@ impl Engine { }, "geo-targeting.exclude-countries" => { request_geo_targeting_init(&mut request); - request.geo_targeting.as_mut().unwrap().exclude_countries = arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean"); + request.geo_targeting.as_mut().unwrap().exclude_countries = Some(arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean")); }, "delivery-schedule.priority" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().priority = value.unwrap_or("").to_string(); + request.delivery_schedule.as_mut().unwrap().priority = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.hard-cutoff" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().hard_cutoff = arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean"); + request.delivery_schedule.as_mut().unwrap().hard_cutoff = Some(arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean")); }, "delivery-schedule.frequency-cap.duration" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.duration = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.frequency-cap.impressions" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.impressions = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().impressions = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.impression-ratio" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().impression_ratio = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().impression_ratio = Some(value.unwrap_or("").to_string()); }, "advertiser-id-dimension-value.kind" => { request_advertiser_id_dimension_value_init(&mut request); @@ -1539,7 +1795,7 @@ impl Engine { }, "remarketing-list-expression.expression" => { request_remarketing_list_expression_init(&mut request); - request.remarketing_list_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.remarketing_list_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "account-id" => { request_remarketing_list_expression_init(&mut request); @@ -1551,27 +1807,27 @@ impl Engine { }, "creative-rotation.weight-calculation-strategy" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = Some(value.unwrap_or("").to_string()); }, "creative-rotation.creative-optimization-configuration-id" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = Some(value.unwrap_or("").to_string()); }, "creative-rotation.type" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "click-through-url.landing-page-id" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().landing_page_id = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().landing_page_id = Some(value.unwrap_or("").to_string()); }, "click-through-url.custom-click-through-url" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().custom_click_through_url = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().custom_click_through_url = Some(value.unwrap_or("").to_string()); }, "click-through-url.default-landing-page" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().default_landing_page = arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean"); + request.click_through_url.as_mut().unwrap().default_landing_page = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean")); }, "comments" => { request_click_through_url_init(&mut request); @@ -1635,7 +1891,7 @@ impl Engine { }, "key-value-targeting-expression.expression" => { request_key_value_targeting_expression_init(&mut request); - request.key_value_targeting_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.key_value_targeting_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "campaign-id-dimension-value.kind" => { request_campaign_id_dimension_value_init(&mut request); @@ -1663,15 +1919,15 @@ impl Engine { }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "start-time" => { request_create_info_init(&mut request); @@ -1699,19 +1955,25 @@ impl Engine { }, "day-part-targeting.user-local-time" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().user_local_time = arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean"); + request.day_part_targeting.as_mut().unwrap().user_local_time = Some(arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean")); }, "day-part-targeting.hours-of-day" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().hours_of_day.push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); + if request.day_part_targeting.as_mut().unwrap().hours_of_day.is_none() { + request.day_part_targeting.as_mut().unwrap().hours_of_day = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().hours_of_day.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); }, "day-part-targeting.days-of-week" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().days_of_week.push(value.unwrap_or("").to_string()); + if request.day_part_targeting.as_mut().unwrap().days_of_week.is_none() { + request.day_part_targeting.as_mut().unwrap().days_of_week = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().days_of_week.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "ssl-compliant" => { request_last_modified_info_init(&mut request); @@ -1742,8 +2004,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1754,7 +2015,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.ads().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.add_type(value.unwrap_or("")); @@ -1858,8 +2119,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1868,10 +2128,10 @@ impl Engine { fn _ads_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Ad = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1891,9 +2151,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1945,6 +2206,13 @@ impl Engine { } } + fn request_delivery_schedule_frequency_cap_init(request: &mut api::Ad) { + request_delivery_schedule_init(request); + if request.delivery_schedule.as_mut().unwrap().frequency_cap.is_none() { + request.delivery_schedule.as_mut().unwrap().frequency_cap = Some(Default::default()); + } + } + fn request_delivery_schedule_init(request: &mut api::Ad) { if request.delivery_schedule.is_none() { request.delivery_schedule = Some(Default::default()); @@ -1990,11 +2258,11 @@ impl Engine { match &field_name.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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "campaign-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -2006,27 +2274,27 @@ impl Engine { }, "geo-targeting.exclude-countries" => { request_geo_targeting_init(&mut request); - request.geo_targeting.as_mut().unwrap().exclude_countries = arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean"); + request.geo_targeting.as_mut().unwrap().exclude_countries = Some(arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean")); }, "delivery-schedule.priority" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().priority = value.unwrap_or("").to_string(); + request.delivery_schedule.as_mut().unwrap().priority = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.hard-cutoff" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().hard_cutoff = arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean"); + request.delivery_schedule.as_mut().unwrap().hard_cutoff = Some(arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean")); }, "delivery-schedule.frequency-cap.duration" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.duration = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.frequency-cap.impressions" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.impressions = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().impressions = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.impression-ratio" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().impression_ratio = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().impression_ratio = Some(value.unwrap_or("").to_string()); }, "advertiser-id-dimension-value.kind" => { request_advertiser_id_dimension_value_init(&mut request); @@ -2058,7 +2326,7 @@ impl Engine { }, "remarketing-list-expression.expression" => { request_remarketing_list_expression_init(&mut request); - request.remarketing_list_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.remarketing_list_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "account-id" => { request_remarketing_list_expression_init(&mut request); @@ -2070,27 +2338,27 @@ impl Engine { }, "creative-rotation.weight-calculation-strategy" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = Some(value.unwrap_or("").to_string()); }, "creative-rotation.creative-optimization-configuration-id" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = Some(value.unwrap_or("").to_string()); }, "creative-rotation.type" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "click-through-url.landing-page-id" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().landing_page_id = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().landing_page_id = Some(value.unwrap_or("").to_string()); }, "click-through-url.custom-click-through-url" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().custom_click_through_url = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().custom_click_through_url = Some(value.unwrap_or("").to_string()); }, "click-through-url.default-landing-page" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().default_landing_page = arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean"); + request.click_through_url.as_mut().unwrap().default_landing_page = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean")); }, "comments" => { request_click_through_url_init(&mut request); @@ -2154,7 +2422,7 @@ impl Engine { }, "key-value-targeting-expression.expression" => { request_key_value_targeting_expression_init(&mut request); - request.key_value_targeting_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.key_value_targeting_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "campaign-id-dimension-value.kind" => { request_campaign_id_dimension_value_init(&mut request); @@ -2182,15 +2450,15 @@ impl Engine { }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "start-time" => { request_create_info_init(&mut request); @@ -2218,19 +2486,25 @@ impl Engine { }, "day-part-targeting.user-local-time" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().user_local_time = arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean"); + request.day_part_targeting.as_mut().unwrap().user_local_time = Some(arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean")); }, "day-part-targeting.hours-of-day" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().hours_of_day.push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); + if request.day_part_targeting.as_mut().unwrap().hours_of_day.is_none() { + request.day_part_targeting.as_mut().unwrap().hours_of_day = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().hours_of_day.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); }, "day-part-targeting.days-of-week" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().days_of_week.push(value.unwrap_or("").to_string()); + if request.day_part_targeting.as_mut().unwrap().days_of_week.is_none() { + request.day_part_targeting.as_mut().unwrap().days_of_week = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().days_of_week.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "ssl-compliant" => { request_last_modified_info_init(&mut request); @@ -2261,8 +2535,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2271,10 +2544,10 @@ impl Engine { fn _ads_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Ad = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2294,9 +2567,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2348,6 +2622,13 @@ impl Engine { } } + fn request_delivery_schedule_frequency_cap_init(request: &mut api::Ad) { + request_delivery_schedule_init(request); + if request.delivery_schedule.as_mut().unwrap().frequency_cap.is_none() { + request.delivery_schedule.as_mut().unwrap().frequency_cap = Some(Default::default()); + } + } + fn request_delivery_schedule_init(request: &mut api::Ad) { if request.delivery_schedule.is_none() { request.delivery_schedule = Some(Default::default()); @@ -2393,11 +2674,11 @@ impl Engine { match &field_name.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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "campaign-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -2409,27 +2690,27 @@ impl Engine { }, "geo-targeting.exclude-countries" => { request_geo_targeting_init(&mut request); - request.geo_targeting.as_mut().unwrap().exclude_countries = arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean"); + request.geo_targeting.as_mut().unwrap().exclude_countries = Some(arg_from_str(value.unwrap_or("false"), err, "geo-targeting.exclude-countries", "boolean")); }, "delivery-schedule.priority" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().priority = value.unwrap_or("").to_string(); + request.delivery_schedule.as_mut().unwrap().priority = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.hard-cutoff" => { request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().hard_cutoff = arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean"); + request.delivery_schedule.as_mut().unwrap().hard_cutoff = Some(arg_from_str(value.unwrap_or("false"), err, "delivery-schedule.hard-cutoff", "boolean")); }, "delivery-schedule.frequency-cap.duration" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.duration = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.frequency-cap.impressions" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().frequency_cap.impressions = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().frequency_cap.as_mut().unwrap().impressions = Some(value.unwrap_or("").to_string()); }, "delivery-schedule.impression-ratio" => { - request_delivery_schedule_init(&mut request); - request.delivery_schedule.as_mut().unwrap().impression_ratio = value.unwrap_or("").to_string(); + request_delivery_schedule_frequency_cap_init(&mut request); + request.delivery_schedule.as_mut().unwrap().impression_ratio = Some(value.unwrap_or("").to_string()); }, "advertiser-id-dimension-value.kind" => { request_advertiser_id_dimension_value_init(&mut request); @@ -2461,7 +2742,7 @@ impl Engine { }, "remarketing-list-expression.expression" => { request_remarketing_list_expression_init(&mut request); - request.remarketing_list_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.remarketing_list_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "account-id" => { request_remarketing_list_expression_init(&mut request); @@ -2473,27 +2754,27 @@ impl Engine { }, "creative-rotation.weight-calculation-strategy" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().weight_calculation_strategy = Some(value.unwrap_or("").to_string()); }, "creative-rotation.creative-optimization-configuration-id" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().creative_optimization_configuration_id = Some(value.unwrap_or("").to_string()); }, "creative-rotation.type" => { request_creative_rotation_init(&mut request); - request.creative_rotation.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.creative_rotation.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "click-through-url.landing-page-id" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().landing_page_id = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().landing_page_id = Some(value.unwrap_or("").to_string()); }, "click-through-url.custom-click-through-url" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().custom_click_through_url = value.unwrap_or("").to_string(); + request.click_through_url.as_mut().unwrap().custom_click_through_url = Some(value.unwrap_or("").to_string()); }, "click-through-url.default-landing-page" => { request_click_through_url_init(&mut request); - request.click_through_url.as_mut().unwrap().default_landing_page = arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean"); + request.click_through_url.as_mut().unwrap().default_landing_page = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url.default-landing-page", "boolean")); }, "comments" => { request_click_through_url_init(&mut request); @@ -2557,7 +2838,7 @@ impl Engine { }, "key-value-targeting-expression.expression" => { request_key_value_targeting_expression_init(&mut request); - request.key_value_targeting_expression.as_mut().unwrap().expression = value.unwrap_or("").to_string(); + request.key_value_targeting_expression.as_mut().unwrap().expression = Some(value.unwrap_or("").to_string()); }, "campaign-id-dimension-value.kind" => { request_campaign_id_dimension_value_init(&mut request); @@ -2585,15 +2866,15 @@ impl Engine { }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "start-time" => { request_create_info_init(&mut request); @@ -2621,19 +2902,25 @@ impl Engine { }, "day-part-targeting.user-local-time" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().user_local_time = arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean"); + request.day_part_targeting.as_mut().unwrap().user_local_time = Some(arg_from_str(value.unwrap_or("false"), err, "day-part-targeting.user-local-time", "boolean")); }, "day-part-targeting.hours-of-day" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().hours_of_day.push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); + if request.day_part_targeting.as_mut().unwrap().hours_of_day.is_none() { + request.day_part_targeting.as_mut().unwrap().hours_of_day = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().hours_of_day.as_mut().unwrap().push(arg_from_str(value.unwrap_or("-0"), err, "day-part-targeting.hours-of-day", "integer")); }, "day-part-targeting.days-of-week" => { request_day_part_targeting_init(&mut request); - request.day_part_targeting.as_mut().unwrap().days_of_week.push(value.unwrap_or("").to_string()); + if request.day_part_targeting.as_mut().unwrap().days_of_week.is_none() { + request.day_part_targeting.as_mut().unwrap().days_of_week = Some(Default::default()); + } + request.day_part_targeting.as_mut().unwrap().days_of_week.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "ssl-compliant" => { request_last_modified_info_init(&mut request); @@ -2664,8 +2951,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2676,7 +2962,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertiser_groups().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2707,7 +2993,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2718,7 +3003,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertiser_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2750,8 +3035,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2760,10 +3044,10 @@ impl Engine { fn _advertiser_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AdvertiserGroup = Default::default(); + let mut request = api::AdvertiserGroup::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2783,9 +3067,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2819,8 +3104,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2831,7 +3115,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertiser_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -2881,8 +3165,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2891,10 +3174,10 @@ impl Engine { fn _advertiser_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AdvertiserGroup = Default::default(); + let mut request = api::AdvertiserGroup::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2914,9 +3197,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2950,8 +3234,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2960,10 +3243,10 @@ impl Engine { fn _advertiser_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AdvertiserGroup = Default::default(); + let mut request = api::AdvertiserGroup::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2983,9 +3266,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3019,8 +3303,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3031,7 +3314,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertisers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3063,8 +3346,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3073,10 +3355,10 @@ impl Engine { fn _advertisers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Advertiser = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3096,9 +3378,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3130,6 +3413,9 @@ impl Engine { "default-click-through-event-tag-id" => { request.default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, + "original-floodlight-configuration-id" => { + request.original_floodlight_configuration_id = Some(value.unwrap_or("").to_string()); + }, "click-through-url-suffix" => { request.click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, @@ -3217,8 +3503,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3229,7 +3514,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertisers().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "subaccount-id" => { call = call.subaccount_id(value.unwrap_or("")); @@ -3297,8 +3582,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3307,10 +3591,10 @@ impl Engine { fn _advertisers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Advertiser = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3330,9 +3614,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3364,6 +3649,9 @@ impl Engine { "default-click-through-event-tag-id" => { request.default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, + "original-floodlight-configuration-id" => { + request.original_floodlight_configuration_id = Some(value.unwrap_or("").to_string()); + }, "click-through-url-suffix" => { request.click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, @@ -3451,8 +3739,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3461,10 +3748,10 @@ impl Engine { fn _advertisers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Advertiser = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3484,9 +3771,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3518,6 +3806,9 @@ impl Engine { "default-click-through-event-tag-id" => { request.default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, + "original-floodlight-configuration-id" => { + request.original_floodlight_configuration_id = Some(value.unwrap_or("").to_string()); + }, "click-through-url-suffix" => { request.click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, @@ -3605,8 +3896,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3617,7 +3907,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.browsers().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3649,8 +3939,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3659,10 +3948,10 @@ impl Engine { fn _campaign_creative_associations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CampaignCreativeAssociation = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3682,9 +3971,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3712,8 +4002,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3724,7 +4013,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.campaign_creative_associations().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -3765,8 +4054,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3777,7 +4065,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.campaigns().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3809,8 +4097,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3819,10 +4106,10 @@ impl Engine { fn _campaigns_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Campaign = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3842,9 +4129,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3908,11 +4196,11 @@ impl Engine { }, "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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "advertiser-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -3944,15 +4232,15 @@ impl Engine { }, "creative-optimization-configuration.optimization-model" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().optimization_model = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().optimization_model = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.id" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.name" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "id" => { request_creative_optimization_configuration_init(&mut request); @@ -3965,9 +4253,9 @@ impl Engine { "trafficker-emails" => { request_creative_optimization_configuration_init(&mut request); if request.trafficker_emails.is_none() { - request.trafficker_emails = Some(Default::default()); + request.trafficker_emails = Some(Default::default()); } - request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "archived" => { request_creative_optimization_configuration_init(&mut request); @@ -4016,21 +4304,21 @@ impl Engine { "creative-group-ids" => { request_id_dimension_value_init(&mut request); if request.creative_group_ids.is_none() { - request.creative_group_ids = Some(Default::default()); + request.creative_group_ids = Some(Default::default()); } - request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "kind" => { request_create_info_init(&mut request); @@ -4046,11 +4334,11 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "nielsen-ocr-enabled" => { request_lookback_configuration_init(&mut request); @@ -4058,7 +4346,7 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + 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()))); @@ -4077,8 +4365,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4089,7 +4376,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.campaigns().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "subaccount-id" => { call = call.subaccount_id(value.unwrap_or("")); @@ -4160,8 +4447,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4170,10 +4456,10 @@ impl Engine { fn _campaigns_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Campaign = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4193,9 +4479,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4259,11 +4546,11 @@ impl Engine { }, "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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "advertiser-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -4295,15 +4582,15 @@ impl Engine { }, "creative-optimization-configuration.optimization-model" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().optimization_model = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().optimization_model = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.id" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.name" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "id" => { request_creative_optimization_configuration_init(&mut request); @@ -4316,9 +4603,9 @@ impl Engine { "trafficker-emails" => { request_creative_optimization_configuration_init(&mut request); if request.trafficker_emails.is_none() { - request.trafficker_emails = Some(Default::default()); + request.trafficker_emails = Some(Default::default()); } - request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "archived" => { request_creative_optimization_configuration_init(&mut request); @@ -4367,21 +4654,21 @@ impl Engine { "creative-group-ids" => { request_id_dimension_value_init(&mut request); if request.creative_group_ids.is_none() { - request.creative_group_ids = Some(Default::default()); + request.creative_group_ids = Some(Default::default()); } - request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "kind" => { request_create_info_init(&mut request); @@ -4397,11 +4684,11 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "nielsen-ocr-enabled" => { request_lookback_configuration_init(&mut request); @@ -4409,7 +4696,7 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + 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()))); @@ -4428,8 +4715,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4438,10 +4724,10 @@ impl Engine { fn _campaigns_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Campaign = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4461,9 +4747,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4527,11 +4814,11 @@ impl Engine { }, "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 = value.unwrap_or("").to_string(); + request.click_through_url_suffix_properties.as_mut().unwrap().click_through_url_suffix = Some(value.unwrap_or("").to_string()); }, "click-through-url-suffix-properties.override-inherited-suffix" => { request_click_through_url_suffix_properties_init(&mut request); - request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean"); + request.click_through_url_suffix_properties.as_mut().unwrap().override_inherited_suffix = Some(arg_from_str(value.unwrap_or("false"), err, "click-through-url-suffix-properties.override-inherited-suffix", "boolean")); }, "advertiser-id" => { request_click_through_url_suffix_properties_init(&mut request); @@ -4563,15 +4850,15 @@ impl Engine { }, "creative-optimization-configuration.optimization-model" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().optimization_model = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().optimization_model = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.id" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "creative-optimization-configuration.name" => { request_creative_optimization_configuration_init(&mut request); - request.creative_optimization_configuration.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.creative_optimization_configuration.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "id" => { request_creative_optimization_configuration_init(&mut request); @@ -4584,9 +4871,9 @@ impl Engine { "trafficker-emails" => { request_creative_optimization_configuration_init(&mut request); if request.trafficker_emails.is_none() { - request.trafficker_emails = Some(Default::default()); + request.trafficker_emails = Some(Default::default()); } - request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "archived" => { request_creative_optimization_configuration_init(&mut request); @@ -4635,21 +4922,21 @@ impl Engine { "creative-group-ids" => { request_id_dimension_value_init(&mut request); if request.creative_group_ids.is_none() { - request.creative_group_ids = Some(Default::default()); + request.creative_group_ids = Some(Default::default()); } - request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creative_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "default-click-through-event-tag-properties.override-inherited-event-tag" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean"); + request.default_click_through_event_tag_properties.as_mut().unwrap().override_inherited_event_tag = Some(arg_from_str(value.unwrap_or("false"), err, "default-click-through-event-tag-properties.override-inherited-event-tag", "boolean")); }, "default-click-through-event-tag-properties.default-click-through-event-tag-id" => { request_default_click_through_event_tag_properties_init(&mut request); - request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = value.unwrap_or("").to_string(); + request.default_click_through_event_tag_properties.as_mut().unwrap().default_click_through_event_tag_id = Some(value.unwrap_or("").to_string()); }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "kind" => { request_create_info_init(&mut request); @@ -4665,11 +4952,11 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "nielsen-ocr-enabled" => { request_lookback_configuration_init(&mut request); @@ -4677,7 +4964,7 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + 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()))); @@ -4696,8 +4983,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4708,7 +4994,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.change_logs().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4740,8 +5026,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4752,7 +5037,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.change_logs().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-profile-ids" => { call = call.add_user_profile_ids(value.unwrap_or("")); @@ -4814,8 +5099,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4826,7 +5110,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.cities().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "region-dart-ids" => { call = call.add_region_dart_ids(value.unwrap_or("")); @@ -4870,19 +5154,18 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } } } - fn _connection_types_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + fn _connection_types_get(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut call = self.hub.connection_types().list(&self.opt.arg_profile_id); + let mut call = self.hub.connection_types().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4914,8 +5197,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _connection_types_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.connection_types().list(&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); + 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 } } @@ -4926,7 +5251,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.content_categories().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4957,7 +5282,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4968,7 +5292,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.content_categories().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5000,8 +5324,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5010,10 +5333,10 @@ impl Engine { fn _content_categories_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ContentCategory = Default::default(); + let mut request = api::ContentCategory::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5033,21 +5356,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); - }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); + "id" => { + request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -5072,8 +5393,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5084,7 +5404,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.content_categories().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -5134,8 +5454,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5144,10 +5463,10 @@ impl Engine { fn _content_categories_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ContentCategory = Default::default(); + let mut request = api::ContentCategory::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5167,21 +5486,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); - }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); + "id" => { + request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -5206,8 +5523,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5216,10 +5532,10 @@ impl Engine { fn _content_categories_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ContentCategory = Default::default(); + let mut request = api::ContentCategory::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5239,21 +5555,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); - }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, - "description" => { - request.description = Some(value.unwrap_or("").to_string()); + "id" => { + request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -5278,8 +5592,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5290,7 +5603,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.countries().get(&self.opt.arg_profile_id, &self.opt.arg_dart_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5322,8 +5635,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5334,7 +5646,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.countries().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5366,8 +5678,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5376,10 +5687,10 @@ impl Engine { fn _creative_assets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeAssetMetadata = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5399,9 +5710,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5414,26 +5726,26 @@ impl Engine { match &field_name.to_string()[..] { "warned-validation-rules" => { if request.warned_validation_rules.is_none() { - request.warned_validation_rules = Some(Default::default()); + request.warned_validation_rules = Some(Default::default()); } - request.warned_validation_rules.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.warned_validation_rules.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "detected-features" => { if request.detected_features.is_none() { - request.detected_features = Some(Default::default()); + request.detected_features = Some(Default::default()); } - request.detected_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.detected_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, "asset-identifier.type" => { request_asset_identifier_init(&mut request); - request.asset_identifier.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.asset_identifier.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "asset-identifier.name" => { request_asset_identifier_init(&mut request); - request.asset_identifier.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.asset_identifier.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -5462,8 +5774,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5474,7 +5785,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_field_values().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5505,7 +5816,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -5516,7 +5826,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_field_values().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5548,8 +5858,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5558,10 +5867,10 @@ impl Engine { fn _creative_field_values_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeFieldValue = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5581,9 +5890,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5614,8 +5924,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5626,7 +5935,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_field_values().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -5676,8 +5985,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5686,10 +5994,10 @@ impl Engine { fn _creative_field_values_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeFieldValue = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5709,9 +6017,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5742,8 +6051,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5752,10 +6060,10 @@ impl Engine { fn _creative_field_values_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeFieldValue = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5775,9 +6083,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5808,8 +6117,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5820,7 +6128,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_fields().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5851,7 +6159,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -5862,7 +6169,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_fields().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5894,8 +6201,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5904,10 +6210,10 @@ impl Engine { fn _creative_fields_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeField = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -5927,9 +6233,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6001,8 +6308,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6013,7 +6319,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_fields().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -6066,8 +6372,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6076,10 +6381,10 @@ impl Engine { fn _creative_fields_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeField = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6099,9 +6404,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6173,8 +6479,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6183,10 +6488,10 @@ impl Engine { fn _creative_fields_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeField = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6206,9 +6511,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6280,8 +6586,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6292,7 +6597,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6324,8 +6629,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6334,10 +6638,10 @@ impl Engine { fn _creative_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6357,9 +6661,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6434,8 +6739,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6446,7 +6750,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creative_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -6502,8 +6806,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6512,10 +6815,10 @@ impl Engine { fn _creative_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6535,9 +6838,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6612,8 +6916,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6622,10 +6925,10 @@ impl Engine { fn _creative_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CreativeGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6645,9 +6948,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6722,8 +7026,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6734,7 +7037,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creatives().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6766,8 +7069,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6776,10 +7078,10 @@ impl Engine { fn _creatives_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Creative = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -6799,9 +7101,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6856,23 +7159,23 @@ impl Engine { }, "fs-command.window-height" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_height = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer"); + request.fs_command.as_mut().unwrap().window_height = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer")); }, "fs-command.top" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().top = arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer"); + request.fs_command.as_mut().unwrap().top = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer")); }, "fs-command.window-width" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_width = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer"); + request.fs_command.as_mut().unwrap().window_width = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer")); }, "fs-command.position-option" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().position_option = value.unwrap_or("").to_string(); + request.fs_command.as_mut().unwrap().position_option = Some(value.unwrap_or("").to_string()); }, "fs-command.left" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().left = arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer"); + request.fs_command.as_mut().unwrap().left = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer")); }, "rendering-id-dimension-value.kind" => { request_rendering_id_dimension_value_init(&mut request); @@ -6961,9 +7264,9 @@ impl Engine { "custom-key-values" => { request_size_init(&mut request); if request.custom_key_values.is_none() { - request.custom_key_values = Some(Default::default()); + request.custom_key_values = Some(Default::default()); } - request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id-dimension-value.kind" => { request_id_dimension_value_init(&mut request); @@ -7036,9 +7339,9 @@ impl Engine { "compatibility" => { request_id_dimension_value_init(&mut request); if request.compatibility.is_none() { - request.compatibility = Some(Default::default()); + request.compatibility = Some(Default::default()); } - request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "ad-parameters" => { request_id_dimension_value_init(&mut request); @@ -7047,9 +7350,9 @@ impl Engine { "ad-tag-keys" => { request_id_dimension_value_init(&mut request); if request.ad_tag_keys.is_none() { - request.ad_tag_keys = Some(Default::default()); + request.ad_tag_keys = Some(Default::default()); } - request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_id_dimension_value_init(&mut request); @@ -7063,13 +7366,17 @@ impl Engine { request_id_dimension_value_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, + "convert-flash-to-html5" => { + request_id_dimension_value_init(&mut request); + request.convert_flash_to_html5 = Some(arg_from_str(value.unwrap_or("false"), err, "convert-flash-to-html5", "boolean")); + }, "video-duration" => { request_id_dimension_value_init(&mut request); request.video_duration = Some(arg_from_str(value.unwrap_or("0.0"), err, "video-duration", "number")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "backup-image-click-through-url" => { request_last_modified_info_init(&mut request); @@ -7094,9 +7401,9 @@ impl Engine { "companion-creatives" => { request_last_modified_info_init(&mut request); if request.companion_creatives.is_none() { - request.companion_creatives = Some(Default::default()); + request.companion_creatives = Some(Default::default()); } - request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "auto-advance-images" => { request_last_modified_info_init(&mut request); @@ -7105,17 +7412,17 @@ impl Engine { "backup-image-features" => { request_last_modified_info_init(&mut request); if request.backup_image_features.is_none() { - request.backup_image_features = Some(Default::default()); + request.backup_image_features = Some(Default::default()); } - request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "backup-image-target-window.custom-html" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().custom_html = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().custom_html = Some(value.unwrap_or("").to_string()); }, "backup-image-target-window.target-window-option" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().target_window_option = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().target_window_option = Some(value.unwrap_or("").to_string()); }, "skippable" => { request_backup_image_target_window_init(&mut request); @@ -7138,8 +7445,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7150,7 +7456,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.creatives().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "types" => { call = call.add_types(value.unwrap_or("")); @@ -7230,8 +7536,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7240,10 +7545,10 @@ impl Engine { fn _creatives_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Creative = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7263,9 +7568,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7320,23 +7626,23 @@ impl Engine { }, "fs-command.window-height" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_height = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer"); + request.fs_command.as_mut().unwrap().window_height = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer")); }, "fs-command.top" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().top = arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer"); + request.fs_command.as_mut().unwrap().top = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer")); }, "fs-command.window-width" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_width = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer"); + request.fs_command.as_mut().unwrap().window_width = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer")); }, "fs-command.position-option" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().position_option = value.unwrap_or("").to_string(); + request.fs_command.as_mut().unwrap().position_option = Some(value.unwrap_or("").to_string()); }, "fs-command.left" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().left = arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer"); + request.fs_command.as_mut().unwrap().left = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer")); }, "rendering-id-dimension-value.kind" => { request_rendering_id_dimension_value_init(&mut request); @@ -7425,9 +7731,9 @@ impl Engine { "custom-key-values" => { request_size_init(&mut request); if request.custom_key_values.is_none() { - request.custom_key_values = Some(Default::default()); + request.custom_key_values = Some(Default::default()); } - request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id-dimension-value.kind" => { request_id_dimension_value_init(&mut request); @@ -7500,9 +7806,9 @@ impl Engine { "compatibility" => { request_id_dimension_value_init(&mut request); if request.compatibility.is_none() { - request.compatibility = Some(Default::default()); + request.compatibility = Some(Default::default()); } - request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "ad-parameters" => { request_id_dimension_value_init(&mut request); @@ -7511,9 +7817,9 @@ impl Engine { "ad-tag-keys" => { request_id_dimension_value_init(&mut request); if request.ad_tag_keys.is_none() { - request.ad_tag_keys = Some(Default::default()); + request.ad_tag_keys = Some(Default::default()); } - request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_id_dimension_value_init(&mut request); @@ -7527,13 +7833,17 @@ impl Engine { request_id_dimension_value_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, + "convert-flash-to-html5" => { + request_id_dimension_value_init(&mut request); + request.convert_flash_to_html5 = Some(arg_from_str(value.unwrap_or("false"), err, "convert-flash-to-html5", "boolean")); + }, "video-duration" => { request_id_dimension_value_init(&mut request); request.video_duration = Some(arg_from_str(value.unwrap_or("0.0"), err, "video-duration", "number")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "backup-image-click-through-url" => { request_last_modified_info_init(&mut request); @@ -7558,9 +7868,9 @@ impl Engine { "companion-creatives" => { request_last_modified_info_init(&mut request); if request.companion_creatives.is_none() { - request.companion_creatives = Some(Default::default()); + request.companion_creatives = Some(Default::default()); } - request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "auto-advance-images" => { request_last_modified_info_init(&mut request); @@ -7569,17 +7879,17 @@ impl Engine { "backup-image-features" => { request_last_modified_info_init(&mut request); if request.backup_image_features.is_none() { - request.backup_image_features = Some(Default::default()); + request.backup_image_features = Some(Default::default()); } - request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "backup-image-target-window.custom-html" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().custom_html = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().custom_html = Some(value.unwrap_or("").to_string()); }, "backup-image-target-window.target-window-option" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().target_window_option = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().target_window_option = Some(value.unwrap_or("").to_string()); }, "skippable" => { request_backup_image_target_window_init(&mut request); @@ -7602,8 +7912,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7612,10 +7921,10 @@ impl Engine { fn _creatives_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Creative = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -7635,9 +7944,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -7692,23 +8002,23 @@ impl Engine { }, "fs-command.window-height" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_height = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer"); + request.fs_command.as_mut().unwrap().window_height = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-height", "integer")); }, "fs-command.top" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().top = arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer"); + request.fs_command.as_mut().unwrap().top = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.top", "integer")); }, "fs-command.window-width" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().window_width = arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer"); + request.fs_command.as_mut().unwrap().window_width = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.window-width", "integer")); }, "fs-command.position-option" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().position_option = value.unwrap_or("").to_string(); + request.fs_command.as_mut().unwrap().position_option = Some(value.unwrap_or("").to_string()); }, "fs-command.left" => { request_fs_command_init(&mut request); - request.fs_command.as_mut().unwrap().left = arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer"); + request.fs_command.as_mut().unwrap().left = Some(arg_from_str(value.unwrap_or("-0"), err, "fs-command.left", "integer")); }, "rendering-id-dimension-value.kind" => { request_rendering_id_dimension_value_init(&mut request); @@ -7797,9 +8107,9 @@ impl Engine { "custom-key-values" => { request_size_init(&mut request); if request.custom_key_values.is_none() { - request.custom_key_values = Some(Default::default()); + request.custom_key_values = Some(Default::default()); } - request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.custom_key_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id-dimension-value.kind" => { request_id_dimension_value_init(&mut request); @@ -7872,9 +8182,9 @@ impl Engine { "compatibility" => { request_id_dimension_value_init(&mut request); if request.compatibility.is_none() { - request.compatibility = Some(Default::default()); + request.compatibility = Some(Default::default()); } - request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.compatibility.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "ad-parameters" => { request_id_dimension_value_init(&mut request); @@ -7883,9 +8193,9 @@ impl Engine { "ad-tag-keys" => { request_id_dimension_value_init(&mut request); if request.ad_tag_keys.is_none() { - request.ad_tag_keys = Some(Default::default()); + request.ad_tag_keys = Some(Default::default()); } - request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ad_tag_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_id_dimension_value_init(&mut request); @@ -7899,13 +8209,17 @@ impl Engine { request_id_dimension_value_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, + "convert-flash-to-html5" => { + request_id_dimension_value_init(&mut request); + request.convert_flash_to_html5 = Some(arg_from_str(value.unwrap_or("false"), err, "convert-flash-to-html5", "boolean")); + }, "video-duration" => { request_id_dimension_value_init(&mut request); request.video_duration = Some(arg_from_str(value.unwrap_or("0.0"), err, "video-duration", "number")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "backup-image-click-through-url" => { request_last_modified_info_init(&mut request); @@ -7930,9 +8244,9 @@ impl Engine { "companion-creatives" => { request_last_modified_info_init(&mut request); if request.companion_creatives.is_none() { - request.companion_creatives = Some(Default::default()); + request.companion_creatives = Some(Default::default()); } - request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.companion_creatives.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "auto-advance-images" => { request_last_modified_info_init(&mut request); @@ -7941,17 +8255,17 @@ impl Engine { "backup-image-features" => { request_last_modified_info_init(&mut request); if request.backup_image_features.is_none() { - request.backup_image_features = Some(Default::default()); + request.backup_image_features = Some(Default::default()); } - request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.backup_image_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "backup-image-target-window.custom-html" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().custom_html = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().custom_html = Some(value.unwrap_or("").to_string()); }, "backup-image-target-window.target-window-option" => { request_backup_image_target_window_init(&mut request); - request.backup_image_target_window.as_mut().unwrap().target_window_option = value.unwrap_or("").to_string(); + request.backup_image_target_window.as_mut().unwrap().target_window_option = Some(value.unwrap_or("").to_string()); }, "skippable" => { request_backup_image_target_window_init(&mut request); @@ -7974,8 +8288,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -7984,10 +8297,10 @@ impl Engine { fn _dimension_values_query(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DimensionValueRequest = Default::default(); + let mut request = api::DimensionValueRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -8013,9 +8326,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8049,8 +8363,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8061,7 +8374,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.directory_site_contacts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8093,8 +8406,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8105,7 +8417,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.directory_site_contacts().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -8158,8 +8470,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8170,7 +8481,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.directory_sites().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8202,8 +8513,198 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + 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(); + 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_id_dimension_value_init(request: &mut api::DirectorySite) { + if request.id_dimension_value.is_none() { + request.id_dimension_value = Some(Default::default()); + } + } + + fn request_settings_dfp_settings_init(request: &mut api::DirectorySite) { + request_settings_init(request); + if request.settings.as_mut().unwrap().dfp_settings.is_none() { + request.settings.as_mut().unwrap().dfp_settings = Some(Default::default()); + } + } + + fn request_settings_init(request: &mut api::DirectorySite) { + if request.settings.is_none() { + request.settings = Some(Default::default()); + } + } + + match &field_name.to_string()[..] { + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); + }, + "country-id" => { + request.country_id = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request.description = Some(value.unwrap_or("").to_string()); + }, + "settings.nielsen-ocr-opt-out" => { + request_settings_init(&mut request); + request.settings.as_mut().unwrap().nielsen_ocr_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "settings.nielsen-ocr-opt-out", "boolean")); + }, + "settings.active-view-opt-out" => { + request_settings_init(&mut request); + request.settings.as_mut().unwrap().active_view_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "settings.active-view-opt-out", "boolean")); + }, + "settings.dfp-settings.dfp-network-name" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().dfp_settings.as_mut().unwrap().dfp_network_name = Some(value.unwrap_or("").to_string()); + }, + "settings.dfp-settings.publisher-portal-only" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().dfp_settings.as_mut().unwrap().publisher_portal_only = Some(arg_from_str(value.unwrap_or("false"), err, "settings.dfp-settings.publisher-portal-only", "boolean")); + }, + "settings.dfp-settings.programmatic-placement-accepted" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().dfp_settings.as_mut().unwrap().programmatic_placement_accepted = Some(arg_from_str(value.unwrap_or("false"), err, "settings.dfp-settings.programmatic-placement-accepted", "boolean")); + }, + "settings.dfp-settings.pub-paid-placement-accepted" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().dfp_settings.as_mut().unwrap().pub_paid_placement_accepted = Some(arg_from_str(value.unwrap_or("false"), err, "settings.dfp-settings.pub-paid-placement-accepted", "boolean")); + }, + "settings.dfp-settings.dfp-network-code" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().dfp_settings.as_mut().unwrap().dfp_network_code = Some(value.unwrap_or("").to_string()); + }, + "settings.verification-tag-opt-out" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().verification_tag_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "settings.verification-tag-opt-out", "boolean")); + }, + "settings.instream-video-placement-accepted" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().instream_video_placement_accepted = Some(arg_from_str(value.unwrap_or("false"), err, "settings.instream-video-placement-accepted", "boolean")); + }, + "settings.interstitial-placement-accepted" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().interstitial_placement_accepted = Some(arg_from_str(value.unwrap_or("false"), err, "settings.interstitial-placement-accepted", "boolean")); + }, + "settings.video-active-view-opt-out" => { + request_settings_dfp_settings_init(&mut request); + request.settings.as_mut().unwrap().video_active_view_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "settings.video-active-view-opt-out", "boolean")); + }, + "currency-id" => { + request_settings_init(&mut request); + request.currency_id = Some(value.unwrap_or("").to_string()); + }, + "inpage-tag-formats" => { + request_settings_init(&mut request); + if request.inpage_tag_formats.is_none() { + request.inpage_tag_formats = Some(Default::default()); + } + request.inpage_tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "url" => { + request_settings_init(&mut request); + request.url = Some(value.unwrap_or("").to_string()); + }, + "parent-id" => { + request_settings_init(&mut request); + request.parent_id = Some(value.unwrap_or("").to_string()); + }, + "interstitial-tag-formats" => { + request_settings_init(&mut request); + if request.interstitial_tag_formats.is_none() { + request.interstitial_tag_formats = Some(Default::default()); + } + request.interstitial_tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); + }, + "id-dimension-value.kind" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "id-dimension-value.value" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "id-dimension-value.dimension-name" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); + }, + "id-dimension-value.etag" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "id-dimension-value.match-type" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); + }, + "id-dimension-value.id" => { + request_id_dimension_value_init(&mut request); + request.id_dimension_value.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "active" => { + request_id_dimension_value_init(&mut request); + request.active = Some(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "id" => { + request_id_dimension_value_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_id_dimension_value_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); + 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 } } @@ -8214,7 +8715,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.directory_sites().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -8285,8 +8786,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8297,7 +8797,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.event_tags().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8328,7 +8828,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -8339,7 +8838,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.event_tags().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8371,8 +8870,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8381,10 +8879,10 @@ impl Engine { fn _event_tags_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::EventTag = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8404,9 +8902,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8428,9 +8927,9 @@ impl Engine { }, "site-ids" => { if request.site_ids.is_none() { - request.site_ids = Some(Default::default()); + request.site_ids = Some(Default::default()); } - request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "subaccount-id" => { request.subaccount_id = Some(value.unwrap_or("").to_string()); @@ -8543,8 +9042,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8555,7 +9053,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.event_tags().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -8617,8 +9115,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8627,10 +9124,10 @@ impl Engine { fn _event_tags_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::EventTag = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8650,9 +9147,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8674,9 +9172,9 @@ impl Engine { }, "site-ids" => { if request.site_ids.is_none() { - request.site_ids = Some(Default::default()); + request.site_ids = Some(Default::default()); } - request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "subaccount-id" => { request.subaccount_id = Some(value.unwrap_or("").to_string()); @@ -8789,8 +9287,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8799,10 +9296,10 @@ impl Engine { fn _event_tags_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::EventTag = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -8822,9 +9319,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -8846,9 +9344,9 @@ impl Engine { }, "site-ids" => { if request.site_ids.is_none() { - request.site_ids = Some(Default::default()); + request.site_ids = Some(Default::default()); } - request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.site_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "subaccount-id" => { request.subaccount_id = Some(value.unwrap_or("").to_string()); @@ -8961,8 +9459,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -8974,7 +9471,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.files().get(&self.opt.arg_report_id, &self.opt.arg_file_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9009,9 +9506,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -9025,7 +9521,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.files().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -9072,8 +9568,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9084,7 +9579,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activities().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9115,7 +9610,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -9126,7 +9620,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activities().generatetag(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "floodlight-activity-id" => { call = call.floodlight_activity_id(value.unwrap_or("")); @@ -9161,8 +9655,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9173,7 +9666,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activities().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9205,8 +9698,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9215,10 +9707,10 @@ impl Engine { fn _floodlight_activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivity = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9238,9 +9730,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -9389,9 +9882,9 @@ impl Engine { "user-defined-variable-types" => { request_floodlight_configuration_id_dimension_value_init(&mut request); if request.user_defined_variable_types.is_none() { - request.user_defined_variable_types = Some(Default::default()); + request.user_defined_variable_types = Some(Default::default()); } - request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "counting-method" => { request_floodlight_configuration_id_dimension_value_init(&mut request); @@ -9442,8 +9935,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9454,7 +9946,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activities().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tag-string" => { call = call.tag_string(value.unwrap_or("")); @@ -9525,8 +10017,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9535,10 +10026,10 @@ impl Engine { fn _floodlight_activities_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivity = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9558,9 +10049,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -9709,9 +10201,9 @@ impl Engine { "user-defined-variable-types" => { request_floodlight_configuration_id_dimension_value_init(&mut request); if request.user_defined_variable_types.is_none() { - request.user_defined_variable_types = Some(Default::default()); + request.user_defined_variable_types = Some(Default::default()); } - request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "counting-method" => { request_floodlight_configuration_id_dimension_value_init(&mut request); @@ -9762,8 +10254,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -9772,10 +10263,10 @@ impl Engine { fn _floodlight_activities_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivity = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -9795,9 +10286,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -9946,9 +10438,9 @@ impl Engine { "user-defined-variable-types" => { request_floodlight_configuration_id_dimension_value_init(&mut request); if request.user_defined_variable_types.is_none() { - request.user_defined_variable_types = Some(Default::default()); + request.user_defined_variable_types = Some(Default::default()); } - request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.user_defined_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "counting-method" => { request_floodlight_configuration_id_dimension_value_init(&mut request); @@ -9999,8 +10491,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10011,7 +10502,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activity_groups().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10042,7 +10533,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -10053,7 +10543,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activity_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10085,8 +10575,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10095,10 +10584,10 @@ impl Engine { fn _floodlight_activity_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivityGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10118,9 +10607,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -10263,8 +10753,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10275,7 +10764,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_activity_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); @@ -10334,8 +10823,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10344,10 +10832,10 @@ impl Engine { fn _floodlight_activity_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivityGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10367,9 +10855,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -10512,8 +11001,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10522,10 +11010,10 @@ impl Engine { fn _floodlight_activity_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightActivityGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10545,9 +11033,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -10690,8 +11179,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10702,7 +11190,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_configurations().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10734,8 +11222,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10746,7 +11233,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.floodlight_configurations().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "ids" => { call = call.add_ids(value.unwrap_or("")); @@ -10781,8 +11268,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10791,10 +11277,10 @@ impl Engine { fn _floodlight_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -10814,9 +11300,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -10865,11 +11352,11 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "first-day-of-week" => { request_lookback_configuration_init(&mut request); @@ -10878,17 +11365,17 @@ impl Engine { "standard-variable-types" => { request_lookback_configuration_init(&mut request); if request.standard_variable_types.is_none() { - request.standard_variable_types = Some(Default::default()); + request.standard_variable_types = Some(Default::default()); } - request.standard_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.standard_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "omniture-settings.omniture-cost-data-enabled" => { request_omniture_settings_init(&mut request); - request.omniture_settings.as_mut().unwrap().omniture_cost_data_enabled = arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-cost-data-enabled", "boolean"); + request.omniture_settings.as_mut().unwrap().omniture_cost_data_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-cost-data-enabled", "boolean")); }, "omniture-settings.omniture-integration-enabled" => { request_omniture_settings_init(&mut request); - request.omniture_settings.as_mut().unwrap().omniture_integration_enabled = arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-integration-enabled", "boolean"); + request.omniture_settings.as_mut().unwrap().omniture_integration_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-integration-enabled", "boolean")); }, "subaccount-id" => { request_omniture_settings_init(&mut request); @@ -10900,11 +11387,11 @@ impl Engine { }, "tag-settings.dynamic-tag-enabled" => { request_tag_settings_init(&mut request); - request.tag_settings.as_mut().unwrap().dynamic_tag_enabled = arg_from_str(value.unwrap_or("false"), err, "tag-settings.dynamic-tag-enabled", "boolean"); + request.tag_settings.as_mut().unwrap().dynamic_tag_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "tag-settings.dynamic-tag-enabled", "boolean")); }, "tag-settings.image-tag-enabled" => { request_tag_settings_init(&mut request); - request.tag_settings.as_mut().unwrap().image_tag_enabled = arg_from_str(value.unwrap_or("false"), err, "tag-settings.image-tag-enabled", "boolean"); + request.tag_settings.as_mut().unwrap().image_tag_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "tag-settings.image-tag-enabled", "boolean")); }, "id-dimension-value.kind" => { request_id_dimension_value_init(&mut request); @@ -10983,8 +11470,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -10993,10 +11479,10 @@ impl Engine { fn _floodlight_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FloodlightConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11016,9 +11502,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -11067,11 +11554,11 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "first-day-of-week" => { request_lookback_configuration_init(&mut request); @@ -11080,17 +11567,17 @@ impl Engine { "standard-variable-types" => { request_lookback_configuration_init(&mut request); if request.standard_variable_types.is_none() { - request.standard_variable_types = Some(Default::default()); + request.standard_variable_types = Some(Default::default()); } - request.standard_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.standard_variable_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "omniture-settings.omniture-cost-data-enabled" => { request_omniture_settings_init(&mut request); - request.omniture_settings.as_mut().unwrap().omniture_cost_data_enabled = arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-cost-data-enabled", "boolean"); + request.omniture_settings.as_mut().unwrap().omniture_cost_data_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-cost-data-enabled", "boolean")); }, "omniture-settings.omniture-integration-enabled" => { request_omniture_settings_init(&mut request); - request.omniture_settings.as_mut().unwrap().omniture_integration_enabled = arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-integration-enabled", "boolean"); + request.omniture_settings.as_mut().unwrap().omniture_integration_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "omniture-settings.omniture-integration-enabled", "boolean")); }, "subaccount-id" => { request_omniture_settings_init(&mut request); @@ -11102,11 +11589,11 @@ impl Engine { }, "tag-settings.dynamic-tag-enabled" => { request_tag_settings_init(&mut request); - request.tag_settings.as_mut().unwrap().dynamic_tag_enabled = arg_from_str(value.unwrap_or("false"), err, "tag-settings.dynamic-tag-enabled", "boolean"); + request.tag_settings.as_mut().unwrap().dynamic_tag_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "tag-settings.dynamic-tag-enabled", "boolean")); }, "tag-settings.image-tag-enabled" => { request_tag_settings_init(&mut request); - request.tag_settings.as_mut().unwrap().image_tag_enabled = arg_from_str(value.unwrap_or("false"), err, "tag-settings.image-tag-enabled", "boolean"); + request.tag_settings.as_mut().unwrap().image_tag_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "tag-settings.image-tag-enabled", "boolean")); }, "id-dimension-value.kind" => { request_id_dimension_value_init(&mut request); @@ -11185,8 +11672,117 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _inventory_items_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.inventory_items().get(&self.opt.arg_profile_id, &self.opt.arg_project_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); + 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 _inventory_items_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.inventory_items().list(&self.opt.arg_profile_id, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "in-plan" => { + call = call.in_plan(arg_from_str(value.unwrap_or("false"), err, "in-plan", "boolean")); + }, + "ids" => { + call = call.add_ids(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); + 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 } } @@ -11197,7 +11793,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.landing_pages().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11228,7 +11824,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -11239,7 +11834,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.landing_pages().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11271,8 +11866,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11281,10 +11875,10 @@ impl Engine { fn _landing_pages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LandingPage = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11304,9 +11898,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -11343,8 +11938,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11355,7 +11949,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.landing_pages().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11387,8 +11981,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11397,10 +11990,10 @@ impl Engine { fn _landing_pages_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LandingPage = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11420,9 +12013,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -11459,8 +12053,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11469,10 +12062,10 @@ impl Engine { fn _landing_pages_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LandingPage = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11492,9 +12085,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -11531,8 +12125,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11543,7 +12136,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.metros().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11575,8 +12168,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _mobile_carriers_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.mobile_carriers().get(&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); + 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 } } @@ -11587,7 +12222,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.mobile_carriers().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11619,8 +12254,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _operating_system_versions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.operating_system_versions().get(&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); + 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 } } @@ -11631,7 +12308,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operating_system_versions().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11663,8 +12340,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _operating_systems_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.operating_systems().get(&self.opt.arg_profile_id, &self.opt.arg_dart_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.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 } } @@ -11675,7 +12394,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operating_systems().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11707,8 +12426,227 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _order_documents_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.order_documents().get(&self.opt.arg_profile_id, &self.opt.arg_project_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); + 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 _order_documents_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.order_documents().list(&self.opt.arg_profile_id, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "order-id" => { + call = call.add_order_id(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "approved" => { + call = call.approved(arg_from_str(value.unwrap_or("false"), err, "approved", "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); + 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 _orders_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.orders().get(&self.opt.arg_profile_id, &self.opt.arg_project_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); + 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 _orders_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.orders().list(&self.opt.arg_profile_id, &self.opt.arg_project_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "site-id" => { + call = call.add_site_id(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(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")); + }, + "ids" => { + call = call.add_ids(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); + 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 } } @@ -11719,7 +12657,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placement_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11751,8 +12689,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -11761,10 +12698,10 @@ impl Engine { fn _placement_groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -11784,9 +12721,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -11930,27 +12868,33 @@ impl Engine { }, "programmatic-setting.trafficker-emails" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().trafficker_emails.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().trafficker_emails.is_none() { + request.programmatic_setting.as_mut().unwrap().trafficker_emails = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.programmatic" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().programmatic = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean"); + request.programmatic_setting.as_mut().unwrap().programmatic = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean")); }, "programmatic-setting.insertion-order-id" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().insertion_order_id = Some(value.unwrap_or("").to_string()); }, "programmatic-setting.insertion-order-id-status" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean"); + request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean")); }, "programmatic-setting.adx-deal-ids" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().adx_deal_ids.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().adx_deal_ids.is_none() { + request.programmatic_setting.as_mut().unwrap().adx_deal_ids = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().adx_deal_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.media-cost-nanos" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().media_cost_nanos = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().media_cost_nanos = Some(value.unwrap_or("").to_string()); }, "archived" => { request_programmatic_setting_init(&mut request); @@ -11959,9 +12903,9 @@ impl Engine { "child-placement-ids" => { request_programmatic_setting_init(&mut request); if request.child_placement_ids.is_none() { - request.child_placement_ids = Some(Default::default()); + request.child_placement_ids = Some(Default::default()); } - request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-category-id" => { request_programmatic_setting_init(&mut request); @@ -12045,7 +12989,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -12093,39 +13037,39 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -12144,8 +13088,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -12156,7 +13099,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placement_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -12233,8 +13176,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -12243,10 +13185,10 @@ impl Engine { fn _placement_groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -12266,9 +13208,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -12412,27 +13355,33 @@ impl Engine { }, "programmatic-setting.trafficker-emails" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().trafficker_emails.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().trafficker_emails.is_none() { + request.programmatic_setting.as_mut().unwrap().trafficker_emails = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.programmatic" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().programmatic = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean"); + request.programmatic_setting.as_mut().unwrap().programmatic = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean")); }, "programmatic-setting.insertion-order-id" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().insertion_order_id = Some(value.unwrap_or("").to_string()); }, "programmatic-setting.insertion-order-id-status" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean"); + request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean")); }, "programmatic-setting.adx-deal-ids" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().adx_deal_ids.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().adx_deal_ids.is_none() { + request.programmatic_setting.as_mut().unwrap().adx_deal_ids = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().adx_deal_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.media-cost-nanos" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().media_cost_nanos = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().media_cost_nanos = Some(value.unwrap_or("").to_string()); }, "archived" => { request_programmatic_setting_init(&mut request); @@ -12441,9 +13390,9 @@ impl Engine { "child-placement-ids" => { request_programmatic_setting_init(&mut request); if request.child_placement_ids.is_none() { - request.child_placement_ids = Some(Default::default()); + request.child_placement_ids = Some(Default::default()); } - request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-category-id" => { request_programmatic_setting_init(&mut request); @@ -12527,7 +13476,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -12575,39 +13524,39 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -12626,8 +13575,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -12636,10 +13584,10 @@ impl Engine { fn _placement_groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementGroup = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -12659,9 +13607,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -12805,27 +13754,33 @@ impl Engine { }, "programmatic-setting.trafficker-emails" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().trafficker_emails.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().trafficker_emails.is_none() { + request.programmatic_setting.as_mut().unwrap().trafficker_emails = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().trafficker_emails.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.programmatic" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().programmatic = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean"); + request.programmatic_setting.as_mut().unwrap().programmatic = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.programmatic", "boolean")); }, "programmatic-setting.insertion-order-id" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().insertion_order_id = Some(value.unwrap_or("").to_string()); }, "programmatic-setting.insertion-order-id-status" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean"); + request.programmatic_setting.as_mut().unwrap().insertion_order_id_status = Some(arg_from_str(value.unwrap_or("false"), err, "programmatic-setting.insertion-order-id-status", "boolean")); }, "programmatic-setting.adx-deal-ids" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().adx_deal_ids.push(value.unwrap_or("").to_string()); + if request.programmatic_setting.as_mut().unwrap().adx_deal_ids.is_none() { + request.programmatic_setting.as_mut().unwrap().adx_deal_ids = Some(Default::default()); + } + request.programmatic_setting.as_mut().unwrap().adx_deal_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "programmatic-setting.media-cost-nanos" => { request_programmatic_setting_init(&mut request); - request.programmatic_setting.as_mut().unwrap().media_cost_nanos = value.unwrap_or("").to_string(); + request.programmatic_setting.as_mut().unwrap().media_cost_nanos = Some(value.unwrap_or("").to_string()); }, "archived" => { request_programmatic_setting_init(&mut request); @@ -12834,9 +13789,9 @@ impl Engine { "child-placement-ids" => { request_programmatic_setting_init(&mut request); if request.child_placement_ids.is_none() { - request.child_placement_ids = Some(Default::default()); + request.child_placement_ids = Some(Default::default()); } - request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.child_placement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-category-id" => { request_programmatic_setting_init(&mut request); @@ -12920,7 +13875,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -12968,39 +13923,39 @@ impl Engine { }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -13019,8 +13974,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13031,7 +13985,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placement_strategies().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13062,7 +14016,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -13073,7 +14026,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placement_strategies().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13105,8 +14058,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13115,10 +14067,10 @@ impl Engine { fn _placement_strategies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementStrategy = Default::default(); + let mut request = api::PlacementStrategy::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13138,9 +14090,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -13174,8 +14127,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13186,7 +14138,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placement_strategies().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -13236,8 +14188,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13246,10 +14197,10 @@ impl Engine { fn _placement_strategies_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementStrategy = Default::default(); + let mut request = api::PlacementStrategy::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13269,9 +14220,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -13305,8 +14257,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13315,10 +14266,10 @@ impl Engine { fn _placement_strategies_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlacementStrategy = Default::default(); + let mut request = api::PlacementStrategy::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13338,9 +14289,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -13374,8 +14326,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13386,7 +14337,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placements().generatetags(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tag-formats" => { call = call.add_tag_formats(value.unwrap_or("")); @@ -13427,8 +14378,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13439,7 +14389,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placements().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13471,8 +14421,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13481,10 +14430,10 @@ impl Engine { fn _placements_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Placement = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -13504,9 +14453,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -13672,14 +14622,14 @@ impl Engine { }, "publisher-update-info.time" => { request_publisher_update_info_init(&mut request); - request.publisher_update_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.publisher_update_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "tag-formats" => { request_publisher_update_info_init(&mut request); if request.tag_formats.is_none() { - request.tag_formats = Some(Default::default()); + request.tag_formats = Some(Default::default()); } - request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "payment-approved" => { request_publisher_update_info_init(&mut request); @@ -13687,19 +14637,19 @@ impl Engine { }, "tag-setting.include-click-through-urls" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean")); }, "tag-setting.include-click-tracking" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean")); }, "tag-setting.additional-key-values" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().additional_key_values = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "tag-setting.keyword-option" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().keyword_option = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "content-category-id" => { request_tag_setting_init(&mut request); @@ -13795,7 +14745,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -13871,47 +14821,47 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -13930,8 +14880,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -13942,7 +14891,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.placements().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -14028,8 +14977,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -14038,10 +14986,10 @@ impl Engine { fn _placements_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Placement = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -14061,9 +15009,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -14229,14 +15178,14 @@ impl Engine { }, "publisher-update-info.time" => { request_publisher_update_info_init(&mut request); - request.publisher_update_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.publisher_update_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "tag-formats" => { request_publisher_update_info_init(&mut request); if request.tag_formats.is_none() { - request.tag_formats = Some(Default::default()); + request.tag_formats = Some(Default::default()); } - request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "payment-approved" => { request_publisher_update_info_init(&mut request); @@ -14244,19 +15193,19 @@ impl Engine { }, "tag-setting.include-click-through-urls" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean")); }, "tag-setting.include-click-tracking" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean")); }, "tag-setting.additional-key-values" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().additional_key_values = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "tag-setting.keyword-option" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().keyword_option = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "content-category-id" => { request_tag_setting_init(&mut request); @@ -14352,7 +15301,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -14428,47 +15377,47 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -14487,8 +15436,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -14497,10 +15445,10 @@ impl Engine { fn _placements_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Placement = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -14520,9 +15468,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -14688,14 +15637,14 @@ impl Engine { }, "publisher-update-info.time" => { request_publisher_update_info_init(&mut request); - request.publisher_update_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.publisher_update_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "tag-formats" => { request_publisher_update_info_init(&mut request); if request.tag_formats.is_none() { - request.tag_formats = Some(Default::default()); + request.tag_formats = Some(Default::default()); } - request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.tag_formats.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "payment-approved" => { request_publisher_update_info_init(&mut request); @@ -14703,19 +15652,19 @@ impl Engine { }, "tag-setting.include-click-through-urls" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-through-urls", "boolean")); }, "tag-setting.include-click-tracking" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean"); + request.tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "tag-setting.include-click-tracking", "boolean")); }, "tag-setting.additional-key-values" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().additional_key_values = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "tag-setting.keyword-option" => { request_tag_setting_init(&mut request); - request.tag_setting.as_mut().unwrap().keyword_option = value.unwrap_or("").to_string(); + request.tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "content-category-id" => { request_tag_setting_init(&mut request); @@ -14811,7 +15760,7 @@ impl Engine { }, "create-info.time" => { request_create_info_init(&mut request); - request.create_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.create_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "site-id" => { request_create_info_init(&mut request); @@ -14887,47 +15836,47 @@ impl Engine { }, "lookback-configuration.click-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().click_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.click-duration", "integer")); }, "lookback-configuration.post-impression-activities-duration" => { request_lookback_configuration_init(&mut request); - request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer"); + request.lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "lookback-configuration.post-impression-activities-duration", "integer")); }, "last-modified-info.time" => { request_last_modified_info_init(&mut request); - request.last_modified_info.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.last_modified_info.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.end-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.flighted" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().flighted = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean"); + request.pricing_schedule.as_mut().unwrap().flighted = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.flighted", "boolean")); }, "pricing-schedule.disregard-overdelivery" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean"); + request.pricing_schedule.as_mut().unwrap().disregard_overdelivery = Some(arg_from_str(value.unwrap_or("false"), err, "pricing-schedule.disregard-overdelivery", "boolean")); }, "pricing-schedule.pricing-type" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().pricing_type = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().pricing_type = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.cap-cost-option" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().cap_cost_option = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().cap_cost_option = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.testing-start-date" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().testing_start_date = value.unwrap_or("").to_string(); + request.pricing_schedule.as_mut().unwrap().testing_start_date = Some(value.unwrap_or("").to_string()); }, "pricing-schedule.floodlight-activity-id" => { request_pricing_schedule_init(&mut request); - request.pricing_schedule.as_mut().unwrap().floodlight_activity_id = value.unwrap_or("").to_string(); + 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()))); @@ -14946,8 +15895,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _platform_types_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.platform_types().get(&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); + 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 } } @@ -14958,7 +15949,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.platform_types().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -14990,8 +15981,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _postal_codes_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.postal_codes().get(&self.opt.arg_profile_id, &self.opt.arg_code); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => err.issues.push(CLIError::UnknownParameter(key.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 } } @@ -15002,7 +16035,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.postal_codes().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15034,8 +16067,114 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _projects_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.projects().get(&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); + 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 _projects_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.projects().list(&self.opt.arg_profile_id); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "search-string" => { + call = call.search_string(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")); + }, + "ids" => { + call = call.add_ids(value.unwrap_or("")); + }, + "advertiser-ids" => { + call = call.add_advertiser_ids(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); + 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 } } @@ -15046,7 +16185,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.regions().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15078,20 +16217,18 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } } } - fn _reports_compatible_fields_query(&self, dry_run: bool, err: &mut InvalidOptionsError) + fn _remarketing_list_shares_get(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Report = Default::default(); - let mut call = self.hub.reports().compatible_fields_query(&request, &self.opt.arg_profile_id); + let mut call = self.hub.remarketing_list_shares().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15111,18 +16248,783 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + 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 _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); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => 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); + 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); + 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 _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); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => 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); + 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 _remarketing_lists_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.remarketing_lists().get(&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); + 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 _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(); + 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_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()); + } + } + + fn request_list_population_rule_init(request: &mut api::RemarketingList) { + if request.list_population_rule.is_none() { + request.list_population_rule = Some(Default::default()); + } + } + + match &field_name.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()); + }, + "list-population-rule.floodlight-activity-id" => { + request_list_population_rule_init(&mut request); + request.list_population_rule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_list_population_rule_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "subaccount-id" => { + request_list_population_rule_init(&mut request); + request.subaccount_id = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request_list_population_rule_init(&mut request); + request.description = Some(value.unwrap_or("").to_string()); + }, + "list-size" => { + request_list_population_rule_init(&mut request); + request.list_size = Some(value.unwrap_or("").to_string()); + }, + "life-span" => { + request_list_population_rule_init(&mut request); + request.life_span = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_list_population_rule_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id" => { + request_list_population_rule_init(&mut request); + request.advertiser_id = Some(value.unwrap_or("").to_string()); + }, + "active" => { + request_list_population_rule_init(&mut request); + request.active = Some(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "advertiser-id-dimension-value.kind" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.value" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.dimension-name" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.etag" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.match-type" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.account_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "list-source" => { + request_advertiser_id_dimension_value_init(&mut request); + request.list_source = 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); + 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 _remarketing_lists_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.remarketing_lists().list(&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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "floodlight-activity-id" => { + call = call.floodlight_activity_id(value.unwrap_or("")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "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); + 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 _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(); + 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_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()); + } + } + + fn request_list_population_rule_init(request: &mut api::RemarketingList) { + if request.list_population_rule.is_none() { + request.list_population_rule = Some(Default::default()); + } + } + + match &field_name.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()); + }, + "list-population-rule.floodlight-activity-id" => { + request_list_population_rule_init(&mut request); + request.list_population_rule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_list_population_rule_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "subaccount-id" => { + request_list_population_rule_init(&mut request); + request.subaccount_id = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request_list_population_rule_init(&mut request); + request.description = Some(value.unwrap_or("").to_string()); + }, + "list-size" => { + request_list_population_rule_init(&mut request); + request.list_size = Some(value.unwrap_or("").to_string()); + }, + "life-span" => { + request_list_population_rule_init(&mut request); + request.life_span = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_list_population_rule_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id" => { + request_list_population_rule_init(&mut request); + request.advertiser_id = Some(value.unwrap_or("").to_string()); + }, + "active" => { + request_list_population_rule_init(&mut request); + request.active = Some(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "advertiser-id-dimension-value.kind" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.value" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.dimension-name" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.etag" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.match-type" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.account_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "list-source" => { + request_advertiser_id_dimension_value_init(&mut request); + request.list_source = 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); + 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 _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(); + 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_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()); + } + } + + fn request_list_population_rule_init(request: &mut api::RemarketingList) { + if request.list_population_rule.is_none() { + request.list_population_rule = Some(Default::default()); + } + } + + match &field_name.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()); + }, + "list-population-rule.floodlight-activity-id" => { + request_list_population_rule_init(&mut request); + request.list_population_rule.as_mut().unwrap().floodlight_activity_id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_list_population_rule_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "subaccount-id" => { + request_list_population_rule_init(&mut request); + request.subaccount_id = Some(value.unwrap_or("").to_string()); + }, + "description" => { + request_list_population_rule_init(&mut request); + request.description = Some(value.unwrap_or("").to_string()); + }, + "list-size" => { + request_list_population_rule_init(&mut request); + request.list_size = Some(value.unwrap_or("").to_string()); + }, + "life-span" => { + request_list_population_rule_init(&mut request); + request.life_span = Some(value.unwrap_or("").to_string()); + }, + "name" => { + request_list_population_rule_init(&mut request); + request.name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id" => { + request_list_population_rule_init(&mut request); + request.advertiser_id = Some(value.unwrap_or("").to_string()); + }, + "active" => { + request_list_population_rule_init(&mut request); + request.active = Some(arg_from_str(value.unwrap_or("false"), err, "active", "boolean")); + }, + "advertiser-id-dimension-value.kind" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.value" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.dimension-name" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.etag" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.match-type" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); + }, + "advertiser-id-dimension-value.id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.advertiser_id_dimension_value.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "account-id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.account_id = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_advertiser_id_dimension_value_init(&mut request); + request.id = Some(value.unwrap_or("").to_string()); + }, + "list-source" => { + request_advertiser_id_dimension_value_init(&mut request); + request.list_source = 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); + 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); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "alt" + |"fields" + |"key" + |"oauth-token" + |"pretty-print" + |"quota-user" + |"user-ip" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => 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_criteria_activities_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().activities.is_none() { + request.criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_criteria_date_range_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().date_range.is_none() { + request.criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_criteria_init(request: &mut api::Report) { if request.criteria.is_none() { request.criteria = Some(Default::default()); } } + fn request_cross_dimension_reach_criteria_date_range_init(request: &mut api::Report) { + request_cross_dimension_reach_criteria_init(request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_cross_dimension_reach_criteria_init(request: &mut api::Report) { if request.cross_dimension_reach_criteria.is_none() { request.cross_dimension_reach_criteria = Some(Default::default()); @@ -15135,18 +17037,81 @@ impl Engine { } } + fn request_floodlight_criteria_date_range_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().date_range.is_none() { + request.floodlight_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_floodlight_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_floodlight_criteria_init(request: &mut api::Report) { if request.floodlight_criteria.is_none() { request.floodlight_criteria = Some(Default::default()); } } + fn request_floodlight_criteria_report_properties_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().report_properties.is_none() { + request.floodlight_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_date_range_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().date_range.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_path_to_conversion_criteria_init(request: &mut api::Report) { if request.path_to_conversion_criteria.is_none() { request.path_to_conversion_criteria = Some(Default::default()); } } + fn request_path_to_conversion_criteria_report_properties_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().report_properties.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_reach_criteria_activities_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().activities.is_none() { + request.reach_criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_reach_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.reach_criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_reach_criteria_date_range_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().date_range.is_none() { + request.reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_reach_criteria_init(request: &mut api::Report) { if request.reach_criteria.is_none() { request.reach_criteria = Some(Default::default()); @@ -15161,36 +17126,42 @@ impl Engine { match &field_name.to_string()[..] { "criteria.activities.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_criteria_activities_init(&mut request); + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.activities.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_criteria_activities_init(&mut request); + if request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "criteria.date-range.start-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.end-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.relative-date-range" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "criteria.custom-rich-media-events.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_criteria_custom_rich_media_events_init(&mut request); + request.criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_criteria_custom_rich_media_events_init(&mut request); + if request.criteria.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_criteria_init(&mut request); @@ -15206,155 +17177,170 @@ impl Engine { }, "schedule.start-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "schedule.runs-on-day-of-month" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().runs_on_day_of_month = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().runs_on_day_of_month = Some(value.unwrap_or("").to_string()); }, "schedule.every" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().every = arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer"); + request.schedule.as_mut().unwrap().every = Some(arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer")); }, "schedule.expiration-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().expiration_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().expiration_date = Some(value.unwrap_or("").to_string()); }, "schedule.active" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().active = arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean"); + request.schedule.as_mut().unwrap().active = Some(arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean")); }, "schedule.repeats" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().repeats = Some(value.unwrap_or("").to_string()); }, "schedule.repeats-on-week-days" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats_on_week_days.push(value.unwrap_or("").to_string()); + if request.schedule.as_mut().unwrap().repeats_on_week_days.is_none() { + request.schedule.as_mut().unwrap().repeats_on_week_days = Some(Default::default()); + } + request.schedule.as_mut().unwrap().repeats_on_week_days.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.start-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.end-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.relative-date-range" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.value" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.dimension-name" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.etag" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.match-type" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.id" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.report-properties.clicks-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.clicks_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().clicks_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.pivot_on_interaction_path = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().pivot_on_interaction_path = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean")); }, "path-to-conversion-criteria.report-properties.impressions-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.impressions_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().impressions_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_interaction_gap = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_interaction_gap = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer")); }, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-click-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_click_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_click_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer")); }, "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_impression_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_impression_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer")); }, "path-to-conversion-criteria.metric-names" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_report_properties_init(&mut request); + if request.path_to_conversion_criteria.as_mut().unwrap().metric_names.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.path_to_conversion_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request_path_to_conversion_criteria_init(&mut request); request.format = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_reach_criteria_activities_init(&mut request); + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.start-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.end-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.relative-date-range" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "reach-criteria.reach-by-frequency-metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_date_range_init(&mut request); + if request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.custom-rich-media-events.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.enable-all-dimension-combinations" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean"); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = Some(arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean")); }, "file-name" => { request_reach_criteria_init(&mut request); @@ -15362,15 +17348,15 @@ impl Engine { }, "delivery.message" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().message = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().message = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner-delivery-type" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner_delivery_type = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().email_owner_delivery_type = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner = arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean"); + request.delivery.as_mut().unwrap().email_owner = Some(arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean")); }, "etag" => { request_delivery_init(&mut request); @@ -15397,92 +17383,101 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.start-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.end-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.relative-date-range" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.value" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.dimension-name" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.etag" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.match-type" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.id" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-attributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "floodlight-criteria.metric-names" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_floodlight_criteria_report_properties_init(&mut request); + if request.floodlight_criteria.as_mut().unwrap().metric_names.is_none() { + request.floodlight_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.floodlight_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.pivoted" => { request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean"); + request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = Some(arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean")); }, "cross-dimension-reach-criteria.date-range.start-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.kind" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.end-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.relative-date-range" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.dimension" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.overlap-metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names = Some(Default::default()); + } + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + 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()))); @@ -15501,8 +17496,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -15513,7 +17507,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15544,7 +17538,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -15556,7 +17549,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.reports().files_get(&self.opt.arg_profile_id, &self.opt.arg_report_id, &self.opt.arg_file_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15591,9 +17584,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -15607,7 +17599,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().files_list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -15651,8 +17643,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -15663,7 +17654,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15695,8 +17686,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -15705,10 +17695,10 @@ impl Engine { fn _reports_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Report = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -15728,18 +17718,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_criteria_activities_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().activities.is_none() { + request.criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_criteria_date_range_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().date_range.is_none() { + request.criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_criteria_init(request: &mut api::Report) { if request.criteria.is_none() { request.criteria = Some(Default::default()); } } + fn request_cross_dimension_reach_criteria_date_range_init(request: &mut api::Report) { + request_cross_dimension_reach_criteria_init(request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_cross_dimension_reach_criteria_init(request: &mut api::Report) { if request.cross_dimension_reach_criteria.is_none() { request.cross_dimension_reach_criteria = Some(Default::default()); @@ -15752,18 +17771,81 @@ impl Engine { } } + fn request_floodlight_criteria_date_range_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().date_range.is_none() { + request.floodlight_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_floodlight_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_floodlight_criteria_init(request: &mut api::Report) { if request.floodlight_criteria.is_none() { request.floodlight_criteria = Some(Default::default()); } } + fn request_floodlight_criteria_report_properties_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().report_properties.is_none() { + request.floodlight_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_date_range_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().date_range.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_path_to_conversion_criteria_init(request: &mut api::Report) { if request.path_to_conversion_criteria.is_none() { request.path_to_conversion_criteria = Some(Default::default()); } } + fn request_path_to_conversion_criteria_report_properties_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().report_properties.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_reach_criteria_activities_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().activities.is_none() { + request.reach_criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_reach_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.reach_criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_reach_criteria_date_range_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().date_range.is_none() { + request.reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_reach_criteria_init(request: &mut api::Report) { if request.reach_criteria.is_none() { request.reach_criteria = Some(Default::default()); @@ -15778,36 +17860,42 @@ impl Engine { match &field_name.to_string()[..] { "criteria.activities.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_criteria_activities_init(&mut request); + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.activities.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_criteria_activities_init(&mut request); + if request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "criteria.date-range.start-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.end-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.relative-date-range" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "criteria.custom-rich-media-events.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_criteria_custom_rich_media_events_init(&mut request); + request.criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_criteria_custom_rich_media_events_init(&mut request); + if request.criteria.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_criteria_init(&mut request); @@ -15823,155 +17911,170 @@ impl Engine { }, "schedule.start-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "schedule.runs-on-day-of-month" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().runs_on_day_of_month = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().runs_on_day_of_month = Some(value.unwrap_or("").to_string()); }, "schedule.every" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().every = arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer"); + request.schedule.as_mut().unwrap().every = Some(arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer")); }, "schedule.expiration-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().expiration_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().expiration_date = Some(value.unwrap_or("").to_string()); }, "schedule.active" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().active = arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean"); + request.schedule.as_mut().unwrap().active = Some(arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean")); }, "schedule.repeats" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().repeats = Some(value.unwrap_or("").to_string()); }, "schedule.repeats-on-week-days" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats_on_week_days.push(value.unwrap_or("").to_string()); + if request.schedule.as_mut().unwrap().repeats_on_week_days.is_none() { + request.schedule.as_mut().unwrap().repeats_on_week_days = Some(Default::default()); + } + request.schedule.as_mut().unwrap().repeats_on_week_days.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.start-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.end-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.relative-date-range" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.value" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.dimension-name" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.etag" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.match-type" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.id" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.report-properties.clicks-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.clicks_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().clicks_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.pivot_on_interaction_path = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().pivot_on_interaction_path = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean")); }, "path-to-conversion-criteria.report-properties.impressions-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.impressions_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().impressions_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_interaction_gap = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_interaction_gap = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer")); }, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-click-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_click_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_click_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer")); }, "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_impression_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_impression_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer")); }, "path-to-conversion-criteria.metric-names" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_report_properties_init(&mut request); + if request.path_to_conversion_criteria.as_mut().unwrap().metric_names.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.path_to_conversion_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request_path_to_conversion_criteria_init(&mut request); request.format = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_reach_criteria_activities_init(&mut request); + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.start-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.end-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.relative-date-range" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "reach-criteria.reach-by-frequency-metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_date_range_init(&mut request); + if request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.custom-rich-media-events.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.enable-all-dimension-combinations" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean"); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = Some(arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean")); }, "file-name" => { request_reach_criteria_init(&mut request); @@ -15979,15 +18082,15 @@ impl Engine { }, "delivery.message" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().message = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().message = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner-delivery-type" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner_delivery_type = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().email_owner_delivery_type = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner = arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean"); + request.delivery.as_mut().unwrap().email_owner = Some(arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean")); }, "etag" => { request_delivery_init(&mut request); @@ -16014,92 +18117,101 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.start-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.end-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.relative-date-range" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.value" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.dimension-name" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.etag" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.match-type" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.id" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-attributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "floodlight-criteria.metric-names" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_floodlight_criteria_report_properties_init(&mut request); + if request.floodlight_criteria.as_mut().unwrap().metric_names.is_none() { + request.floodlight_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.floodlight_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.pivoted" => { request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean"); + request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = Some(arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean")); }, "cross-dimension-reach-criteria.date-range.start-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.kind" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.end-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.relative-date-range" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.dimension" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.overlap-metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names = Some(Default::default()); + } + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + 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()))); @@ -16118,8 +18230,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -16130,7 +18241,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -16177,8 +18288,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -16187,10 +18297,10 @@ impl Engine { fn _reports_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Report = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -16210,18 +18320,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_criteria_activities_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().activities.is_none() { + request.criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_criteria_date_range_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().date_range.is_none() { + request.criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_criteria_init(request: &mut api::Report) { if request.criteria.is_none() { request.criteria = Some(Default::default()); } } + fn request_cross_dimension_reach_criteria_date_range_init(request: &mut api::Report) { + request_cross_dimension_reach_criteria_init(request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_cross_dimension_reach_criteria_init(request: &mut api::Report) { if request.cross_dimension_reach_criteria.is_none() { request.cross_dimension_reach_criteria = Some(Default::default()); @@ -16234,18 +18373,81 @@ impl Engine { } } + fn request_floodlight_criteria_date_range_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().date_range.is_none() { + request.floodlight_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_floodlight_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_floodlight_criteria_init(request: &mut api::Report) { if request.floodlight_criteria.is_none() { request.floodlight_criteria = Some(Default::default()); } } + fn request_floodlight_criteria_report_properties_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().report_properties.is_none() { + request.floodlight_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_date_range_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().date_range.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_path_to_conversion_criteria_init(request: &mut api::Report) { if request.path_to_conversion_criteria.is_none() { request.path_to_conversion_criteria = Some(Default::default()); } } + fn request_path_to_conversion_criteria_report_properties_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().report_properties.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_reach_criteria_activities_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().activities.is_none() { + request.reach_criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_reach_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.reach_criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_reach_criteria_date_range_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().date_range.is_none() { + request.reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_reach_criteria_init(request: &mut api::Report) { if request.reach_criteria.is_none() { request.reach_criteria = Some(Default::default()); @@ -16260,36 +18462,42 @@ impl Engine { match &field_name.to_string()[..] { "criteria.activities.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_criteria_activities_init(&mut request); + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.activities.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_criteria_activities_init(&mut request); + if request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "criteria.date-range.start-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.end-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.relative-date-range" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "criteria.custom-rich-media-events.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_criteria_custom_rich_media_events_init(&mut request); + request.criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_criteria_custom_rich_media_events_init(&mut request); + if request.criteria.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_criteria_init(&mut request); @@ -16305,155 +18513,170 @@ impl Engine { }, "schedule.start-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "schedule.runs-on-day-of-month" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().runs_on_day_of_month = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().runs_on_day_of_month = Some(value.unwrap_or("").to_string()); }, "schedule.every" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().every = arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer"); + request.schedule.as_mut().unwrap().every = Some(arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer")); }, "schedule.expiration-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().expiration_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().expiration_date = Some(value.unwrap_or("").to_string()); }, "schedule.active" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().active = arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean"); + request.schedule.as_mut().unwrap().active = Some(arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean")); }, "schedule.repeats" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().repeats = Some(value.unwrap_or("").to_string()); }, "schedule.repeats-on-week-days" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats_on_week_days.push(value.unwrap_or("").to_string()); + if request.schedule.as_mut().unwrap().repeats_on_week_days.is_none() { + request.schedule.as_mut().unwrap().repeats_on_week_days = Some(Default::default()); + } + request.schedule.as_mut().unwrap().repeats_on_week_days.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.start-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.end-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.relative-date-range" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.value" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.dimension-name" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.etag" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.match-type" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.id" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.report-properties.clicks-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.clicks_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().clicks_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.pivot_on_interaction_path = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().pivot_on_interaction_path = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean")); }, "path-to-conversion-criteria.report-properties.impressions-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.impressions_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().impressions_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_interaction_gap = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_interaction_gap = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer")); }, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-click-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_click_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_click_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer")); }, "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_impression_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_impression_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer")); }, "path-to-conversion-criteria.metric-names" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_report_properties_init(&mut request); + if request.path_to_conversion_criteria.as_mut().unwrap().metric_names.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.path_to_conversion_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request_path_to_conversion_criteria_init(&mut request); request.format = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_reach_criteria_activities_init(&mut request); + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.start-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.end-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.relative-date-range" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "reach-criteria.reach-by-frequency-metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_date_range_init(&mut request); + if request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.custom-rich-media-events.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.enable-all-dimension-combinations" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean"); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = Some(arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean")); }, "file-name" => { request_reach_criteria_init(&mut request); @@ -16461,15 +18684,15 @@ impl Engine { }, "delivery.message" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().message = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().message = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner-delivery-type" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner_delivery_type = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().email_owner_delivery_type = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner = arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean"); + request.delivery.as_mut().unwrap().email_owner = Some(arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean")); }, "etag" => { request_delivery_init(&mut request); @@ -16496,92 +18719,101 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.start-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.end-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.relative-date-range" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.value" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.dimension-name" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.etag" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.match-type" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.id" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-attributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "floodlight-criteria.metric-names" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_floodlight_criteria_report_properties_init(&mut request); + if request.floodlight_criteria.as_mut().unwrap().metric_names.is_none() { + request.floodlight_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.floodlight_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.pivoted" => { request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean"); + request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = Some(arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean")); }, "cross-dimension-reach-criteria.date-range.start-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.kind" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.end-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.relative-date-range" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.dimension" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.overlap-metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names = Some(Default::default()); + } + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + 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()))); @@ -16600,8 +18832,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -16612,7 +18843,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().run(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "synchronous" => { call = call.synchronous(arg_from_str(value.unwrap_or("false"), err, "synchronous", "boolean")); @@ -16647,8 +18878,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -16657,10 +18887,10 @@ impl Engine { fn _reports_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Report = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -16680,18 +18910,47 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_criteria_activities_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().activities.is_none() { + request.criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_criteria_date_range_init(request: &mut api::Report) { + request_criteria_init(request); + if request.criteria.as_mut().unwrap().date_range.is_none() { + request.criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_criteria_init(request: &mut api::Report) { if request.criteria.is_none() { request.criteria = Some(Default::default()); } } + fn request_cross_dimension_reach_criteria_date_range_init(request: &mut api::Report) { + request_cross_dimension_reach_criteria_init(request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_cross_dimension_reach_criteria_init(request: &mut api::Report) { if request.cross_dimension_reach_criteria.is_none() { request.cross_dimension_reach_criteria = Some(Default::default()); @@ -16704,18 +18963,81 @@ impl Engine { } } + fn request_floodlight_criteria_date_range_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().date_range.is_none() { + request.floodlight_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_floodlight_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_floodlight_criteria_init(request: &mut api::Report) { if request.floodlight_criteria.is_none() { request.floodlight_criteria = Some(Default::default()); } } + fn request_floodlight_criteria_report_properties_init(request: &mut api::Report) { + request_floodlight_criteria_init(request); + if request.floodlight_criteria.as_mut().unwrap().report_properties.is_none() { + request.floodlight_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_date_range_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().date_range.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + + fn request_path_to_conversion_criteria_floodlight_config_id_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id = Some(Default::default()); + } + } + fn request_path_to_conversion_criteria_init(request: &mut api::Report) { if request.path_to_conversion_criteria.is_none() { request.path_to_conversion_criteria = Some(Default::default()); } } + fn request_path_to_conversion_criteria_report_properties_init(request: &mut api::Report) { + request_path_to_conversion_criteria_init(request); + if request.path_to_conversion_criteria.as_mut().unwrap().report_properties.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().report_properties = Some(Default::default()); + } + } + + fn request_reach_criteria_activities_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().activities.is_none() { + request.reach_criteria.as_mut().unwrap().activities = Some(Default::default()); + } + } + + fn request_reach_criteria_custom_rich_media_events_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().custom_rich_media_events.is_none() { + request.reach_criteria.as_mut().unwrap().custom_rich_media_events = Some(Default::default()); + } + } + + fn request_reach_criteria_date_range_init(request: &mut api::Report) { + request_reach_criteria_init(request); + if request.reach_criteria.as_mut().unwrap().date_range.is_none() { + request.reach_criteria.as_mut().unwrap().date_range = Some(Default::default()); + } + } + fn request_reach_criteria_init(request: &mut api::Report) { if request.reach_criteria.is_none() { request.reach_criteria = Some(Default::default()); @@ -16730,36 +19052,42 @@ impl Engine { match &field_name.to_string()[..] { "criteria.activities.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_criteria_activities_init(&mut request); + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.activities.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_criteria_activities_init(&mut request); + if request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "criteria.date-range.start-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.end-date" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "criteria.date-range.relative-date-range" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_criteria_date_range_init(&mut request); + request.criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "criteria.custom-rich-media-events.kind" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_criteria_custom_rich_media_events_init(&mut request); + request.criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "criteria.metric-names" => { - request_criteria_init(&mut request); - request.criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_criteria_custom_rich_media_events_init(&mut request); + if request.criteria.as_mut().unwrap().metric_names.is_none() { + request.criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_criteria_init(&mut request); @@ -16775,155 +19103,170 @@ impl Engine { }, "schedule.start-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "schedule.runs-on-day-of-month" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().runs_on_day_of_month = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().runs_on_day_of_month = Some(value.unwrap_or("").to_string()); }, "schedule.every" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().every = arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer"); + request.schedule.as_mut().unwrap().every = Some(arg_from_str(value.unwrap_or("-0"), err, "schedule.every", "integer")); }, "schedule.expiration-date" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().expiration_date = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().expiration_date = Some(value.unwrap_or("").to_string()); }, "schedule.active" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().active = arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean"); + request.schedule.as_mut().unwrap().active = Some(arg_from_str(value.unwrap_or("false"), err, "schedule.active", "boolean")); }, "schedule.repeats" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().repeats = Some(value.unwrap_or("").to_string()); }, "schedule.repeats-on-week-days" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().repeats_on_week_days.push(value.unwrap_or("").to_string()); + if request.schedule.as_mut().unwrap().repeats_on_week_days.is_none() { + request.schedule.as_mut().unwrap().repeats_on_week_days = Some(Default::default()); + } + request.schedule.as_mut().unwrap().repeats_on_week_days.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.start-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.end-date" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.date-range.relative-date-range" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_path_to_conversion_criteria_date_range_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.kind" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.value" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.dimension-name" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.etag" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.match-type" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.floodlight-config-id.id" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_floodlight_config_id_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "path-to-conversion-criteria.report-properties.clicks-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.clicks_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().clicks_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.clicks-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.pivot_on_interaction_path = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().pivot_on_interaction_path = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.pivot-on-interaction-path", "boolean")); }, "path-to-conversion-criteria.report-properties.impressions-lookback-window" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.impressions_lookback_window = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().impressions_lookback_window = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.impressions-lookback-window", "integer")); }, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-interaction-gap" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_interaction_gap = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_interaction_gap = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-interaction-gap", "integer")); }, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "path-to-conversion-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "path-to-conversion-criteria.report-properties.maximum-click-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_click_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_click_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-click-interactions", "integer")); }, "path-to-conversion-criteria.report-properties.maximum-impression-interactions" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().report_properties.maximum_impression_interactions = arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer"); + request_path_to_conversion_criteria_report_properties_init(&mut request); + request.path_to_conversion_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().maximum_impression_interactions = Some(arg_from_str(value.unwrap_or("-0"), err, "path-to-conversion-criteria.report-properties.maximum-impression-interactions", "integer")); }, "path-to-conversion-criteria.metric-names" => { - request_path_to_conversion_criteria_init(&mut request); - request.path_to_conversion_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_path_to_conversion_criteria_report_properties_init(&mut request); + if request.path_to_conversion_criteria.as_mut().unwrap().metric_names.is_none() { + request.path_to_conversion_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.path_to_conversion_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request_path_to_conversion_criteria_init(&mut request); request.format = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.kind = value.unwrap_or("").to_string(); + request_reach_criteria_activities_init(&mut request); + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.activities.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().activities.metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().activities.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_activities_init(&mut request); + if request.reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.start-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.end-date" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "reach-criteria.date-range.relative-date-range" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_reach_criteria_date_range_init(&mut request); + request.reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "reach-criteria.reach-by-frequency-metric-names" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.push(value.unwrap_or("").to_string()); + request_reach_criteria_date_range_init(&mut request); + if request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.is_none() { + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names = Some(Default::default()); + } + request.reach_criteria.as_mut().unwrap().reach_by_frequency_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reach-criteria.custom-rich-media-events.kind" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().custom_rich_media_events.kind = value.unwrap_or("").to_string(); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().custom_rich_media_events.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "reach-criteria.enable-all-dimension-combinations" => { - request_reach_criteria_init(&mut request); - request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean"); + request_reach_criteria_custom_rich_media_events_init(&mut request); + request.reach_criteria.as_mut().unwrap().enable_all_dimension_combinations = Some(arg_from_str(value.unwrap_or("false"), err, "reach-criteria.enable-all-dimension-combinations", "boolean")); }, "file-name" => { request_reach_criteria_init(&mut request); @@ -16931,15 +19274,15 @@ impl Engine { }, "delivery.message" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().message = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().message = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner-delivery-type" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner_delivery_type = value.unwrap_or("").to_string(); + request.delivery.as_mut().unwrap().email_owner_delivery_type = Some(value.unwrap_or("").to_string()); }, "delivery.email-owner" => { request_delivery_init(&mut request); - request.delivery.as_mut().unwrap().email_owner = arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean"); + request.delivery.as_mut().unwrap().email_owner = Some(arg_from_str(value.unwrap_or("false"), err, "delivery.email-owner", "boolean")); }, "etag" => { request_delivery_init(&mut request); @@ -16966,92 +19309,101 @@ impl Engine { request.type_ = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.start-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.end-date" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.date-range.relative-date-range" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_floodlight_criteria_date_range_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.kind" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.kind = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.value" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.value = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.dimension-name" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.dimension_name = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().dimension_name = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.etag" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.etag = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.match-type" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.match_type = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().match_type = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.floodlight-config-id.id" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.id = Some(value.unwrap_or("").to_string()); + request_floodlight_criteria_floodlight_config_id_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().floodlight_config_id.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "floodlight-criteria.report-properties.include-unattributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-ip-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_unattributed_cookie_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_unattributed_cookie_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-unattributed-cookie-conversions", "boolean")); }, "floodlight-criteria.report-properties.include-attributed-ip-conversions" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().report_properties.include_attributed_ip_conversions = arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean"); + request_floodlight_criteria_report_properties_init(&mut request); + request.floodlight_criteria.as_mut().unwrap().report_properties.as_mut().unwrap().include_attributed_ip_conversions = Some(arg_from_str(value.unwrap_or("false"), err, "floodlight-criteria.report-properties.include-attributed-ip-conversions", "boolean")); }, "floodlight-criteria.metric-names" => { - request_floodlight_criteria_init(&mut request); - request.floodlight_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_floodlight_criteria_report_properties_init(&mut request); + if request.floodlight_criteria.as_mut().unwrap().metric_names.is_none() { + request.floodlight_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + request.floodlight_criteria.as_mut().unwrap().metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.pivoted" => { request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean"); + request.cross_dimension_reach_criteria.as_mut().unwrap().pivoted = Some(arg_from_str(value.unwrap_or("false"), err, "cross-dimension-reach-criteria.pivoted", "boolean")); }, "cross-dimension-reach-criteria.date-range.start-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.start_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.kind" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.kind = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.end-date" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.end_date = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.date-range.relative-date-range" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.relative_date_range = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().date_range.as_mut().unwrap().relative_date_range = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.dimension" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + request.cross_dimension_reach_criteria.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.overlap-metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names = Some(Default::default()); + } + request.cross_dimension_reach_criteria.as_mut().unwrap().overlap_metric_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "cross-dimension-reach-criteria.metric-names" => { - request_cross_dimension_reach_criteria_init(&mut request); - request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.push(value.unwrap_or("").to_string()); + request_cross_dimension_reach_criteria_date_range_init(&mut request); + if request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names.is_none() { + request.cross_dimension_reach_criteria.as_mut().unwrap().metric_names = Some(Default::default()); + } + 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()))); @@ -17070,8 +19422,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17082,7 +19433,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17114,8 +19465,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17124,10 +19474,10 @@ impl Engine { fn _sites_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Site = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17147,9 +19497,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -17165,12 +19516,33 @@ impl Engine { } } + fn request_site_settings_creative_settings_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().creative_settings.is_none() { + request.site_settings.as_mut().unwrap().creative_settings = Some(Default::default()); + } + } + fn request_site_settings_init(request: &mut api::Site) { if request.site_settings.is_none() { request.site_settings = Some(Default::default()); } } + fn request_site_settings_lookback_configuration_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().lookback_configuration.is_none() { + request.site_settings.as_mut().unwrap().lookback_configuration = Some(Default::default()); + } + } + + fn request_site_settings_tag_setting_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().tag_setting.is_none() { + request.site_settings.as_mut().unwrap().tag_setting = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -17207,47 +19579,47 @@ impl Engine { }, "site-settings.disable-brand-safe-ads" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_brand_safe_ads = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean"); + request.site_settings.as_mut().unwrap().disable_brand_safe_ads = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean")); }, "site-settings.active-view-opt-out" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().active_view_opt_out = arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean"); + request.site_settings.as_mut().unwrap().active_view_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean")); }, "site-settings.lookback-configuration.click-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.click_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer")); }, "site-settings.lookback-configuration.post-impression-activities-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer")); }, "site-settings.disable-new-cookie" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_new_cookie = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().disable_new_cookie = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean")); }, "site-settings.tag-setting.include-click-through-urls" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean")); }, "site-settings.tag-setting.include-click-tracking" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean")); }, "site-settings.tag-setting.additional-key-values" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.additional_key_values = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "site-settings.tag-setting.keyword-option" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.keyword_option = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-header" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_header = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_header = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-footer" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_footer = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_footer = Some(value.unwrap_or("").to_string()); }, "approved" => { request_site_settings_init(&mut request); @@ -17310,8 +19682,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17322,7 +19693,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "unmapped-site" => { call = call.unmapped_site(arg_from_str(value.unwrap_or("false"), err, "unmapped-site", "boolean")); @@ -17399,8 +19770,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17409,10 +19779,10 @@ impl Engine { fn _sites_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Site = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17432,9 +19802,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -17450,12 +19821,33 @@ impl Engine { } } + fn request_site_settings_creative_settings_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().creative_settings.is_none() { + request.site_settings.as_mut().unwrap().creative_settings = Some(Default::default()); + } + } + fn request_site_settings_init(request: &mut api::Site) { if request.site_settings.is_none() { request.site_settings = Some(Default::default()); } } + fn request_site_settings_lookback_configuration_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().lookback_configuration.is_none() { + request.site_settings.as_mut().unwrap().lookback_configuration = Some(Default::default()); + } + } + + fn request_site_settings_tag_setting_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().tag_setting.is_none() { + request.site_settings.as_mut().unwrap().tag_setting = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -17492,47 +19884,47 @@ impl Engine { }, "site-settings.disable-brand-safe-ads" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_brand_safe_ads = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean"); + request.site_settings.as_mut().unwrap().disable_brand_safe_ads = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean")); }, "site-settings.active-view-opt-out" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().active_view_opt_out = arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean"); + request.site_settings.as_mut().unwrap().active_view_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean")); }, "site-settings.lookback-configuration.click-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.click_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer")); }, "site-settings.lookback-configuration.post-impression-activities-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer")); }, "site-settings.disable-new-cookie" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_new_cookie = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().disable_new_cookie = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean")); }, "site-settings.tag-setting.include-click-through-urls" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean")); }, "site-settings.tag-setting.include-click-tracking" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean")); }, "site-settings.tag-setting.additional-key-values" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.additional_key_values = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "site-settings.tag-setting.keyword-option" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.keyword_option = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-header" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_header = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_header = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-footer" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_footer = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_footer = Some(value.unwrap_or("").to_string()); }, "approved" => { request_site_settings_init(&mut request); @@ -17595,8 +19987,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17605,10 +19996,10 @@ impl Engine { fn _sites_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Site = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17628,9 +20019,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -17646,12 +20038,33 @@ impl Engine { } } + fn request_site_settings_creative_settings_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().creative_settings.is_none() { + request.site_settings.as_mut().unwrap().creative_settings = Some(Default::default()); + } + } + fn request_site_settings_init(request: &mut api::Site) { if request.site_settings.is_none() { request.site_settings = Some(Default::default()); } } + fn request_site_settings_lookback_configuration_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().lookback_configuration.is_none() { + request.site_settings.as_mut().unwrap().lookback_configuration = Some(Default::default()); + } + } + + fn request_site_settings_tag_setting_init(request: &mut api::Site) { + request_site_settings_init(request); + if request.site_settings.as_mut().unwrap().tag_setting.is_none() { + request.site_settings.as_mut().unwrap().tag_setting = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -17688,47 +20101,47 @@ impl Engine { }, "site-settings.disable-brand-safe-ads" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_brand_safe_ads = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean"); + request.site_settings.as_mut().unwrap().disable_brand_safe_ads = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-brand-safe-ads", "boolean")); }, "site-settings.active-view-opt-out" => { request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().active_view_opt_out = arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean"); + request.site_settings.as_mut().unwrap().active_view_opt_out = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.active-view-opt-out", "boolean")); }, "site-settings.lookback-configuration.click-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.click_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().click_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.click-duration", "integer")); }, "site-settings.lookback-configuration.post-impression-activities-duration" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().lookback_configuration.post_impression_activities_duration = arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().lookback_configuration.as_mut().unwrap().post_impression_activities_duration = Some(arg_from_str(value.unwrap_or("-0"), err, "site-settings.lookback-configuration.post-impression-activities-duration", "integer")); }, "site-settings.disable-new-cookie" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().disable_new_cookie = arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean"); + request_site_settings_lookback_configuration_init(&mut request); + request.site_settings.as_mut().unwrap().disable_new_cookie = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.disable-new-cookie", "boolean")); }, "site-settings.tag-setting.include-click-through-urls" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_through_urls = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_through_urls = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-through-urls", "boolean")); }, "site-settings.tag-setting.include-click-tracking" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.include_click_tracking = arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean"); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().include_click_tracking = Some(arg_from_str(value.unwrap_or("false"), err, "site-settings.tag-setting.include-click-tracking", "boolean")); }, "site-settings.tag-setting.additional-key-values" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.additional_key_values = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().additional_key_values = Some(value.unwrap_or("").to_string()); }, "site-settings.tag-setting.keyword-option" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().tag_setting.keyword_option = value.unwrap_or("").to_string(); + request_site_settings_tag_setting_init(&mut request); + request.site_settings.as_mut().unwrap().tag_setting.as_mut().unwrap().keyword_option = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-header" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_header = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_header = Some(value.unwrap_or("").to_string()); }, "site-settings.creative-settings.i-frame-footer" => { - request_site_settings_init(&mut request); - request.site_settings.as_mut().unwrap().creative_settings.i_frame_footer = value.unwrap_or("").to_string(); + request_site_settings_creative_settings_init(&mut request); + request.site_settings.as_mut().unwrap().creative_settings.as_mut().unwrap().i_frame_footer = Some(value.unwrap_or("").to_string()); }, "approved" => { request_site_settings_init(&mut request); @@ -17791,8 +20204,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17803,7 +20215,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sizes().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17835,8 +20247,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17845,10 +20256,10 @@ impl Engine { fn _sizes_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Size = Default::default(); + let mut request = api::Size::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -17868,9 +20279,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -17907,8 +20319,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17919,7 +20330,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sizes().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "width" => { call = call.width(arg_from_str(value.unwrap_or("-0"), err, "width", "integer")); @@ -17963,8 +20374,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -17975,7 +20385,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subaccounts().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18007,8 +20417,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18017,10 +20426,10 @@ impl Engine { fn _subaccounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subaccount = Default::default(); + let mut request = api::Subaccount::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18040,9 +20449,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18052,9 +20462,9 @@ impl Engine { }, "available-permission-ids" => { if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); + request.available_permission_ids = Some(Default::default()); } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); @@ -18082,8 +20492,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18094,7 +20503,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subaccounts().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -18144,8 +20553,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18154,10 +20562,10 @@ impl Engine { fn _subaccounts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subaccount = Default::default(); + let mut request = api::Subaccount::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18177,9 +20585,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18189,9 +20598,9 @@ impl Engine { }, "available-permission-ids" => { if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); + request.available_permission_ids = Some(Default::default()); } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); @@ -18219,8 +20628,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18229,10 +20637,10 @@ impl Engine { fn _subaccounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subaccount = Default::default(); + let mut request = api::Subaccount::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18252,9 +20660,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18264,9 +20673,9 @@ impl Engine { }, "available-permission-ids" => { if request.available_permission_ids.is_none() { - request.available_permission_ids = Some(Default::default()); + request.available_permission_ids = Some(Default::default()); } - request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.available_permission_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); @@ -18294,8 +20703,111 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _targetable_remarketing_lists_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.targetable_remarketing_lists().get(&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); + 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 _targetable_remarketing_lists_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.targetable_remarketing_lists().list(&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 { + "sort-order" => { + call = call.sort_order(value.unwrap_or("")); + }, + "sort-field" => { + call = call.sort_field(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "name" => { + call = call.name(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "active" => { + call = call.active(arg_from_str(value.unwrap_or("false"), err, "active", "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); + 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 } } @@ -18306,7 +20818,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_profiles().get(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18338,8 +20850,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18350,7 +20861,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_profiles().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18382,8 +20893,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18394,7 +20904,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_role_permission_groups().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18426,8 +20936,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18438,7 +20947,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_role_permission_groups().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18470,8 +20979,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18482,7 +20990,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_role_permissions().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18514,8 +21022,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18526,7 +21033,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_role_permissions().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "ids" => { call = call.add_ids(value.unwrap_or("")); @@ -18561,8 +21068,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18573,7 +21079,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_roles().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18604,7 +21110,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -18615,7 +21120,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_roles().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18647,8 +21152,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18657,10 +21161,10 @@ impl Engine { fn _user_roles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::UserRole = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18680,9 +21184,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18725,8 +21230,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18737,7 +21241,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.user_roles().list(&self.opt.arg_profile_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "subaccount-id" => { call = call.subaccount_id(value.unwrap_or("")); @@ -18793,8 +21297,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18803,10 +21306,10 @@ impl Engine { fn _user_roles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::UserRole = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18826,9 +21329,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18871,8 +21375,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18881,10 +21384,10 @@ impl Engine { fn _user_roles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::UserRole = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -18904,9 +21407,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -18949,8 +21453,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -18968,7 +21471,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_account_permission_groups { + } + else if self.opt.cmd_account_permission_groups { if self.opt.cmd_get { call_result = self._account_permission_groups_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -18976,7 +21480,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_account_permissions { + } + else if self.opt.cmd_account_permissions { if self.opt.cmd_get { call_result = self._account_permissions_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -18984,9 +21489,12 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_account_user_profiles { + } + else if self.opt.cmd_account_user_profiles { if self.opt.cmd_get { call_result = self._account_user_profiles_get(dry_run, &mut err); + } else if self.opt.cmd_insert { + call_result = self._account_user_profiles_insert(dry_run, &mut err); } else if self.opt.cmd_list { call_result = self._account_user_profiles_list(dry_run, &mut err); } else if self.opt.cmd_patch { @@ -18996,7 +21504,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_accounts { + } + else if self.opt.cmd_accounts { if self.opt.cmd_get { call_result = self._accounts_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19008,7 +21517,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_ads { + } + else if self.opt.cmd_ads { if self.opt.cmd_get { call_result = self._ads_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19022,7 +21532,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_advertiser_groups { + } + else if self.opt.cmd_advertiser_groups { if self.opt.cmd_delete { call_result = self._advertiser_groups_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19038,7 +21549,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_advertisers { + } + else if self.opt.cmd_advertisers { if self.opt.cmd_get { call_result = self._advertisers_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19052,13 +21564,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_browsers { + } + else if self.opt.cmd_browsers { if self.opt.cmd_list { call_result = self._browsers_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_campaign_creative_associations { + } + else if self.opt.cmd_campaign_creative_associations { if self.opt.cmd_insert { call_result = self._campaign_creative_associations_insert(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19066,7 +21580,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_campaigns { + } + else if self.opt.cmd_campaigns { if self.opt.cmd_get { call_result = self._campaigns_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19080,7 +21595,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_change_logs { + } + else if self.opt.cmd_change_logs { if self.opt.cmd_get { call_result = self._change_logs_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19088,19 +21604,24 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_cities { + } + else if self.opt.cmd_cities { if self.opt.cmd_list { call_result = self._cities_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_connection_types { - if self.opt.cmd_list { + } + else if self.opt.cmd_connection_types { + if self.opt.cmd_get { + call_result = self._connection_types_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._connection_types_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_content_categories { + } + else if self.opt.cmd_content_categories { if self.opt.cmd_delete { call_result = self._content_categories_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19116,7 +21637,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_countries { + } + else if self.opt.cmd_countries { if self.opt.cmd_get { call_result = self._countries_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19124,13 +21646,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_creative_assets { + } + else if self.opt.cmd_creative_assets { if self.opt.cmd_insert { call_result = self._creative_assets_insert(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_creative_field_values { + } + else if self.opt.cmd_creative_field_values { if self.opt.cmd_delete { call_result = self._creative_field_values_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19146,7 +21670,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_creative_fields { + } + else if self.opt.cmd_creative_fields { if self.opt.cmd_delete { call_result = self._creative_fields_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19162,7 +21687,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_creative_groups { + } + else if self.opt.cmd_creative_groups { if self.opt.cmd_get { call_result = self._creative_groups_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19176,7 +21702,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_creatives { + } + else if self.opt.cmd_creatives { if self.opt.cmd_get { call_result = self._creatives_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19190,13 +21717,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_dimension_values { + } + else if self.opt.cmd_dimension_values { if self.opt.cmd_query { call_result = self._dimension_values_query(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_directory_site_contacts { + } + else if self.opt.cmd_directory_site_contacts { if self.opt.cmd_get { call_result = self._directory_site_contacts_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19204,15 +21733,19 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_directory_sites { + } + else if self.opt.cmd_directory_sites { if self.opt.cmd_get { call_result = self._directory_sites_get(dry_run, &mut err); + } else if self.opt.cmd_insert { + call_result = self._directory_sites_insert(dry_run, &mut err); } else if self.opt.cmd_list { call_result = self._directory_sites_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_event_tags { + } + else if self.opt.cmd_event_tags { if self.opt.cmd_delete { call_result = self._event_tags_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19228,7 +21761,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_files { + } + else if self.opt.cmd_files { if self.opt.cmd_get { call_result = self._files_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19236,7 +21770,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_floodlight_activities { + } + else if self.opt.cmd_floodlight_activities { if self.opt.cmd_delete { call_result = self._floodlight_activities_delete(dry_run, &mut err); } else if self.opt.cmd_generatetag { @@ -19254,7 +21789,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_floodlight_activity_groups { + } + else if self.opt.cmd_floodlight_activity_groups { if self.opt.cmd_delete { call_result = self._floodlight_activity_groups_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19270,7 +21806,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_floodlight_configurations { + } + else if self.opt.cmd_floodlight_configurations { if self.opt.cmd_get { call_result = self._floodlight_configurations_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19282,7 +21819,17 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_landing_pages { + } + else if self.opt.cmd_inventory_items { + if self.opt.cmd_get { + call_result = self._inventory_items_get(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._inventory_items_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_landing_pages { if self.opt.cmd_delete { call_result = self._landing_pages_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19298,31 +21845,60 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_metros { + } + else if self.opt.cmd_metros { if self.opt.cmd_list { call_result = self._metros_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_mobile_carriers { - if self.opt.cmd_list { + } + else if self.opt.cmd_mobile_carriers { + if self.opt.cmd_get { + call_result = self._mobile_carriers_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._mobile_carriers_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_operating_system_versions { - if self.opt.cmd_list { + } + else if self.opt.cmd_operating_system_versions { + if self.opt.cmd_get { + call_result = self._operating_system_versions_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._operating_system_versions_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_operating_systems { - if self.opt.cmd_list { + } + else if self.opt.cmd_operating_systems { + if self.opt.cmd_get { + call_result = self._operating_systems_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._operating_systems_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_placement_groups { + } + else if self.opt.cmd_order_documents { + if self.opt.cmd_get { + call_result = self._order_documents_get(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._order_documents_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_orders { + if self.opt.cmd_get { + call_result = self._orders_get(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._orders_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_placement_groups { if self.opt.cmd_get { call_result = self._placement_groups_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19336,7 +21912,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_placement_strategies { + } + else if self.opt.cmd_placement_strategies { if self.opt.cmd_delete { call_result = self._placement_strategies_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19352,7 +21929,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_placements { + } + else if self.opt.cmd_placements { if self.opt.cmd_generatetags { call_result = self._placements_generatetags(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19368,25 +21946,68 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_platform_types { - if self.opt.cmd_list { + } + else if self.opt.cmd_platform_types { + if self.opt.cmd_get { + call_result = self._platform_types_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._platform_types_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_postal_codes { - if self.opt.cmd_list { + } + else if self.opt.cmd_postal_codes { + if self.opt.cmd_get { + call_result = self._postal_codes_get(dry_run, &mut err); + } else if self.opt.cmd_list { call_result = self._postal_codes_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_regions { + } + else if self.opt.cmd_projects { + if self.opt.cmd_get { + call_result = self._projects_get(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._projects_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_regions { if self.opt.cmd_list { call_result = self._regions_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_remarketing_list_shares { + if self.opt.cmd_get { + call_result = self._remarketing_list_shares_get(dry_run, &mut err); + } else if self.opt.cmd_patch { + call_result = self._remarketing_list_shares_patch(dry_run, &mut err); + } else if self.opt.cmd_update { + call_result = self._remarketing_list_shares_update(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_remarketing_lists { + if self.opt.cmd_get { + call_result = self._remarketing_lists_get(dry_run, &mut err); + } else if self.opt.cmd_insert { + call_result = self._remarketing_lists_insert(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._remarketing_lists_list(dry_run, &mut err); + } else if self.opt.cmd_patch { + call_result = self._remarketing_lists_patch(dry_run, &mut err); + } else if self.opt.cmd_update { + call_result = self._remarketing_lists_update(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_reports { if self.opt.cmd_compatible_fields_query { call_result = self._reports_compatible_fields_query(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -19410,7 +22031,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_sites { + } + else if self.opt.cmd_sites { if self.opt.cmd_get { call_result = self._sites_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19424,7 +22046,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_sizes { + } + else if self.opt.cmd_sizes { if self.opt.cmd_get { call_result = self._sizes_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19434,7 +22057,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_subaccounts { + } + else if self.opt.cmd_subaccounts { if self.opt.cmd_get { call_result = self._subaccounts_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -19448,7 +22072,17 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_user_profiles { + } + else if self.opt.cmd_targetable_remarketing_lists { + if self.opt.cmd_get { + call_result = self._targetable_remarketing_lists_get(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._targetable_remarketing_lists_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_user_profiles { if self.opt.cmd_get { call_result = self._user_profiles_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19456,7 +22090,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_user_role_permission_groups { + } + else if self.opt.cmd_user_role_permission_groups { if self.opt.cmd_get { call_result = self._user_role_permission_groups_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19464,7 +22099,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_user_role_permissions { + } + else if self.opt.cmd_user_role_permissions { if self.opt.cmd_get { call_result = self._user_role_permissions_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -19472,7 +22108,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_user_roles { + } + else if self.opt.cmd_user_roles { if self.opt.cmd_delete { call_result = self._user_roles_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -19508,21 +22145,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "dfareporting2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "dfareporting2d1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "dfareporting2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "dfareporting2d1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Dfareporting::new(hyper::Client::new(), auth), + hub: api::Dfareporting::new(client, auth), }; match engine._doit(true) { @@ -19542,12 +22195,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/dfareporting2/Cargo.toml b/gen/dfareporting2d1/Cargo.toml similarity index 81% rename from gen/dfareporting2/Cargo.toml rename to gen/dfareporting2d1/Cargo.toml index d6cec095ca..0d9c68c716 100644 --- a/gen/dfareporting2/Cargo.toml +++ b/gen/dfareporting2d1/Cargo.toml @@ -3,13 +3,13 @@ # DO NOT EDIT ! [package] -name = "google-dfareporting2" +name = "google-dfareporting2d1" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dfareporting (protocol v2.0)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2" +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" homepage = "https://developers.google.com/doubleclick-advertisers/reporting/" -documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2" +documentation = "http://byron.github.io/google-apis-rs/google_dfareporting2d1" license = "MIT" keywords = ["dfareporting", "google", "protocol", "web", "api"] diff --git a/gen/admin1_reports-cli/LICENSE.md b/gen/dfareporting2d1/LICENSE.md similarity index 100% rename from gen/admin1_reports-cli/LICENSE.md rename to gen/dfareporting2d1/LICENSE.md diff --git a/gen/dfareporting2d1/README.md b/gen/dfareporting2d1/README.md new file mode 100644 index 0000000000..3ea0866d1b --- /dev/null +++ b/gen/dfareporting2d1/README.md @@ -0,0 +1,303 @@ +<!--- +DO NOT EDIT ! +This file was generated automatically from 'src/mako/api/README.md.mako' +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*. + +Everything else about the *dfareporting* *v2d1* API can be found at the +[official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). +# Features + +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Dfareporting.html) ... + +* [account active ad summaries](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountActiveAdSummary.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountActiveAdSummaryGetCall.html) +* [account permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermissionGroupListCall.html) +* [account permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPermissionListCall.html) +* [account user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfileGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfileInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfileListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfilePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUserProfileUpdateCall.html) +* [accounts](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Account.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AccountUpdateCall.html) +* [ads](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Ad.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdUpdateCall.html) +* [advertiser groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroup.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGroupUpdateCall.html) +* [advertisers](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Advertiser.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.AdvertiserUpdateCall.html) +* [browsers](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Browser.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.BrowserListCall.html) +* [campaign creative associations](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignCreativeAssociation.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignCreativeAssociationInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignCreativeAssociationListCall.html) +* [campaigns](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Campaign.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CampaignUpdateCall.html) +* [change logs](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ChangeLog.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ChangeLogGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ChangeLogListCall.html) +* [cities](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.City.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CityListCall.html) +* [connection types](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ConnectionType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ConnectionTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ConnectionTypeListCall.html) +* [content categories](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategory.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ContentCategoryUpdateCall.html) +* [countries](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Country.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CountryGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CountryListCall.html) +* [creative assets](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeAsset.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeAssetInsertCall.html) +* [creative field values](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValue.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValueDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValueGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValueInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValueListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValuePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldValueUpdateCall.html) +* [creative fields](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeField.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeFieldUpdateCall.html) +* [creative groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGroupUpdateCall.html) +* [creatives](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Creative.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeUpdateCall.html) +* [dimension values](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DimensionValue.html) + * [*query*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DimensionValueQueryCall.html) +* [directory site contacts](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteContact.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteContactGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteContactListCall.html) +* [directory sites](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySite.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.DirectorySiteListCall.html) +* [event tags](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTag.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.EventTagUpdateCall.html) +* [files](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.File.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FileListCall.html) +* [floodlight activities](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivity.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityDeleteCall.html), [*generatetag*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityUpdateCall.html) +* [floodlight activity groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroup.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightActivityGroupUpdateCall.html) +* [floodlight configurations](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightConfiguration.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightConfigurationGetCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightConfigurationListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightConfigurationPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FloodlightConfigurationUpdateCall.html) +* [inventory items](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.InventoryItem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.InventoryItemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.InventoryItemListCall.html) +* [landing pages](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPage.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPageDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPageGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPageInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPageListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPagePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.LandingPageUpdateCall.html) +* [metros](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Metro.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.MetroListCall.html) +* [mobile carriers](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.MobileCarrier.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.MobileCarrierGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.MobileCarrierListCall.html) +* [operating system versions](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystemVersion.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystemVersionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystemVersionListCall.html) +* [operating systems](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystem.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystemGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OperatingSystemListCall.html) +* [order documents](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OrderDocument.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OrderDocumentGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OrderDocumentListCall.html) +* [orders](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Order.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OrderGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.OrderListCall.html) +* [placement groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroupGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroupInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroupListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroupPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGroupUpdateCall.html) +* [placement strategies](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategy.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementStrategyUpdateCall.html) +* [placements](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Placement.html) + * [*generatetags*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGeneratetagCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlacementUpdateCall.html) +* [platform types](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlatformType.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlatformTypeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PlatformTypeListCall.html) +* [postal codes](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PostalCode.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PostalCodeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.PostalCodeListCall.html) +* [projects](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Project.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ProjectGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ProjectListCall.html) +* [regions](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Region.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RegionListCall.html) +* [remarketing list shares](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListShare.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListShareGetCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListSharePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListShareUpdateCall.html) +* [remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.RemarketingListUpdateCall.html) +* [reports](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Report.html) + * [*compatible fields query*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportCompatibleFieldQueryCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportDeleteCall.html), [*files get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportFileGetCall.html), [*files list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportFileListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportPatchCall.html), [*run*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportRunCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportUpdateCall.html) +* [sites](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Site.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SiteGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SiteInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SiteListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SitePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SiteUpdateCall.html) +* [sizes](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Size.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SizeGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SizeInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SizeListCall.html) +* [subaccounts](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Subaccount.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SubaccountGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SubaccountInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SubaccountListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SubaccountPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.SubaccountUpdateCall.html) +* [targetable remarketing lists](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.TargetableRemarketingList.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.TargetableRemarketingListGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.TargetableRemarketingListListCall.html) +* [user profiles](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserProfile.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserProfileGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserProfileListCall.html) +* [user role permission groups](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermissionGroup.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermissionGroupGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermissionGroupListCall.html) +* [user role permissions](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermission.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermissionGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePermissionListCall.html) +* [user roles](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRole.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRoleDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRoleGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRoleInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRoleListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRolePatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.UserRoleUpdateCall.html) + + +Upload supported by ... + +* [*insert creative assets*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.CreativeAssetInsertCall.html) + +Download supported by ... + +* [*get files*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.FileGetCall.html) +* [*files get reports*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.ReportFileGetCall.html) + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](http://byron.github.io/google-apis-rs/google_dfareporting2d1/struct.Dfareporting.html)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Resource.html)** + * primary types that you can apply *Activities* to + * a collection of properties and *Parts* + * **[Parts](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Part.html)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.CallBuilder.html)** + * operations to apply to *Resources* + +All *structures* are marked with applicable traits to further categorize them and ease browsing. + +Generally speaking, you can invoke *Activities* like this: + +```Rust,ignore +let r = hub.resource().activity(...).doit() +``` + +Or specifically ... + +```ignore +let r = hub.reports().run(...).doit() +let r = hub.reports().get(...).doit() +let r = hub.reports().list(...).doit() +let r = hub.reports().delete(...).doit() +let r = hub.reports().files_list(...).doit() +let r = hub.reports().insert(...).doit() +let r = hub.reports().patch(...).doit() +let r = hub.reports().compatible_fields_query(...).doit() +let r = hub.reports().update(...).doit() +let r = hub.reports().files_get(...).doit() +``` + +The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` +supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be +specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. +The `doit()` method performs the actual communication with the server and returns the respective result. + +# Usage + +## Setting up your Project + +To use this library, you would put the following lines into your `Cargo.toml` file: + +```toml +[dependencies] +google-dfareporting2d1 = "*" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate yup_oauth2 as oauth2; +extern crate google_dfareporting2d1 as dfareporting2d1; +use dfareporting2d1::{Result, Error}; +use std::default::Default; +use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +use dfareporting2d1::Dfareporting; + +// Get an ApplicationSecret instance by some means. It contains the `client_id` and +// `client_secret`, among other things. +let secret: ApplicationSecret = Default::default(); +// Instantiate the authenticator. It will choose a suitable authentication flow for you, +// unless you replace `None` with the desired Flow. +// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about +// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and +// retrieve them from storage. +let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, + hyper::Client::new(), + <MemoryStorage as Default>::default(), None); +let mut hub = Dfareporting::new(hyper::Client::new(), auth); +// You can configure optional parameters by calling 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().list("profileId") + .sort_order("sit") + .sort_field("Stet") + .scope("sed") + .page_token("et") + .max_results(-18) + .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::MissingAPIKey + |Error::MissingToken + |Error::Cancelled + |Error::UploadSizeLimitExceeded(_, _) + |Error::Failure(_) + |Error::FieldClash(_) + |Error::JsonDecodeError(_) => println!("{}", e), + }, + Ok(res) => println!("Success: {:?}", res), +} + +``` +## Handling Errors + +All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_dfareporting2d1/enum.Result.html) enumeration as return value of +the doit() methods, or handed as possibly intermediate results to either the +[Hub Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dfareporting2d1/../yup-oauth2/trait.AuthenticatorDelegate.html). + +When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This +makes the system potentially resilient to all kinds of errors. + +## Uploads and Downloads +If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google_dfareporting2d1/enum.Result.html), should be +read by you to obtain the media. +If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.ResponseResult.html), it will return that by default. +You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making +this call: `.param("alt", "media")`. + +Methods supporting uploads can do so using up to 2 different protocols: +*simple* and *resumable*. The distinctiveness of each is represented by customized +`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. + +## Customization and Callbacks + +You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.CallBuilder.html) before making the final `doit()` call. +Respective methods will be called to provide progress information, as well as determine whether the system should +retry on failure. + +The [delegate trait](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. + +## Optional Parts in Server-Requests + +All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses +are valid. +Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.Part.html) which are identifiable by name, which will be sent to +the server to indicate either the set parts of the request or the desired parts in the response. + +## Builder Arguments + +Using [method builders](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. +These will always take a single argument, for which the following statements are true. + +* [PODs][wiki-pod] are handed by copy +* strings are passed as `&str` +* [request values](http://byron.github.io/google-apis-rs/google_dfareporting2d1/trait.RequestValue.html) are borrowed + +Arguments will always be copied or cloned into the builder, to make them independent of their original life times. + +[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure +[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern +[google-go-api]: https://github.com/google/google-api-go-client + +# License +The **dfareporting2d1** library was generated by Sebastian Thiel, and is placed +under the *MIT* license. +You can read the full text at the repository's [license file][repo-license]. + +[repo-license]: https://github.com/Byron/google-apis-rs/LICENSE.md diff --git a/gen/dataflow1_b4/src/cmn.rs b/gen/dfareporting2d1/src/cmn.rs similarity index 97% rename from gen/dataflow1_b4/src/cmn.rs rename to gen/dfareporting2d1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/dataflow1_b4/src/cmn.rs +++ b/gen/dfareporting2d1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/dfareporting2/src/lib.rs b/gen/dfareporting2d1/src/lib.rs similarity index 81% rename from gen/dfareporting2/src/lib.rs rename to gen/dfareporting2d1/src/lib.rs index d66a64ea05..baa15f8570 100644 --- a/gen/dfareporting2/src/lib.rs +++ b/gen/dfareporting2d1/src/lib.rs @@ -2,11 +2,11 @@ // 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.0* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! 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*. //! -//! Everything else about the *dfareporting* *v2* API can be found at the +//! Everything else about the *dfareporting* *v2d1* API can be found at the //! [official documentation site](https://developers.google.com/doubleclick-advertisers/reporting/). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dfareporting2d1). //! # Features //! //! Handle the following *Resources* with ease from the central [hub](struct.Dfareporting.html) ... @@ -18,7 +18,7 @@ //! * [account permissions](struct.AccountPermission.html) //! * [*get*](struct.AccountPermissionGetCall.html) and [*list*](struct.AccountPermissionListCall.html) //! * [account user profiles](struct.AccountUserProfile.html) -//! * [*get*](struct.AccountUserProfileGetCall.html), [*list*](struct.AccountUserProfileListCall.html), [*patch*](struct.AccountUserProfilePatchCall.html) and [*update*](struct.AccountUserProfileUpdateCall.html) +//! * [*get*](struct.AccountUserProfileGetCall.html), [*insert*](struct.AccountUserProfileInsertCall.html), [*list*](struct.AccountUserProfileListCall.html), [*patch*](struct.AccountUserProfilePatchCall.html) and [*update*](struct.AccountUserProfileUpdateCall.html) //! * [accounts](struct.Account.html) //! * [*get*](struct.AccountGetCall.html), [*list*](struct.AccountListCall.html), [*patch*](struct.AccountPatchCall.html) and [*update*](struct.AccountUpdateCall.html) //! * [ads](struct.Ad.html) @@ -38,7 +38,7 @@ //! * [cities](struct.City.html) //! * [*list*](struct.CityListCall.html) //! * [connection types](struct.ConnectionType.html) -//! * [*list*](struct.ConnectionTypeListCall.html) +//! * [*get*](struct.ConnectionTypeGetCall.html) and [*list*](struct.ConnectionTypeListCall.html) //! * [content categories](struct.ContentCategory.html) //! * [*delete*](struct.ContentCategoryDeleteCall.html), [*get*](struct.ContentCategoryGetCall.html), [*insert*](struct.ContentCategoryInsertCall.html), [*list*](struct.ContentCategoryListCall.html), [*patch*](struct.ContentCategoryPatchCall.html) and [*update*](struct.ContentCategoryUpdateCall.html) //! * [countries](struct.Country.html) @@ -58,7 +58,7 @@ //! * [directory site contacts](struct.DirectorySiteContact.html) //! * [*get*](struct.DirectorySiteContactGetCall.html) and [*list*](struct.DirectorySiteContactListCall.html) //! * [directory sites](struct.DirectorySite.html) -//! * [*get*](struct.DirectorySiteGetCall.html) and [*list*](struct.DirectorySiteListCall.html) +//! * [*get*](struct.DirectorySiteGetCall.html), [*insert*](struct.DirectorySiteInsertCall.html) and [*list*](struct.DirectorySiteListCall.html) //! * [event tags](struct.EventTag.html) //! * [*delete*](struct.EventTagDeleteCall.html), [*get*](struct.EventTagGetCall.html), [*insert*](struct.EventTagInsertCall.html), [*list*](struct.EventTagListCall.html), [*patch*](struct.EventTagPatchCall.html) and [*update*](struct.EventTagUpdateCall.html) //! * [files](struct.File.html) @@ -69,16 +69,22 @@ //! * [*delete*](struct.FloodlightActivityGroupDeleteCall.html), [*get*](struct.FloodlightActivityGroupGetCall.html), [*insert*](struct.FloodlightActivityGroupInsertCall.html), [*list*](struct.FloodlightActivityGroupListCall.html), [*patch*](struct.FloodlightActivityGroupPatchCall.html) and [*update*](struct.FloodlightActivityGroupUpdateCall.html) //! * [floodlight configurations](struct.FloodlightConfiguration.html) //! * [*get*](struct.FloodlightConfigurationGetCall.html), [*list*](struct.FloodlightConfigurationListCall.html), [*patch*](struct.FloodlightConfigurationPatchCall.html) and [*update*](struct.FloodlightConfigurationUpdateCall.html) +//! * [inventory items](struct.InventoryItem.html) +//! * [*get*](struct.InventoryItemGetCall.html) and [*list*](struct.InventoryItemListCall.html) //! * [landing pages](struct.LandingPage.html) //! * [*delete*](struct.LandingPageDeleteCall.html), [*get*](struct.LandingPageGetCall.html), [*insert*](struct.LandingPageInsertCall.html), [*list*](struct.LandingPageListCall.html), [*patch*](struct.LandingPagePatchCall.html) and [*update*](struct.LandingPageUpdateCall.html) //! * [metros](struct.Metro.html) //! * [*list*](struct.MetroListCall.html) //! * [mobile carriers](struct.MobileCarrier.html) -//! * [*list*](struct.MobileCarrierListCall.html) +//! * [*get*](struct.MobileCarrierGetCall.html) and [*list*](struct.MobileCarrierListCall.html) //! * [operating system versions](struct.OperatingSystemVersion.html) -//! * [*list*](struct.OperatingSystemVersionListCall.html) +//! * [*get*](struct.OperatingSystemVersionGetCall.html) and [*list*](struct.OperatingSystemVersionListCall.html) //! * [operating systems](struct.OperatingSystem.html) -//! * [*list*](struct.OperatingSystemListCall.html) +//! * [*get*](struct.OperatingSystemGetCall.html) and [*list*](struct.OperatingSystemListCall.html) +//! * [order documents](struct.OrderDocument.html) +//! * [*get*](struct.OrderDocumentGetCall.html) and [*list*](struct.OrderDocumentListCall.html) +//! * [orders](struct.Order.html) +//! * [*get*](struct.OrderGetCall.html) and [*list*](struct.OrderListCall.html) //! * [placement groups](struct.PlacementGroup.html) //! * [*get*](struct.PlacementGroupGetCall.html), [*insert*](struct.PlacementGroupInsertCall.html), [*list*](struct.PlacementGroupListCall.html), [*patch*](struct.PlacementGroupPatchCall.html) and [*update*](struct.PlacementGroupUpdateCall.html) //! * [placement strategies](struct.PlacementStrategy.html) @@ -86,11 +92,17 @@ //! * [placements](struct.Placement.html) //! * [*generatetags*](struct.PlacementGeneratetagCall.html), [*get*](struct.PlacementGetCall.html), [*insert*](struct.PlacementInsertCall.html), [*list*](struct.PlacementListCall.html), [*patch*](struct.PlacementPatchCall.html) and [*update*](struct.PlacementUpdateCall.html) //! * [platform types](struct.PlatformType.html) -//! * [*list*](struct.PlatformTypeListCall.html) +//! * [*get*](struct.PlatformTypeGetCall.html) and [*list*](struct.PlatformTypeListCall.html) //! * [postal codes](struct.PostalCode.html) -//! * [*list*](struct.PostalCodeListCall.html) +//! * [*get*](struct.PostalCodeGetCall.html) and [*list*](struct.PostalCodeListCall.html) +//! * [projects](struct.Project.html) +//! * [*get*](struct.ProjectGetCall.html) and [*list*](struct.ProjectListCall.html) //! * [regions](struct.Region.html) //! * [*list*](struct.RegionListCall.html) +//! * [remarketing list shares](struct.RemarketingListShare.html) +//! * [*get*](struct.RemarketingListShareGetCall.html), [*patch*](struct.RemarketingListSharePatchCall.html) and [*update*](struct.RemarketingListShareUpdateCall.html) +//! * [remarketing lists](struct.RemarketingList.html) +//! * [*get*](struct.RemarketingListGetCall.html), [*insert*](struct.RemarketingListInsertCall.html), [*list*](struct.RemarketingListListCall.html), [*patch*](struct.RemarketingListPatchCall.html) and [*update*](struct.RemarketingListUpdateCall.html) //! * [reports](struct.Report.html) //! * [*compatible fields query*](struct.ReportCompatibleFieldQueryCall.html), [*delete*](struct.ReportDeleteCall.html), [*files get*](struct.ReportFileGetCall.html), [*files list*](struct.ReportFileListCall.html), [*get*](struct.ReportGetCall.html), [*insert*](struct.ReportInsertCall.html), [*list*](struct.ReportListCall.html), [*patch*](struct.ReportPatchCall.html), [*run*](struct.ReportRunCall.html) and [*update*](struct.ReportUpdateCall.html) //! * [sites](struct.Site.html) @@ -99,6 +111,8 @@ //! * [*get*](struct.SizeGetCall.html), [*insert*](struct.SizeInsertCall.html) and [*list*](struct.SizeListCall.html) //! * [subaccounts](struct.Subaccount.html) //! * [*get*](struct.SubaccountGetCall.html), [*insert*](struct.SubaccountInsertCall.html), [*list*](struct.SubaccountListCall.html), [*patch*](struct.SubaccountPatchCall.html) and [*update*](struct.SubaccountUpdateCall.html) +//! * [targetable remarketing lists](struct.TargetableRemarketingList.html) +//! * [*get*](struct.TargetableRemarketingListGetCall.html) and [*list*](struct.TargetableRemarketingListListCall.html) //! * [user profiles](struct.UserProfile.html) //! * [*get*](struct.UserProfileGetCall.html) and [*list*](struct.UserProfileListCall.html) //! * [user role permission groups](struct.UserRolePermissionGroup.html) @@ -175,7 +189,7 @@ //! //! ```toml //! [dependencies] -//! google-dfareporting2 = "*" +//! google-dfareporting2d1 = "*" //! ``` //! //! ## A complete example @@ -183,12 +197,12 @@ //! ```test_harness,no_run //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; -//! extern crate google_dfareporting2 as dfareporting2; -//! use dfareporting2::{Result, Error}; +//! extern crate google_dfareporting2d1 as dfareporting2d1; +//! use dfareporting2d1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use dfareporting2::Dfareporting; +//! use dfareporting2d1::Dfareporting; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. @@ -361,12 +375,12 @@ impl Default for Scope { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::{Result, Error}; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. @@ -514,6 +528,9 @@ impl<'a, C, A> Dfareporting<C, A> pub fn floodlight_configurations(&'a self) -> FloodlightConfigurationMethods<'a, C, A> { FloodlightConfigurationMethods { hub: &self } } + pub fn inventory_items(&'a self) -> InventoryItemMethods<'a, C, A> { + InventoryItemMethods { hub: &self } + } pub fn landing_pages(&'a self) -> LandingPageMethods<'a, C, A> { LandingPageMethods { hub: &self } } @@ -529,6 +546,12 @@ impl<'a, C, A> Dfareporting<C, A> pub fn operating_systems(&'a self) -> OperatingSystemMethods<'a, C, A> { OperatingSystemMethods { hub: &self } } + pub fn order_documents(&'a self) -> OrderDocumentMethods<'a, C, A> { + OrderDocumentMethods { hub: &self } + } + pub fn orders(&'a self) -> OrderMethods<'a, C, A> { + OrderMethods { hub: &self } + } pub fn placement_groups(&'a self) -> PlacementGroupMethods<'a, C, A> { PlacementGroupMethods { hub: &self } } @@ -544,9 +567,18 @@ impl<'a, C, A> Dfareporting<C, A> pub fn postal_codes(&'a self) -> PostalCodeMethods<'a, C, A> { PostalCodeMethods { hub: &self } } + pub fn projects(&'a self) -> ProjectMethods<'a, C, A> { + ProjectMethods { hub: &self } + } pub fn regions(&'a self) -> RegionMethods<'a, C, A> { RegionMethods { hub: &self } } + pub fn remarketing_list_shares(&'a self) -> RemarketingListShareMethods<'a, C, A> { + RemarketingListShareMethods { hub: &self } + } + pub fn remarketing_lists(&'a self) -> RemarketingListMethods<'a, C, A> { + RemarketingListMethods { hub: &self } + } pub fn reports(&'a self) -> ReportMethods<'a, C, A> { ReportMethods { hub: &self } } @@ -559,6 +591,9 @@ impl<'a, C, A> Dfareporting<C, A> pub fn subaccounts(&'a self) -> SubaccountMethods<'a, C, A> { SubaccountMethods { hub: &self } } + pub fn targetable_remarketing_lists(&'a self) -> TargetableRemarketingListMethods<'a, C, A> { + TargetableRemarketingListMethods { hub: &self } + } pub fn user_profiles(&'a self) -> UserProfileMethods<'a, C, A> { UserProfileMethods { hub: &self } } @@ -599,10 +634,10 @@ impl<'a, C, A> Dfareporting<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperatingSystemsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemsListResponse". - pub kind: String, + pub kind: Option<String>, /// Operating system collection. #[serde(rename="operatingSystems")] - pub operating_systems: Vec<OperatingSystem>, + pub operating_systems: Option<Vec<OperatingSystem>>, } impl ResponseResult for OperatingSystemsListResponse {} @@ -616,23 +651,23 @@ impl ResponseResult for OperatingSystemsListResponse {} pub struct DirectorySiteSettings { /// Whether this site accepts interstitial ads. #[serde(rename="interstitialPlacementAccepted")] - pub interstitial_placement_accepted: bool, + pub interstitial_placement_accepted: Option<bool>, /// Whether this directory site has disabled Nielsen OCR reach ratings. #[serde(rename="nielsenOcrOptOut")] - pub nielsen_ocr_opt_out: bool, + pub nielsen_ocr_opt_out: Option<bool>, /// Whether this directory site has disabled active view creatives. #[serde(rename="activeViewOptOut")] - pub active_view_opt_out: bool, + pub active_view_opt_out: Option<bool>, /// Whether this directory site has disabled active view for in-stream video creatives. #[serde(rename="videoActiveViewOptOut")] - pub video_active_view_opt_out: bool, + pub video_active_view_opt_out: Option<bool>, /// Directory site DFP settings. - pub dfp_settings: DfpSettings, + pub dfp_settings: Option<DfpSettings>, /// Whether this directory site has disabled generation of Verification ins tags. #[serde(rename="verificationTagOptOut")] - pub verification_tag_opt_out: bool, + pub verification_tag_opt_out: Option<bool>, /// Whether this site accepts in-stream video ads. - pub instream_video_placement_accepted: bool, + pub instream_video_placement_accepted: Option<bool>, } impl Part for DirectorySiteSettings {} @@ -646,6 +681,7 @@ impl Part for DirectorySiteSettings {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list mobile carriers](struct.MobileCarrierListCall.html) (none) +/// * [get mobile carriers](struct.MobileCarrierGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileCarrier { @@ -664,6 +700,7 @@ pub struct MobileCarrier { } impl Resource for MobileCarrier {} +impl ResponseResult for MobileCarrier {} /// Contains properties of a DCM subaccount. @@ -713,11 +750,11 @@ impl ResponseResult for Subaccount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissionGroup { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroup". - pub kind: String, + pub kind: Option<String>, /// ID of this account permission group. - pub id: String, + pub id: Option<String>, /// Name of this account permission group. - pub name: String, + pub name: Option<String>, } impl Resource for AccountPermissionGroup {} @@ -737,13 +774,13 @@ impl ResponseResult for AccountPermissionGroup {} pub struct DimensionValueList { /// Continuation token used to page through dimension values. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The dimension values returned in this response. - pub items: Vec<DimensionValue>, + pub items: Option<Vec<DimensionValue>>, /// The kind of list this is, in this case dfareporting#dimensionValueList. - pub kind: String, + pub kind: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for DimensionValueList {} @@ -762,12 +799,12 @@ impl ResponseResult for DimensionValueList {} pub struct CampaignCreativeAssociationsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Campaign creative association collection #[serde(rename="campaignCreativeAssociations")] - pub campaign_creative_associations: Vec<CampaignCreativeAssociation>, + pub campaign_creative_associations: Option<Vec<CampaignCreativeAssociation>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociationsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CampaignCreativeAssociationsListResponse {} @@ -786,12 +823,12 @@ impl ResponseResult for CampaignCreativeAssociationsListResponse {} pub struct FloodlightActivitiesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesListResponse". - pub kind: String, + pub kind: Option<String>, /// Floodlight activity collection. #[serde(rename="floodlightActivities")] - pub floodlight_activities: Vec<FloodlightActivity>, + pub floodlight_activities: Option<Vec<FloodlightActivity>>, } impl ResponseResult for FloodlightActivitiesListResponse {} @@ -810,9 +847,9 @@ impl ResponseResult for FloodlightActivitiesListResponse {} pub struct UserRolePermissionGroupsListResponse { /// User role permission group collection. #[serde(rename="userRolePermissionGroups")] - pub user_role_permission_groups: Vec<UserRolePermissionGroup>, + pub user_role_permission_groups: Option<Vec<UserRolePermissionGroup>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for UserRolePermissionGroupsListResponse {} @@ -832,13 +869,13 @@ impl ResponseResult for UserRolePermissionGroupsListResponse {} pub struct FileList { /// Continuation token used to page through files. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The files returned in this response. - pub items: Vec<File>, + pub items: Option<Vec<File>>, /// The kind of list this is, in this case dfareporting#fileList. - pub kind: String, + pub kind: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for FileList {} @@ -851,10 +888,10 @@ impl ResponseResult for FileList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomRichMediaEvents { /// The kind of resource this is, in this case dfareporting#customRichMediaEvents. - pub kind: String, + pub kind: Option<String>, /// List of custom rich media event IDs. Dimension values must be all of type dfa:richMediaEventTypeIdAndName. #[serde(rename="filteredEventIds")] - pub filtered_event_ids: Vec<DimensionValue>, + pub filtered_event_ids: Option<Vec<DimensionValue>>, } impl Part for CustomRichMediaEvents {} @@ -867,9 +904,9 @@ impl Part for CustomRichMediaEvents {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventTagOverride { /// Whether this override is enabled. - pub enabled: bool, + pub enabled: Option<bool>, /// ID of this event tag override. This is a read-only, auto-generated field. - pub id: String, + pub id: Option<String>, } impl Part for EventTagOverride {} @@ -888,18 +925,18 @@ impl Part for EventTagOverride {} pub struct AccountActiveAdSummary { /// Ads that can be activated for the account. #[serde(rename="availableAds")] - pub available_ads: String, + pub available_ads: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountActiveAdSummary". - pub kind: String, + pub kind: Option<String>, /// ID of the account. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option<String>, /// Ads that have been activated for the account #[serde(rename="activeAds")] - pub active_ads: String, + pub active_ads: Option<String>, /// Maximum number of active ads allowed for the account. #[serde(rename="activeAdsLimitTier")] - pub active_ads_limit_tier: String, + pub active_ads_limit_tier: Option<String>, } impl ResponseResult for AccountActiveAdSummary {} @@ -913,10 +950,10 @@ impl ResponseResult for AccountActiveAdSummary {} pub struct LookbackConfiguration { /// Lookback window, in days, from the last time a given user clicked on one of your ads. If you enter 0, clicks will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. #[serde(rename="clickDuration")] - pub click_duration: i32, + pub click_duration: Option<i32>, /// Lookback window, in days, from the last time a given user viewed one of your ads. If you enter 0, impressions will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. #[serde(rename="postImpressionActivitiesDuration")] - pub post_impression_activities_duration: i32, + pub post_impression_activities_duration: Option<i32>, } impl Part for LookbackConfiguration {} @@ -934,15 +971,46 @@ impl Part for LookbackConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivitiesGenerateTagResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesGenerateTagResponse". - pub kind: String, + pub kind: Option<String>, /// Generated tag for this floodlight activity. #[serde(rename="floodlightActivityTag")] - pub floodlight_activity_tag: String, + pub floodlight_activity_tag: Option<String>, } impl ResponseResult for FloodlightActivitiesGenerateTagResponse {} +/// Remarketing List Population Rule Term. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationTerm { + /// ID of the list in question. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option<String>, + /// Will be true if the term should check if the user is in the list and false if the term should check if the user is not in the list. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. False by default. + pub contains: Option<bool>, + /// Whether to negate the comparison result of this term during rule evaluation. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub negation: Option<bool>, + /// Literal to compare the variable to. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub value: Option<String>, + /// Friendly name of this term's variable. This is a read-only, auto-generated field. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM. + #[serde(rename="variableFriendlyName")] + pub variable_friendly_name: Option<String>, + /// Comparison operator of this term. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. + pub operator: Option<String>, + /// List population term type determines the applicable fields in this object. If left unset or set to CUSTOM_VARIABLE_TERM, then variableName, variableFriendlyName, operator, value, and negation are applicable. If set to LIST_MEMBERSHIP_TERM then remarketingListId and contains are applicable. If set to REFERRER_TERM then operator, value, and negation are applicable. + #[serde(rename="type")] + pub type_: Option<String>, + /// Name of the variable (U1, U2, etc.) being compared in this term. This field is only relevant when type is set to null, CUSTOM_VARIABLE_TERM or REFERRER_TERM. + #[serde(rename="variableName")] + pub variable_name: Option<String>, +} + +impl Part for ListPopulationTerm {} + + /// Site Settings /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -951,22 +1019,22 @@ impl ResponseResult for FloodlightActivitiesGenerateTagResponse {} pub struct SiteSettings { /// Whether brand safe ads are disabled for this site. #[serde(rename="disableBrandSafeAds")] - pub disable_brand_safe_ads: bool, + pub disable_brand_safe_ads: Option<bool>, /// Site-wide creative settings. #[serde(rename="creativeSettings")] - pub creative_settings: CreativeSettings, + pub creative_settings: Option<CreativeSettings>, /// Whether active view creatives are disabled for this site. #[serde(rename="activeViewOptOut")] - pub active_view_opt_out: bool, + pub active_view_opt_out: Option<bool>, /// Lookback window settings for this site. #[serde(rename="lookbackConfiguration")] - pub lookback_configuration: LookbackConfiguration, + pub lookback_configuration: Option<LookbackConfiguration>, /// Whether new cookies are disabled for this site. #[serde(rename="disableNewCookie")] - pub disable_new_cookie: bool, + pub disable_new_cookie: Option<bool>, /// Configuration settings for dynamic and image floodlight tags. #[serde(rename="tagSetting")] - pub tag_setting: TagSetting, + pub tag_setting: Option<TagSetting>, } impl Part for SiteSettings {} @@ -981,6 +1049,7 @@ impl Part for SiteSettings {} /// /// * [patch account user profiles](struct.AccountUserProfilePatchCall.html) (request|response) /// * [list account user profiles](struct.AccountUserProfileListCall.html) (none) +/// * [insert account user profiles](struct.AccountUserProfileInsertCall.html) (request|response) /// * [get account user profiles](struct.AccountUserProfileGetCall.html) (response) /// * [update account user profiles](struct.AccountUserProfileUpdateCall.html) (request|response) /// @@ -1059,15 +1128,64 @@ impl ResponseResult for AccountUserProfile {} pub struct TagSettings { /// Whether dynamic floodlight tags are enabled. #[serde(rename="dynamicTagEnabled")] - pub dynamic_tag_enabled: bool, + pub dynamic_tag_enabled: Option<bool>, /// Whether image tags are enabled. #[serde(rename="imageTagEnabled")] - pub image_tag_enabled: bool, + pub image_tag_enabled: Option<bool>, } impl Part for TagSettings {} +/// Contains properties of a targetable remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource is a read-only view of a remarketing list to be used to faciliate targeting ads to specific lists. Remarketing lists that are owned by your advertisers and those that are shared to your advertisers or account are accessible via this resource. To manage remarketing lists that are owned by your advertisers, use the RemarketingList resource. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (none) +/// * [get targetable remarketing lists](struct.TargetableRemarketingListGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingList { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingList". + pub kind: Option<String>, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Targetable remarketing list description. + pub description: Option<String>, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option<String>, + /// Number of days that a user should remain in the targetable remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option<String>, + /// Dimension value for the advertiser ID that owns this targetable remarketing list. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Product from which this targetable remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option<String>, + /// Whether this targetable remarketing list is active. + pub active: Option<bool>, + /// Dimension value for the ID of the advertiser. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option<DimensionValue>, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Targetable remarketing list ID. + pub id: Option<String>, + /// Name of the targetable remarketing list. Is no greater than 128 characters long. + pub name: Option<String>, +} + +impl Resource for TargetableRemarketingList {} +impl ResponseResult for TargetableRemarketingList {} + + /// Contains information about a particular version of an operating system that can be targeted by ads. /// /// # Activities @@ -1075,6 +1193,7 @@ impl Part for TagSettings {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// +/// * [get operating system versions](struct.OperatingSystemVersionGetCall.html) (response) /// * [list operating system versions](struct.OperatingSystemVersionListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -1097,27 +1216,31 @@ pub struct OperatingSystemVersion { } impl Resource for OperatingSystemVersion {} +impl ResponseResult for OperatingSystemVersion {} -/// The properties of the report. +/// Remarketing list response /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list remarketing lists](struct.RemarketingListListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReportFloodlightCriteriaReportProperties { - /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. - #[serde(rename="includeUnattributedIPConversions")] - pub include_unattributed_ip_conversions: bool, - /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. - #[serde(rename="includeUnattributedCookieConversions")] - pub include_unattributed_cookie_conversions: bool, - /// Include conversions that have no cookie, but do have an exposure path. - #[serde(rename="includeAttributedIPConversions")] - pub include_attributed_ip_conversions: bool, +pub struct RemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Remarketing list collection. + #[serde(rename="remarketingLists")] + pub remarketing_lists: Option<Vec<RemarketingList>>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListsListResponse". + pub kind: Option<String>, } -impl NestedType for ReportFloodlightCriteriaReportProperties {} -impl Part for ReportFloodlightCriteriaReportProperties {} +impl ResponseResult for RemarketingListsListResponse {} /// Creative Field Assignment. @@ -1128,15 +1251,35 @@ impl Part for ReportFloodlightCriteriaReportProperties {} pub struct CreativeFieldAssignment { /// ID of the creative field. #[serde(rename="creativeFieldId")] - pub creative_field_id: String, + pub creative_field_id: Option<String>, /// ID of the creative field value. #[serde(rename="creativeFieldValueId")] - pub creative_field_value_id: String, + pub creative_field_value_id: Option<String>, } impl Part for CreativeFieldAssignment {} +/// Remarketing List Population Rule. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationRule { + /// Floodlight activity ID associated with this rule. This field can be left blank. + #[serde(rename="floodlightActivityId")] + pub floodlight_activity_id: Option<String>, + /// Name of floodlight activity associated with this rule. This is a read-only, auto-generated field. + #[serde(rename="floodlightActivityName")] + pub floodlight_activity_name: Option<String>, + /// Clauses that make up this list population rule. Clauses are joined by ANDs, and the clauses themselves are made up of list population terms which are joined by ORs. + #[serde(rename="listPopulationClauses")] + pub list_population_clauses: Option<Vec<ListPopulationClause>>, +} + +impl Part for ListPopulationRule {} + + /// Contains properties of a DCM account. /// /// # Activities @@ -1280,13 +1423,13 @@ pub struct DayPartTargeting { /// - "FRIDAY" /// - "SATURDAY" #[serde(rename="daysOfWeek")] - pub days_of_week: Vec<String>, + pub days_of_week: Option<Vec<String>>, /// Hours of the day when the ad will serve. Must be an integer between 0 and 23 (inclusive), where 0 is midnight to 1 AM, and 23 is 11 PM to midnight. Can be specified with days of week, in which case the ad would serve during these hours on the specified days. For example, if Monday, Wednesday, Friday are the days of week specified and 9-10am, 3-5pm (hours 9, 15, and 16) is specified, the ad would serve Monday, Wednesdays, and Fridays at 9-10am and 3-5pm. #[serde(rename="hoursOfDay")] - pub hours_of_day: Vec<i32>, + pub hours_of_day: Option<Vec<i32>>, /// Whether or not to use the user's local time. If false, the America/New York time zone applies. #[serde(rename="userLocalTime")] - pub user_local_time: bool, + pub user_local_time: Option<bool>, } impl Part for DayPartTargeting {} @@ -1304,22 +1447,22 @@ impl Part for DayPartTargeting {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CompatibleFields { /// The kind of resource this is, in this case dfareporting#compatibleFields. - pub kind: String, + pub kind: Option<String>, /// Contains items that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". #[serde(rename="crossDimensionReachReportCompatibleFields")] - pub cross_dimension_reach_report_compatible_fields: CrossDimensionReachReportCompatibleFields, + pub cross_dimension_reach_report_compatible_fields: Option<CrossDimensionReachReportCompatibleFields>, /// Contains items that are compatible to be selected for a report of type "REACH". #[serde(rename="reachReportCompatibleFields")] - pub reach_report_compatible_fields: ReachReportCompatibleFields, + pub reach_report_compatible_fields: Option<ReachReportCompatibleFields>, /// Contains items that are compatible to be selected for a report of type "PATH_TO_CONVERSION". #[serde(rename="pathToConversionReportCompatibleFields")] - pub path_to_conversion_report_compatible_fields: PathToConversionReportCompatibleFields, + pub path_to_conversion_report_compatible_fields: Option<PathToConversionReportCompatibleFields>, /// Contains items that are compatible to be selected for a report of type "FLOODLIGHT". #[serde(rename="floodlightReportCompatibleFields")] - pub floodlight_report_compatible_fields: FloodlightReportCompatibleFields, + pub floodlight_report_compatible_fields: Option<FloodlightReportCompatibleFields>, /// Contains items that are compatible to be selected for a report of type "STANDARD". #[serde(rename="reportCompatibleFields")] - pub report_compatible_fields: ReportCompatibleFields, + pub report_compatible_fields: Option<ReportCompatibleFields>, } impl ResponseResult for CompatibleFields {} @@ -1364,28 +1507,51 @@ impl Resource for Region {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCriteria { /// Activity group. - pub activities: Activities, + pub activities: Option<Activities>, /// The list of standard dimensions the report should include. - pub dimensions: Vec<SortedDimension>, + pub dimensions: Option<Vec<SortedDimension>>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, /// The date range for which this report should be run. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// Custom Rich Media Events group. #[serde(rename="customRichMediaEvents")] - pub custom_rich_media_events: CustomRichMediaEvents, + pub custom_rich_media_events: Option<CustomRichMediaEvents>, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<DimensionValue>, + pub dimension_filters: Option<Vec<DimensionValue>>, } impl NestedType for ReportCriteria {} impl Part for ReportCriteria {} +/// Order List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list orders](struct.OrderListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrdersListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ordersListResponse". + pub kind: Option<String>, + /// Order collection. + pub orders: Option<Vec<Order>>, +} + +impl ResponseResult for OrdersListResponse {} + + /// Represents fields that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1393,17 +1559,17 @@ impl Part for ReportCriteria {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CrossDimensionReachReportCompatibleFields { /// Dimensions which are compatible to be selected in the "breakdown" section of the report. - pub breakdown: Vec<Dimension>, + pub breakdown: Option<Vec<Dimension>>, /// Metrics which are compatible to be selected in the "metricNames" section of the report. - pub metrics: Vec<Metric>, + pub metrics: Option<Vec<Metric>>, /// The kind of resource this is, in this case dfareporting#crossDimensionReachReportCompatibleFields. - pub kind: String, + pub kind: Option<String>, /// Metrics which are compatible to be selected in the "overlapMetricNames" section of the report. #[serde(rename="overlapMetrics")] - pub overlap_metrics: Vec<Metric>, + pub overlap_metrics: Option<Vec<Metric>>, /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<Dimension>, + pub dimension_filters: Option<Vec<Dimension>>, } impl Part for CrossDimensionReachReportCompatibleFields {} @@ -1465,9 +1631,9 @@ impl ResponseResult for UserRole {} pub struct EventTagsListResponse { /// Event tag collection. #[serde(rename="eventTags")] - pub event_tags: Vec<EventTag>, + pub event_tags: Option<Vec<EventTag>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTagsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for EventTagsListResponse {} @@ -1536,11 +1702,11 @@ impl ResponseResult for FloodlightActivityGroup {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AudienceSegment { /// Weight allocated to this segment. Must be between 1 and 1000. The weight assigned will be understood in proportion to the weights assigned to other segments in the same segment group. - pub allocation: i32, + pub allocation: Option<i32>, /// ID of this audience segment. This is a read-only, auto-generated field. - pub id: String, + pub id: Option<String>, /// Name of this audience segment. This is a required field and must be less than 65 characters long. - pub name: String, + pub name: Option<String>, } impl Part for AudienceSegment {} @@ -1661,43 +1827,43 @@ impl ResponseResult for Campaign {} pub struct ChangeLog { /// Time when the object was modified. #[serde(rename="changeTime")] - pub change_time: String, + pub change_time: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLog". - pub kind: String, + pub kind: Option<String>, /// Subaccount ID of the modified object. #[serde(rename="subaccountId")] - pub subaccount_id: String, + pub subaccount_id: Option<String>, /// Old value of the object field. #[serde(rename="oldValue")] - pub old_value: String, + pub old_value: Option<String>, /// ID of the object of this change log. The object could be a campaign, placement, ad, or other type. #[serde(rename="objectId")] - pub object_id: String, + pub object_id: Option<String>, /// ID of this change log. - pub id: String, + pub id: Option<String>, /// User profile name of the user who modified the object. #[serde(rename="userProfileName")] - pub user_profile_name: String, + pub user_profile_name: Option<String>, /// Field name of the object which changed. #[serde(rename="fieldName")] - pub field_name: String, + pub field_name: Option<String>, /// ID of the user who modified the object. #[serde(rename="userProfileId")] - pub user_profile_id: String, + pub user_profile_id: Option<String>, /// Action which caused the change. - pub action: String, + pub action: Option<String>, /// Transaction ID of this change log. When a single API call results in many changes, each change will have a separate ID in the change log but will share the same transactionId. #[serde(rename="transactionId")] - pub transaction_id: String, + pub transaction_id: Option<String>, /// Account ID of the modified object. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option<String>, /// New value of the object field. #[serde(rename="newValue")] - pub new_value: String, + pub new_value: Option<String>, /// Object type of the change log. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, } impl Resource for ChangeLog {} @@ -1719,29 +1885,29 @@ impl ResponseResult for ChangeLog {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct File { /// The status of the report file. - pub status: String, + pub status: Option<String>, /// The kind of resource this is, in this case dfareporting#file. - pub kind: String, + pub kind: Option<String>, /// The output format of the report. Only available once the file is available. - pub format: String, + pub format: Option<String>, /// The date range for which the file has report data. The date range will always be the absolute date range for which the report is run. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// The filename of the file. #[serde(rename="fileName")] - pub file_name: String, + pub file_name: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The ID of the report this file was generated from. #[serde(rename="reportId")] - pub report_id: String, + pub report_id: Option<String>, /// The URLs where the completed report file can be downloaded. - pub urls: FileUrls, + pub urls: Option<FileUrls>, /// The timestamp in milliseconds since epoch when this file was last modified. #[serde(rename="lastModifiedTime")] - pub last_modified_time: String, + pub last_modified_time: Option<String>, /// The unique ID of this report file. - pub id: String, + pub id: Option<String>, } impl Resource for File {} @@ -1755,7 +1921,7 @@ impl ResponseResult for File {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct KeyValueTargetingExpression { /// Keyword expression being targeted by the ad. - pub expression: String, + pub expression: Option<String>, } impl Part for KeyValueTargetingExpression {} @@ -1768,241 +1934,29 @@ impl Part for KeyValueTargetingExpression {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCrossDimensionReachCriteria { /// The list of dimensions the report should include. - pub breakdown: Vec<SortedDimension>, + pub breakdown: Option<Vec<SortedDimension>>, /// Whether the report is pivoted or not. Defaults to true. - pub pivoted: bool, + pub pivoted: Option<bool>, /// The list of names of overlap metrics the report should include. #[serde(rename="overlapMetricNames")] - pub overlap_metric_names: Vec<String>, + pub overlap_metric_names: Option<Vec<String>>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, /// The date range this report should be run for. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// The list of filters on which dimensions are filtered. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<DimensionValue>, + pub dimension_filters: Option<Vec<DimensionValue>>, /// The dimension option. - pub dimension: String, + pub dimension: Option<String>, } impl NestedType for ReportCrossDimensionReachCriteria {} impl Part for ReportCrossDimensionReachCriteria {} -/// Audience Segment Group. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct AudienceSegmentGroup { - /// Audience segments assigned to this group. The number of segments must be between 2 and 100. - #[serde(rename="audienceSegments")] - pub audience_segments: Vec<AudienceSegment>, - /// ID of this audience segment group. This is a read-only, auto-generated field. - pub id: String, - /// Name of this audience segment group. This is a required field and must be less than 65 characters long. - pub name: String, -} - -impl Part for AudienceSegmentGroup {} - - -/// Contains properties of a placement strategy. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [patch placement strategies](struct.PlacementStrategyPatchCall.html) (request|response) -/// * [insert placement strategies](struct.PlacementStrategyInsertCall.html) (request|response) -/// * [get placement strategies](struct.PlacementStrategyGetCall.html) (response) -/// * [update placement strategies](struct.PlacementStrategyUpdateCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PlacementStrategy { - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy". - pub kind: Option<String>, - /// Account ID of this placement strategy.This is a read-only field that can be left blank. - #[serde(rename="accountId")] - pub account_id: Option<String>, - /// ID of this placement strategy. This is a read-only, auto-generated field. - pub id: Option<String>, - /// Name of this placement strategy. This is a required field. It must be less than 256 characters long and unique among placement strategies of the same account. - pub name: Option<String>, -} - -impl RequestValue for PlacementStrategy {} -impl ResponseResult for PlacementStrategy {} - - -/// Placement Tag -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct PlacementTag { - /// Tags generated for this placement. - #[serde(rename="tagDatas")] - pub tag_datas: Vec<TagData>, - /// Placement ID - #[serde(rename="placementId")] - pub placement_id: String, -} - -impl Part for PlacementTag {} - - -/// Country List Response -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list countries](struct.CountryListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CountriesListResponse { - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse". - pub kind: String, - /// Country collection. - pub countries: Vec<Country>, -} - -impl ResponseResult for CountriesListResponse {} - - -/// Click-through URL -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ClickThroughUrl { - /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false. - #[serde(rename="landingPageId")] - pub landing_page_id: String, - /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset. - #[serde(rename="customClickThroughUrl")] - pub custom_click_through_url: String, - /// Whether the campaign default landing page is used. - #[serde(rename="defaultLandingPage")] - pub default_landing_page: bool, -} - -impl Part for ClickThroughUrl {} - - -/// Companion Click-through override. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CompanionClickThroughOverride { - /// Click-through URL of this companion click-through override. - #[serde(rename="clickThroughUrl")] - pub click_through_url: ClickThroughUrl, - /// ID of the creative for this companion click-through override. - #[serde(rename="creativeId")] - pub creative_id: String, -} - -impl Part for CompanionClickThroughOverride {} - - -/// Frequency Cap. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct FrequencyCap { - /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days in seconds, or 7,776,000. - pub duration: String, - /// Number of times an individual user can be served the ad within the specified duration. The maximum allowed is 15. - pub impressions: String, -} - -impl Part for FrequencyCap {} - - -/// Identifies a creative which has been associated with a given campaign. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (none) -/// * [insert campaign creative associations](struct.CampaignCreativeAssociationInsertCall.html) (request|response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CampaignCreativeAssociation { - /// ID of the creative associated with the campaign. This is a required field. - #[serde(rename="creativeId")] - pub creative_id: Option<String>, - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation". - pub kind: Option<String>, -} - -impl RequestValue for CampaignCreativeAssociation {} -impl Resource for CampaignCreativeAssociation {} -impl ResponseResult for CampaignCreativeAssociation {} - - -/// Operating System Version List Response -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list operating system versions](struct.OperatingSystemVersionListCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperatingSystemVersionsListResponse { - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse". - pub kind: String, - /// Operating system version collection. - #[serde(rename="operatingSystemVersions")] - pub operating_system_versions: Vec<OperatingSystemVersion>, -} - -impl ResponseResult for OperatingSystemVersionsListResponse {} - - -/// Organizes placements according to the contents of their associated webpages. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [patch content categories](struct.ContentCategoryPatchCall.html) (request|response) -/// * [insert content categories](struct.ContentCategoryInsertCall.html) (request|response) -/// * [update content categories](struct.ContentCategoryUpdateCall.html) (request|response) -/// * [get content categories](struct.ContentCategoryGetCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ContentCategory { - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory". - pub kind: Option<String>, - /// Account ID of this content category. This is a read-only field that can be left blank. - #[serde(rename="accountId")] - pub account_id: Option<String>, - /// Description of this content category. - pub description: Option<String>, - /// Name of this content category. This is a required field and must be less than 256 characters long and unique among content categories of the same account. - pub name: Option<String>, - /// ID of this content category. This is a read-only, auto-generated field. - pub id: Option<String>, -} - -impl RequestValue for ContentCategory {} -impl ResponseResult for ContentCategory {} - - /// Contains properties of a placement. /// /// # Activities @@ -2139,6 +2093,366 @@ impl Resource for Placement {} impl ResponseResult for Placement {} +/// Inventory item List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list inventory items](struct.InventoryItemListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItemsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItemsListResponse". + pub kind: Option<String>, + /// Inventory item collection + #[serde(rename="inventoryItems")] + pub inventory_items: Option<Vec<InventoryItem>>, +} + +impl ResponseResult for InventoryItemsListResponse {} + + +/// Audience Segment Group. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AudienceSegmentGroup { + /// Audience segments assigned to this group. The number of segments must be between 2 and 100. + #[serde(rename="audienceSegments")] + pub audience_segments: Option<Vec<AudienceSegment>>, + /// ID of this audience segment group. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Name of this audience segment group. This is a required field and must be less than 65 characters long. + pub name: Option<String>, +} + +impl Part for AudienceSegmentGroup {} + + +/// Contains properties of a placement strategy. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [patch placement strategies](struct.PlacementStrategyPatchCall.html) (request|response) +/// * [insert placement strategies](struct.PlacementStrategyInsertCall.html) (request|response) +/// * [get placement strategies](struct.PlacementStrategyGetCall.html) (response) +/// * [update placement strategies](struct.PlacementStrategyUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementStrategy { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy". + pub kind: Option<String>, + /// Account ID of this placement strategy.This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// ID of this placement strategy. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Name of this placement strategy. This is a required field. It must be less than 256 characters long and unique among placement strategies of the same account. + pub name: Option<String>, +} + +impl RequestValue for PlacementStrategy {} +impl ResponseResult for PlacementStrategy {} + + +/// Placement Tag +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlacementTag { + /// Tags generated for this placement. + #[serde(rename="tagDatas")] + pub tag_datas: Option<Vec<TagData>>, + /// Placement ID + #[serde(rename="placementId")] + pub placement_id: Option<String>, +} + +impl Part for PlacementTag {} + + +/// Country List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list countries](struct.CountryListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CountriesListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse". + pub kind: Option<String>, + /// Country collection. + pub countries: Option<Vec<Country>>, +} + +impl ResponseResult for CountriesListResponse {} + + +/// Click-through URL +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ClickThroughUrl { + /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false. + #[serde(rename="landingPageId")] + pub landing_page_id: Option<String>, + /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset. + #[serde(rename="customClickThroughUrl")] + pub custom_click_through_url: Option<String>, + /// Whether the campaign default landing page is used. + #[serde(rename="defaultLandingPage")] + pub default_landing_page: Option<bool>, +} + +impl Part for ClickThroughUrl {} + + +/// Companion Click-through override. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CompanionClickThroughOverride { + /// Click-through URL of this companion click-through override. + #[serde(rename="clickThroughUrl")] + pub click_through_url: Option<ClickThroughUrl>, + /// ID of the creative for this companion click-through override. + #[serde(rename="creativeId")] + pub creative_id: Option<String>, +} + +impl Part for CompanionClickThroughOverride {} + + +/// Frequency Cap. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct FrequencyCap { + /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days in seconds, or 7,776,000. + pub duration: Option<String>, + /// Number of times an individual user can be served the ad within the specified duration. The maximum allowed is 15. + pub impressions: Option<String>, +} + +impl Part for FrequencyCap {} + + +/// Identifies a creative which has been associated with a given campaign. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list campaign creative associations](struct.CampaignCreativeAssociationListCall.html) (none) +/// * [insert campaign creative associations](struct.CampaignCreativeAssociationInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CampaignCreativeAssociation { + /// ID of the creative associated with the campaign. This is a required field. + #[serde(rename="creativeId")] + pub creative_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation". + pub kind: Option<String>, +} + +impl RequestValue for CampaignCreativeAssociation {} +impl Resource for CampaignCreativeAssociation {} +impl ResponseResult for CampaignCreativeAssociation {} + + +/// Contains properties of a remarketing list's sharing information. Sharing allows other accounts or advertisers to target to your remarketing lists. This resource can be used to manage remarketing list sharing to other accounts and advertisers. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get remarketing list shares](struct.RemarketingListShareGetCall.html) (response) +/// * [patch remarketing list shares](struct.RemarketingListSharePatchCall.html) (request|response) +/// * [update remarketing list shares](struct.RemarketingListShareUpdateCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingListShare { + /// Advertisers that the remarketing list is shared with. + #[serde(rename="sharedAdvertiserIds")] + pub shared_advertiser_ids: Option<Vec<String>>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListShare". + pub kind: Option<String>, + /// Remarketing list ID. This is a read-only, auto-generated field. + #[serde(rename="remarketingListId")] + pub remarketing_list_id: Option<String>, + /// Accounts that the remarketing list is shared with. + #[serde(rename="sharedAccountIds")] + pub shared_account_ids: Option<Vec<String>>, +} + +impl RequestValue for RemarketingListShare {} +impl Resource for RemarketingListShare {} +impl ResponseResult for RemarketingListShare {} + + +/// Operating System Version List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list operating system versions](struct.OperatingSystemVersionListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperatingSystemVersionsListResponse { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse". + pub kind: Option<String>, + /// Operating system version collection. + #[serde(rename="operatingSystemVersions")] + pub operating_system_versions: Option<Vec<OperatingSystemVersion>>, +} + +impl ResponseResult for OperatingSystemVersionsListResponse {} + + +/// Organizes placements according to the contents of their associated webpages. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [patch content categories](struct.ContentCategoryPatchCall.html) (request|response) +/// * [insert content categories](struct.ContentCategoryInsertCall.html) (request|response) +/// * [update content categories](struct.ContentCategoryUpdateCall.html) (request|response) +/// * [get content categories](struct.ContentCategoryGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentCategory { + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory". + pub kind: Option<String>, + /// Account ID of this content category. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// ID of this content category. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Name of this content category. This is a required field and must be less than 256 characters long and unique among content categories of the same account. + pub name: Option<String>, +} + +impl RequestValue for ContentCategory {} +impl ResponseResult for ContentCategory {} + + +/// Targetable remarketing list response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list targetable remarketing lists](struct.TargetableRemarketingListListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct TargetableRemarketingListsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingListsListResponse". + pub kind: Option<String>, + /// Targetable remarketing list collection. + #[serde(rename="targetableRemarketingLists")] + pub targetable_remarketing_lists: Option<Vec<TargetableRemarketingList>>, +} + +impl ResponseResult for TargetableRemarketingListsListResponse {} + + +/// Represents a buy from the DoubleClick Planning inventory store. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get inventory items](struct.InventoryItemGetCall.html) (response) +/// * [list inventory items](struct.InventoryItemListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InventoryItem { + /// Order ID of this inventory item. + #[serde(rename="orderId")] + pub order_id: Option<String>, + /// Advertiser ID of this inventory item. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// ID of the site this inventory item is associated with. + #[serde(rename="siteId")] + pub site_id: Option<String>, + /// Ad slots of this inventory item. If this inventory item represents a standalone placement, there will be exactly one ad slot. If this inventory item represents a placement group, there will be more than one ad slot, each representing one child placement in that placement group. + #[serde(rename="adSlots")] + pub ad_slots: Option<Vec<AdSlot>>, + /// RFP ID of this inventory item. + #[serde(rename="rfpId")] + pub rfp_id: Option<String>, + /// Content category ID of this inventory item. + #[serde(rename="contentCategoryId")] + pub content_category_id: Option<String>, + /// Placement strategy ID of this inventory item. + #[serde(rename="placementStrategyId")] + pub placement_strategy_id: Option<String>, + /// Account ID of this inventory item. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItem". + pub kind: Option<String>, + /// Negotiation channel ID of this inventory item. + #[serde(rename="negotiationChannelId")] + pub negotiation_channel_id: Option<String>, + /// Subaccount ID of this inventory item. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Name of this inventory item. For standalone inventory items, this is the same name as that of its only ad slot. For group inventory items, this can differ from the name of any of its ad slots. + pub name: Option<String>, + /// Estimated click-through rate of this inventory item. + #[serde(rename="estimatedClickThroughRate")] + pub estimated_click_through_rate: Option<String>, + /// Information about the most recent modification of this inventory item. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option<LastModifiedInfo>, + /// Estimated conversion rate of this inventory item. + #[serde(rename="estimatedConversionRate")] + pub estimated_conversion_rate: Option<String>, + /// Whether this inventory item is in plan. + #[serde(rename="inPlan")] + pub in_plan: Option<bool>, + /// ID of this inventory item. + pub id: Option<String>, + /// Project ID of this inventory item. + #[serde(rename="projectId")] + pub project_id: Option<String>, + /// Pricing of this inventory item. + pub pricing: Option<Pricing>, +} + +impl Resource for InventoryItem {} +impl ResponseResult for InventoryItem {} + + /// Represents fields that are compatible to be selected for a report of type "FlOODLIGHT". /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2146,14 +2460,14 @@ impl ResponseResult for Placement {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightReportCompatibleFields { /// Metrics which are compatible to be selected in the "metricNames" section of the report. - pub metrics: Vec<Metric>, + pub metrics: Option<Vec<Metric>>, /// The kind of resource this is, in this case dfareporting#floodlightReportCompatibleFields. - pub kind: String, + pub kind: Option<String>, /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<Dimension>, + pub dimension_filters: Option<Vec<Dimension>>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. - pub dimensions: Vec<Dimension>, + pub dimensions: Option<Vec<Dimension>>, } impl Part for FloodlightReportCompatibleFields {} @@ -2167,9 +2481,9 @@ impl Part for FloodlightReportCompatibleFields {} pub struct CreativeAssetId { /// Type of asset to upload. This is a required field. IMAGE is solely used for IMAGE creatives. Other image assets should use HTML_IMAGE. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Name of the creative asset. This is a required field while inserting an asset. After insertion, this assetIdentifier is used to identify the uploaded asset. Characters in the name must be alphanumeric or one of the following: ".-_ ". Spaces are allowed. - pub name: String, + pub name: Option<String>, } impl Part for CreativeAssetId {} @@ -2183,9 +2497,9 @@ impl Part for CreativeAssetId {} pub struct DirectorySiteContactAssignment { /// ID of this directory site contact. This is a read-only, auto-generated field. #[serde(rename="contactId")] - pub contact_id: String, + pub contact_id: Option<String>, /// Visibility of this directory site contact assignment. When set to PUBLIC this contact assignment is visible to all account and agency users; when set to PRIVATE it is visible only to the site. - pub visibility: String, + pub visibility: Option<String>, } impl Part for DirectorySiteContactAssignment {} @@ -2198,12 +2512,12 @@ impl Part for DirectorySiteContactAssignment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAssignment { /// Weight of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_RANDOM. - pub weight: i32, + pub weight: Option<i32>, /// Sequence number of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_SEQUENTIAL. - pub sequence: i32, + pub sequence: Option<i32>, /// Click-through URL of the creative assignment. #[serde(rename="clickThroughUrl")] - pub click_through_url: ClickThroughUrl, + pub click_through_url: Option<ClickThroughUrl>, /// Rich media exit overrides for this creative assignment. /// Applicable when the creative type is any of the following: /// - RICH_MEDIA_INPAGE @@ -2218,33 +2532,33 @@ pub struct CreativeAssignment { /// - VPAID_LINEAR /// - VPAID_NON_LINEAR #[serde(rename="richMediaExitOverrides")] - pub rich_media_exit_overrides: Vec<RichMediaExitOverride>, + pub rich_media_exit_overrides: Option<Vec<RichMediaExitOverride>>, /// Whether applicable event tags should fire when this creative assignment is rendered. If this value is unset when the ad is inserted or updated, it will default to true for all creative types EXCEPT for INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO. #[serde(rename="applyEventTags")] - pub apply_event_tags: bool, + pub apply_event_tags: Option<bool>, /// Creative group assignments for this creative assignment. Only one assignment per creative group number is allowed for a maximum of two assignments. #[serde(rename="creativeGroupAssignments")] - pub creative_group_assignments: Vec<CreativeGroupAssignment>, + pub creative_group_assignments: Option<Vec<CreativeGroupAssignment>>, /// Companion creative overrides for this creative assignment. Applicable to video ads. #[serde(rename="companionCreativeOverrides")] - pub companion_creative_overrides: Vec<CompanionClickThroughOverride>, + pub companion_creative_overrides: Option<Vec<CompanionClickThroughOverride>>, /// Date and time that the assigned creative should start serving. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// Whether the creative to be assigned is SSL-compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. #[serde(rename="sslCompliant")] - pub ssl_compliant: bool, + pub ssl_compliant: Option<bool>, /// Whether this creative assignment is active. When true, the creative will be included in the ad's rotation. - pub active: bool, + pub active: Option<bool>, /// ID of the creative to be assigned. This is a required field. #[serde(rename="creativeId")] - pub creative_id: String, + pub creative_id: Option<String>, /// Date and time that the assigned creative should stop serving. Must be later than the start time. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// Dimension value for the ID of the creative. This is a read-only, auto-generated field. #[serde(rename="creativeIdDimensionValue")] - pub creative_id_dimension_value: DimensionValue, + pub creative_id_dimension_value: Option<DimensionValue>, } impl Part for CreativeAssignment {} @@ -2279,6 +2593,35 @@ pub struct DimensionValueRequest { impl RequestValue for DimensionValueRequest {} +/// Ad Slot +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AdSlot { + /// Comment for this ad slot. + pub comment: Option<String>, + /// ID of the placement from an external platform that is linked to this ad slot. + #[serde(rename="linkedPlacementId")] + pub linked_placement_id: Option<String>, + /// Name of this ad slot. + pub name: Option<String>, + /// Primary ad slot of a roadblock inventory item. + pub primary: Option<bool>, + /// Height of this ad slot. + pub height: Option<String>, + /// Width of this ad slot. + pub width: Option<String>, + /// Payment source type of this ad slot. + #[serde(rename="paymentSourceType")] + pub payment_source_type: Option<String>, + /// Ad slot compatibility. WEB and WEB_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. + pub compatibility: Option<String>, +} + +impl Part for AdSlot {} + + /// Properties of inheriting and overriding the default click-through event tag. A campaign may override the event tag defined at the advertiser level, and an ad may also override the campaign's setting further. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2287,10 +2630,10 @@ impl RequestValue for DimensionValueRequest {} pub struct DefaultClickThroughEventTagProperties { /// Whether this entity should override the inherited default click-through event tag with its own defined value. #[serde(rename="overrideInheritedEventTag")] - pub override_inherited_event_tag: bool, + pub override_inherited_event_tag: Option<bool>, /// ID of the click-through event tag to apply to all ads in this entity's scope. #[serde(rename="defaultClickThroughEventTagId")] - pub default_click_through_event_tag_id: String, + pub default_click_through_event_tag_id: Option<String>, } impl Part for DefaultClickThroughEventTagProperties {} @@ -2308,11 +2651,11 @@ impl Part for DefaultClickThroughEventTagProperties {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserProfileList { /// The user profiles returned in this response. - pub items: Vec<UserProfile>, + pub items: Option<Vec<UserProfile>>, /// The kind of list this is, in this case dfareporting#userProfileList. - pub kind: String, + pub kind: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for UserProfileList {} @@ -2331,16 +2674,74 @@ impl ResponseResult for UserProfileList {} pub struct SubaccountsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccountsListResponse". - pub kind: String, + pub kind: Option<String>, /// Subaccount collection. - pub subaccounts: Vec<Subaccount>, + pub subaccounts: Option<Vec<Subaccount>>, } impl ResponseResult for SubaccountsListResponse {} +/// Contains properties of a DoubleClick Planning order document. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get order documents](struct.OrderDocumentGetCall.html) (response) +/// * [list order documents](struct.OrderDocumentListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocument { + /// ID of the order from which this order document is created. + #[serde(rename="orderId")] + pub order_id: Option<String>, + /// Advertiser ID of this order document. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocument". + pub kind: Option<String>, + /// Subaccount ID of this order document. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Effective date of this order document. + #[serde(rename="effectiveDate")] + pub effective_date: Option<String>, + /// Title of this order document. + pub title: Option<String>, + /// Project ID of this order document. + #[serde(rename="projectId")] + pub project_id: Option<String>, + /// The amended order document ID of this order document. An order document can be created by optionally amending another order document so that the change history can be preserved. + #[serde(rename="amendedOrderDocumentId")] + pub amended_order_document_id: Option<String>, + /// Whether this order document has been signed. + pub signed: Option<bool>, + /// Information about the creation of this order document. + #[serde(rename="createdInfo")] + pub created_info: Option<LastModifiedInfo>, + /// IDs of users who have approved this order document. + #[serde(rename="approvedByUserProfileIds")] + pub approved_by_user_profile_ids: Option<Vec<String>>, + /// Whether this order document is cancelled. + pub cancelled: Option<bool>, + /// Type of this order document + #[serde(rename="type")] + pub type_: Option<String>, + /// ID of this order document. + pub id: Option<String>, + /// Account ID of this order document. + #[serde(rename="accountId")] + pub account_id: Option<String>, +} + +impl Resource for OrderDocument {} +impl ResponseResult for OrderDocument {} + + /// Represents a Report resource. /// /// # Activities @@ -2421,6 +2822,7 @@ impl ResponseResult for Report {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// +/// * [get platform types](struct.PlatformTypeGetCall.html) (response) /// * [list platform types](struct.PlatformTypeListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -2434,6 +2836,7 @@ pub struct PlatformType { } impl Resource for PlatformType {} +impl ResponseResult for PlatformType {} /// Advertiser List Response @@ -2449,11 +2852,11 @@ impl Resource for PlatformType {} pub struct AdvertisersListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Advertiser collection. - pub advertisers: Vec<Advertiser>, + pub advertisers: Option<Vec<Advertiser>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertisersListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AdvertisersListResponse {} @@ -2612,12 +3015,12 @@ impl Resource for CreativeAsset {} pub struct DirectorySitesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySitesListResponse". - pub kind: String, + pub kind: Option<String>, /// Directory site collection. #[serde(rename="directorySites")] - pub directory_sites: Vec<DirectorySite>, + pub directory_sites: Option<Vec<DirectorySite>>, } impl ResponseResult for DirectorySitesListResponse {} @@ -2630,7 +3033,7 @@ impl ResponseResult for DirectorySitesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LastModifiedInfo { /// Timestamp of the last change in milliseconds since epoch. - pub time: String, + pub time: Option<String>, } impl Part for LastModifiedInfo {} @@ -2648,9 +3051,9 @@ impl Part for LastModifiedInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RegionsListResponse { /// Region collection. - pub regions: Vec<Region>, + pub regions: Option<Vec<Region>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#regionsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for RegionsListResponse {} @@ -2669,11 +3072,11 @@ impl ResponseResult for RegionsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolePermissionGroup { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroup". - pub kind: String, + pub kind: Option<String>, /// ID of this user role permission. - pub id: String, + pub id: Option<String>, /// Name of this user role permission group. - pub name: String, + pub name: Option<String>, } impl Resource for UserRolePermissionGroup {} @@ -2688,11 +3091,11 @@ impl ResponseResult for UserRolePermissionGroup {} pub struct ClickTag { /// Advertiser event name associated with the click tag. This field is used by ENHANCED_BANNER, ENHANCED_IMAGE, and HTML5_BANNER creatives. #[serde(rename="eventName")] - pub event_name: String, + pub event_name: Option<String>, /// Parameter name for the specified click tag. For ENHANCED_IMAGE creative assets, this field must match the value of the creative asset's creativeAssetId.name field. - pub name: String, + pub name: Option<String>, /// Parameter value for the specified click tag. This field contains a click-through url. - pub value: String, + pub value: Option<String>, } impl Part for ClickTag {} @@ -2705,6 +3108,7 @@ impl Part for ClickTag {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// +/// * [get connection types](struct.ConnectionTypeGetCall.html) (response) /// * [list connection types](struct.ConnectionTypeListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -2718,6 +3122,7 @@ pub struct ConnectionType { } impl Resource for ConnectionType {} +impl ResponseResult for ConnectionType {} /// Browser List Response @@ -2732,9 +3137,9 @@ impl Resource for ConnectionType {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BrowsersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browsersListResponse". - pub kind: String, + pub kind: Option<String>, /// Browser collection. - pub browsers: Vec<Browser>, + pub browsers: Option<Vec<Browser>>, } impl ResponseResult for BrowsersListResponse {} @@ -2748,11 +3153,11 @@ impl ResponseResult for BrowsersListResponse {} pub struct ObjectFilter { /// Applicable when status is ASSIGNED. The user has access to objects with these object IDs. #[serde(rename="objectIds")] - pub object_ids: Vec<String>, + pub object_ids: Option<Vec<String>>, /// Status of the filter. NONE means the user has access to none of the objects. ALL means the user has access to all objects. ASSIGNED means the user has access to the objects with IDs in the objectIds list. - pub status: String, + pub status: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#objectFilter". - pub kind: String, + pub kind: Option<String>, } impl Part for ObjectFilter {} @@ -2766,10 +3171,10 @@ impl Part for ObjectFilter {} pub struct CreativeSettings { /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. #[serde(rename="iFrameHeader")] - pub i_frame_header: String, + pub i_frame_header: Option<String>, /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. #[serde(rename="iFrameFooter")] - pub i_frame_footer: String, + pub i_frame_footer: Option<String>, } impl Part for CreativeSettings {} @@ -2782,53 +3187,38 @@ impl Part for CreativeSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Dimension { /// The kind of resource this is, in this case dfareporting#dimension. - pub kind: String, + pub kind: Option<String>, /// The dimension name, e.g. dfa:advertiser - pub name: String, + pub name: Option<String>, } impl Part for Dimension {} -/// Contains properties of a creative field. +/// Contact of an order. /// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [list creative fields](struct.CreativeFieldListCall.html) (none) -/// * [update creative fields](struct.CreativeFieldUpdateCall.html) (request|response) -/// * [get creative fields](struct.CreativeFieldGetCall.html) (response) -/// * [insert creative fields](struct.CreativeFieldInsertCall.html) (request|response) -/// * [delete creative fields](struct.CreativeFieldDeleteCall.html) (none) -/// * [patch creative fields](struct.CreativeFieldPatchCall.html) (request|response) +/// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct CreativeField { - /// Advertiser ID of this creative field. This is a required field on insertion. - #[serde(rename="advertiserId")] - pub advertiser_id: Option<String>, - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField". - pub kind: Option<String>, - /// Subaccount ID of this creative field. This is a read-only field that can be left blank. - #[serde(rename="subaccountId")] - pub subaccount_id: Option<String>, - /// Name of this creative field. This is a required field and must be less than 256 characters long and unique among creative fields of the same advertiser. - pub name: Option<String>, - /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. - #[serde(rename="advertiserIdDimensionValue")] - pub advertiser_id_dimension_value: Option<DimensionValue>, - /// ID of this creative field. This is a read-only, auto-generated field. - pub id: Option<String>, - /// Account ID of this creative field. This is a read-only field that can be left blank. - #[serde(rename="accountId")] - pub account_id: Option<String>, +pub struct OrderContact { + /// Type of this contact. + #[serde(rename="contactType")] + pub contact_type: Option<String>, + /// Title of this contact. + #[serde(rename="contactTitle")] + pub contact_title: Option<String>, + /// Free-form information about this contact. It could be any information related to this contact in addition to type, title, name, and signature user profile ID. + #[serde(rename="contactInfo")] + pub contact_info: Option<String>, + /// Name of this contact. + #[serde(rename="contactName")] + pub contact_name: Option<String>, + /// ID of the user profile containing the signature that will be embedded into order documents. + #[serde(rename="signatureUserProfileId")] + pub signature_user_profile_id: Option<String>, } -impl RequestValue for CreativeField {} -impl Resource for CreativeField {} -impl ResponseResult for CreativeField {} +impl Part for OrderContact {} /// DirectorySites contains properties of a website from the Site Directory. Sites need to be added to an account via the Sites resource before they can be assigned to a placement. @@ -2840,18 +3230,19 @@ impl ResponseResult for CreativeField {} /// /// * [get directory sites](struct.DirectorySiteGetCall.html) (response) /// * [list directory sites](struct.DirectorySiteListCall.html) (none) +/// * [insert directory sites](struct.DirectorySiteInsertCall.html) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySite { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySite". - pub kind: String, + pub kind: Option<String>, /// Country ID of this directory site. #[serde(rename="countryId")] - pub country_id: String, + pub country_id: Option<String>, /// Description of this directory site. - pub description: String, + pub description: Option<String>, /// Directory site settings. - pub settings: DirectorySiteSettings, + pub settings: Option<DirectorySiteSettings>, /// Currency ID of this directory site. /// Possible values are: /// - "1" for USD @@ -2891,7 +3282,7 @@ pub struct DirectorySite { /// - "35" for COP /// - "36" for GTQ #[serde(rename="currencyId")] - pub currency_id: String, + pub currency_id: Option<String>, /// Tag types for regular placements. /// /// Acceptable values are: @@ -2900,15 +3291,15 @@ pub struct DirectorySite { /// - "INTERNAL_REDIRECT_INPAGE" /// - "JAVASCRIPT_INPAGE" #[serde(rename="inpageTagFormats")] - pub inpage_tag_formats: Vec<String>, + pub inpage_tag_formats: Option<Vec<String>>, /// URL of this directory site. - pub url: String, + pub url: Option<String>, /// Directory site contacts. #[serde(rename="contactAssignments")] - pub contact_assignments: Vec<DirectorySiteContactAssignment>, + pub contact_assignments: Option<Vec<DirectorySiteContactAssignment>>, /// Parent directory site ID. #[serde(rename="parentId")] - pub parent_id: String, + pub parent_id: Option<String>, /// Tag types for interstitial placements. /// /// Acceptable values are: @@ -2916,18 +3307,19 @@ pub struct DirectorySite { /// - "INTERNAL_REDIRECT_INTERSTITIAL" /// - "JAVASCRIPT_INTERSTITIAL" #[serde(rename="interstitialTagFormats")] - pub interstitial_tag_formats: Vec<String>, + pub interstitial_tag_formats: Option<Vec<String>>, /// Dimension value for the ID of this directory site. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] - pub id_dimension_value: DimensionValue, + pub id_dimension_value: Option<DimensionValue>, /// Whether this directory site is active. - pub active: bool, + pub active: Option<bool>, /// ID of this directory site. This is a read-only, auto-generated field. - pub id: String, + pub id: Option<String>, /// Name of this directory site. - pub name: String, + pub name: Option<String>, } +impl RequestValue for DirectorySite {} impl Resource for DirectorySite {} impl ResponseResult for DirectorySite {} @@ -2944,9 +3336,9 @@ impl ResponseResult for DirectorySite {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CitiesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#citiesListResponse". - pub kind: String, + pub kind: Option<String>, /// City collection. - pub cities: Vec<City>, + pub cities: Option<Vec<City>>, } impl ResponseResult for CitiesListResponse {} @@ -3005,9 +3397,9 @@ impl ResponseResult for CreativeGroup {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metric { /// The kind of resource this is, in this case dfareporting#metric. - pub kind: String, + pub kind: Option<String>, /// The metric name, e.g. dfa:impressions - pub name: String, + pub name: Option<String>, } impl Part for Metric {} @@ -3021,13 +3413,13 @@ impl Part for Metric {} pub struct RichMediaExitOverride { /// Click-through URL to override the default exit URL. Applicable if the useCustomExitUrl field is set to true. #[serde(rename="customExitUrl")] - pub custom_exit_url: String, + pub custom_exit_url: Option<String>, /// Whether to use the custom exit URL. #[serde(rename="useCustomExitUrl")] - pub use_custom_exit_url: bool, + pub use_custom_exit_url: Option<bool>, /// ID for the override to refer to a specific exit in the creative. #[serde(rename="exitId")] - pub exit_id: String, + pub exit_id: Option<String>, } impl Part for RichMediaExitOverride {} @@ -3046,9 +3438,9 @@ impl Part for RichMediaExitOverride {} pub struct AccountPermissionsListResponse { /// Account permission collection. #[serde(rename="accountPermissions")] - pub account_permissions: Vec<AccountPermission>, + pub account_permissions: Option<Vec<AccountPermission>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AccountPermissionsListResponse {} @@ -3066,10 +3458,10 @@ impl ResponseResult for AccountPermissionsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementsGenerateTagsResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsGenerateTagsResponse". - pub kind: String, + pub kind: Option<String>, /// Set of generated tags for the specified placements. #[serde(rename="placementTags")] - pub placement_tags: Vec<PlacementTag>, + pub placement_tags: Option<Vec<PlacementTag>>, } impl ResponseResult for PlacementsGenerateTagsResponse {} @@ -3117,12 +3509,12 @@ impl ResponseResult for CreativeFieldValue {} pub struct FloodlightActivityGroupsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroupsListResponse". - pub kind: String, + pub kind: Option<String>, /// Floodlight activity group collection. #[serde(rename="floodlightActivityGroups")] - pub floodlight_activity_groups: Vec<FloodlightActivityGroup>, + pub floodlight_activity_groups: Option<Vec<FloodlightActivityGroup>>, } impl ResponseResult for FloodlightActivityGroupsListResponse {} @@ -3141,12 +3533,12 @@ impl ResponseResult for FloodlightActivityGroupsListResponse {} pub struct DirectorySiteContactsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Directory site contact collection #[serde(rename="directorySiteContacts")] - pub directory_site_contacts: Vec<DirectorySiteContact>, + pub directory_site_contacts: Option<Vec<DirectorySiteContact>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContactsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for DirectorySiteContactsListResponse {} @@ -3160,32 +3552,32 @@ impl ResponseResult for DirectorySiteContactsListResponse {} pub struct CreativeCustomEvent { /// Target type used by the event. #[serde(rename="targetType")] - pub target_type: String, + pub target_type: Option<String>, /// Artwork type used by the creative.This is a read-only field. #[serde(rename="artworkType")] - pub artwork_type: String, + pub artwork_type: Option<String>, /// Reporting ID, used to differentiate multiple videos in a single creative. #[serde(rename="videoReportingId")] - pub video_reporting_id: String, + pub video_reporting_id: Option<String>, /// Properties for rich media popup windows. This field is used only for exit events. #[serde(rename="popupWindowProperties")] - pub popup_window_properties: PopupWindowProperties, + pub popup_window_properties: Option<PopupWindowProperties>, /// Artwork label column, used to link events in DCM back to events in Studio. This is a required field and should not be modified after insertion. #[serde(rename="artworkLabel")] - pub artwork_label: String, + pub artwork_label: Option<String>, /// Whether the event is active. - pub active: bool, + pub active: Option<bool>, /// Type of the event. This is a read-only field. #[serde(rename="advertiserCustomEventType")] - pub advertiser_custom_event_type: String, + pub advertiser_custom_event_type: Option<String>, /// Exit URL of the event. This field is used only for exit events. #[serde(rename="exitUrl")] - pub exit_url: String, + pub exit_url: Option<String>, /// ID of this event. This is a required field and should not be modified after insertion. - pub id: String, + pub id: Option<String>, /// User-entered name for the event. #[serde(rename="advertiserCustomEventName")] - pub advertiser_custom_event_name: String, + pub advertiser_custom_event_name: Option<String>, } impl Part for CreativeCustomEvent {} @@ -3204,11 +3596,11 @@ impl Part for CreativeCustomEvent {} pub struct CreativesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativesListResponse". - pub kind: String, + pub kind: Option<String>, /// Creative collection. - pub creatives: Vec<Creative>, + pub creatives: Option<Vec<Creative>>, } impl ResponseResult for CreativesListResponse {} @@ -3222,10 +3614,10 @@ impl ResponseResult for CreativesListResponse {} pub struct OmnitureSettings { /// Whether placement cost data will be sent to Omniture. This property can be enabled only if omnitureIntegrationEnabled is true. #[serde(rename="omnitureCostDataEnabled")] - pub omniture_cost_data_enabled: bool, + pub omniture_cost_data_enabled: Option<bool>, /// Whether Omniture integration is enabled. This property can be enabled only when the "Advanced Ad Serving" account setting is enabled. #[serde(rename="omnitureIntegrationEnabled")] - pub omniture_integration_enabled: bool, + pub omniture_integration_enabled: Option<bool>, } impl Part for OmnitureSettings {} @@ -3238,18 +3630,18 @@ impl Part for OmnitureSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PathToConversionReportCompatibleFields { /// Metrics which are compatible to be selected in the "metricNames" section of the report. - pub metrics: Vec<Metric>, + pub metrics: Option<Vec<Metric>>, /// Per-interaction dimensions which are compatible to be selected in the "perInteractionDimensions" section of the report. #[serde(rename="perInteractionDimensions")] - pub per_interaction_dimensions: Vec<Dimension>, + pub per_interaction_dimensions: Option<Vec<Dimension>>, /// The kind of resource this is, in this case dfareporting#pathToConversionReportCompatibleFields. - pub kind: String, + pub kind: Option<String>, /// Conversion dimensions which are compatible to be selected in the "conversionDimensions" section of the report. #[serde(rename="conversionDimensions")] - pub conversion_dimensions: Vec<Dimension>, + pub conversion_dimensions: Option<Vec<Dimension>>, /// Custom floodlight variables which are compatible to be selected in the "customFloodlightVariables" section of the report. #[serde(rename="customFloodlightVariables")] - pub custom_floodlight_variables: Vec<Dimension>, + pub custom_floodlight_variables: Option<Vec<Dimension>>, } impl Part for PathToConversionReportCompatibleFields {} @@ -3267,10 +3659,10 @@ impl Part for PathToConversionReportCompatibleFields {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileCarriersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarriersListResponse". - pub kind: String, + pub kind: Option<String>, /// Mobile carrier collection. #[serde(rename="mobileCarriers")] - pub mobile_carriers: Vec<MobileCarrier>, + pub mobile_carriers: Option<Vec<MobileCarrier>>, } impl ResponseResult for MobileCarriersListResponse {} @@ -3283,11 +3675,11 @@ impl ResponseResult for MobileCarriersListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivityDynamicTag { /// Tag code. - pub tag: String, + pub tag: Option<String>, /// ID of this dynamic tag. This is a read-only, auto-generated field. - pub id: String, + pub id: Option<String>, /// Name of this tag. - pub name: String, + pub name: Option<String>, } impl Part for FloodlightActivityDynamicTag {} @@ -3438,6 +3830,9 @@ pub struct Creative { pub subaccount_id: Option<String>, /// Name of the creative. This is a required field and must be less than 256 characters long. Applicable to all creative types. pub name: Option<String>, + /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative types: ENHANCED_BANNER and FLASH_INPAGE. + #[serde(rename="convertFlashToHtml5")] + pub convert_flash_to_html5: Option<bool>, /// Creative video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, all RICH_MEDIA, and all VPAID. #[serde(rename="videoDuration")] pub video_duration: Option<f32>, @@ -3485,7 +3880,7 @@ impl ResponseResult for Creative {} pub struct ReportsConfiguration { /// Whether the exposure to conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting. #[serde(rename="exposureToConversionEnabled")] - pub exposure_to_conversion_enabled: bool, + pub exposure_to_conversion_enabled: Option<bool>, /// Report generation time zone ID of this account. This is a required field that can only be changed by a superuser. /// Acceptable values are: /// @@ -3503,10 +3898,10 @@ pub struct ReportsConfiguration { /// - "12" for "Pacific/Auckland" /// - "13" for "America/Sao_Paulo" #[serde(rename="reportGenerationTimeZoneId")] - pub report_generation_time_zone_id: String, + pub report_generation_time_zone_id: Option<String>, /// Default lookback windows for new advertisers in this account. #[serde(rename="lookbackConfiguration")] - pub lookback_configuration: LookbackConfiguration, + pub lookback_configuration: Option<LookbackConfiguration>, } impl Part for ReportsConfiguration {} @@ -3524,12 +3919,12 @@ impl Part for ReportsConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CampaignsListResponse { /// Campaign collection. - pub campaigns: Vec<Campaign>, + pub campaigns: Option<Vec<Campaign>>, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CampaignsListResponse {} @@ -3548,9 +3943,9 @@ impl ResponseResult for CampaignsListResponse {} pub struct UserRolePermissionsListResponse { /// User role permission collection. #[serde(rename="userRolePermissions")] - pub user_role_permissions: Vec<UserRolePermission>, + pub user_role_permissions: Option<Vec<UserRolePermission>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for UserRolePermissionsListResponse {} @@ -3570,26 +3965,26 @@ impl ResponseResult for UserRolePermissionsListResponse {} pub struct UserProfile { /// The user name. #[serde(rename="userName")] - pub user_name: String, + pub user_name: Option<String>, /// The kind of resource this is, in this case dfareporting#userProfile. - pub kind: String, + pub kind: Option<String>, /// The sub account ID this profile belongs to if applicable. #[serde(rename="subAccountId")] - pub sub_account_id: String, + pub sub_account_id: Option<String>, /// The account name this profile belongs to. #[serde(rename="accountName")] - pub account_name: String, + pub account_name: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The sub account name this profile belongs to if applicable. #[serde(rename="subAccountName")] - pub sub_account_name: String, + pub sub_account_name: Option<String>, /// The unique ID of the user profile. #[serde(rename="profileId")] - pub profile_id: String, + pub profile_id: Option<String>, /// The account ID to which this profile belongs. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option<String>, } impl Resource for UserProfile {} @@ -3604,10 +3999,10 @@ impl ResponseResult for UserProfile {} pub struct CreativeGroupAssignment { /// ID of the creative group to be assigned. #[serde(rename="creativeGroupId")] - pub creative_group_id: String, + pub creative_group_id: Option<String>, /// Creative group number of the creative group assignment. #[serde(rename="creativeGroupNumber")] - pub creative_group_number: String, + pub creative_group_number: Option<String>, } impl Part for CreativeGroupAssignment {} @@ -3621,31 +4016,31 @@ impl Part for CreativeGroupAssignment {} pub struct ReportPathToConversionCriteria { /// The list of conversion dimensions the report should include. #[serde(rename="conversionDimensions")] - pub conversion_dimensions: Vec<SortedDimension>, + pub conversion_dimensions: Option<Vec<SortedDimension>>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, /// The date range this report should be run for. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// The list of custom floodlight variables the report should include. #[serde(rename="customFloodlightVariables")] - pub custom_floodlight_variables: Vec<SortedDimension>, + pub custom_floodlight_variables: Option<Vec<SortedDimension>>, /// The list of 'dfa:activity' values to filter on. #[serde(rename="activityFilters")] - pub activity_filters: Vec<DimensionValue>, + pub activity_filters: Option<Vec<DimensionValue>>, /// The list of custom rich media events to include. #[serde(rename="customRichMediaEvents")] - pub custom_rich_media_events: Vec<DimensionValue>, + pub custom_rich_media_events: Option<Vec<DimensionValue>>, /// The list of per interaction dimensions the report should include. #[serde(rename="perInteractionDimensions")] - pub per_interaction_dimensions: Vec<SortedDimension>, + pub per_interaction_dimensions: Option<Vec<SortedDimension>>, /// The properties of the report. #[serde(rename="reportProperties")] - pub report_properties: ReportPathToConversionCriteriaReportProperties, + pub report_properties: Option<ReportPathToConversionCriteriaReportProperties>, /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. #[serde(rename="floodlightConfigId")] - pub floodlight_config_id: DimensionValue, + pub floodlight_config_id: Option<DimensionValue>, } impl NestedType for ReportPathToConversionCriteria {} @@ -3665,12 +4060,12 @@ impl Part for ReportPathToConversionCriteria {} pub struct CreativeFieldsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Creative field collection. #[serde(rename="creativeFields")] - pub creative_fields: Vec<CreativeField>, + pub creative_fields: Option<Vec<CreativeField>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CreativeFieldsListResponse {} @@ -3683,21 +4078,44 @@ impl ResponseResult for CreativeFieldsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportDelivery { /// The message to be sent with each email. - pub message: String, + pub message: Option<String>, /// The type of delivery for the owner to receive, if enabled. #[serde(rename="emailOwnerDeliveryType")] - pub email_owner_delivery_type: String, + pub email_owner_delivery_type: Option<String>, /// The list of recipients to which to email the report. - pub recipients: Vec<Recipient>, + pub recipients: Option<Vec<Recipient>>, /// Whether the report should be emailed to the report owner. #[serde(rename="emailOwner")] - pub email_owner: bool, + pub email_owner: Option<bool>, } impl NestedType for ReportDelivery {} impl Part for ReportDelivery {} +/// Project List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list projects](struct.ProjectListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ProjectsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#projectsListResponse". + pub kind: Option<String>, + /// Project collection. + pub projects: Option<Vec<Project>>, +} + +impl ResponseResult for ProjectsListResponse {} + + /// Geographical Targeting. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3705,19 +4123,19 @@ impl Part for ReportDelivery {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoTargeting { /// Regions to be targeted. For each region only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a region, do not target or exclude the country of the region. - pub regions: Vec<Region>, + pub regions: Option<Vec<Region>>, /// Countries to be targeted or excluded from targeting, depending on the setting of the excludeCountries field. For each country only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting or excluding a country, do not target regions, cities, metros, or postal codes in the same country. - pub countries: Vec<Country>, + pub countries: Option<Vec<Country>>, /// Metros to be targeted. For each metro only dmaId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a metro, do not target or exclude the country of the metro. - pub metros: Vec<Metro>, + pub metros: Option<Vec<Metro>>, /// Cities to be targeted. For each city only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a city, do not target or exclude the country of the city, and do not target the metro or region of the city. - pub cities: Vec<City>, + pub cities: Option<Vec<City>>, /// Whether or not to exclude the countries in the countries field from targeting. If false, the countries field refers to countries which will be targeted by the ad. #[serde(rename="excludeCountries")] - pub exclude_countries: bool, + pub exclude_countries: Option<bool>, /// Postal codes to be targeted. For each postal code only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a postal code, do not target or exclude the country of the postal code. #[serde(rename="postalCodes")] - pub postal_codes: Vec<PostalCode>, + pub postal_codes: Option<Vec<PostalCode>>, } impl Part for GeoTargeting {} @@ -3730,16 +4148,16 @@ impl Part for GeoTargeting {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeliverySchedule { /// Serving priority of an ad, with respect to other ads. The lower the priority number, the greater the priority with which it is served. - pub priority: String, + pub priority: Option<String>, /// Whether or not hard cutoff is enabled. If true, the ad will not serve after the end date and time. Otherwise the ad will continue to be served until it has reached its delivery goals. #[serde(rename="hardCutoff")] - pub hard_cutoff: bool, + pub hard_cutoff: Option<bool>, /// Limit on the number of times an individual user can be served the ad within a specified period of time. #[serde(rename="frequencyCap")] - pub frequency_cap: FrequencyCap, + pub frequency_cap: Option<FrequencyCap>, /// Impression ratio for this ad. This ratio determines how often each ad is served relative to the others. For example, if ad A has an impression ratio of 1 and ad B has an impression ratio of 3, then DCM will serve ad B three times as often as ad A. Must be between 1 and 10. #[serde(rename="impressionRatio")] - pub impression_ratio: String, + pub impression_ratio: Option<String>, } impl Part for DeliverySchedule {} @@ -3753,26 +4171,26 @@ impl Part for DeliverySchedule {} pub struct ReportSchedule { /// Start date of date range for which scheduled reports should be run. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// Enum to define for "MONTHLY" scheduled reports whether reports should be repeated on the same day of the month as "startDate" or the same day of the week of the month. /// Example: If 'startDate' is Monday, April 2nd 2012 (2012-04-02), "DAY_OF_MONTH" would run subsequent reports on the 2nd of every Month, and "WEEK_OF_MONTH" would run subsequent reports on the first Monday of the month. #[serde(rename="runsOnDayOfMonth")] - pub runs_on_day_of_month: String, + pub runs_on_day_of_month: Option<String>, /// The expiration date when the scheduled report stops running. #[serde(rename="expirationDate")] - pub expiration_date: String, + pub expiration_date: Option<String>, /// Whether the schedule is active or not. Must be set to either true or false. - pub active: bool, + pub active: Option<bool>, /// Defines every how many days, weeks or months the report should be run. Needs to be set when "repeats" is either "DAILY", "WEEKLY" or "MONTHLY". - pub every: i32, + pub every: Option<i32>, /// The interval for which the report is repeated. Note: /// - "DAILY" also requires field "every" to be set. /// - "WEEKLY" also requires fields "every" and "repeatsOnWeekDays" to be set. /// - "MONTHLY" also requires fields "every" and "runsOnDayOfMonth" to be set. - pub repeats: String, + pub repeats: Option<String>, /// List of week days "WEEKLY" on which scheduled reports should run. #[serde(rename="repeatsOnWeekDays")] - pub repeats_on_week_days: Vec<String>, + pub repeats_on_week_days: Option<Vec<String>>, } impl NestedType for ReportSchedule {} @@ -3786,12 +4204,12 @@ impl Part for ReportSchedule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Recipient { /// The kind of resource this is, in this case dfareporting#recipient. - pub kind: String, + pub kind: Option<String>, /// The delivery type for the recipient. #[serde(rename="deliveryType")] - pub delivery_type: String, + pub delivery_type: Option<String>, /// The email address of the recipient. - pub email: String, + pub email: Option<String>, } impl Part for Recipient {} @@ -3804,17 +4222,17 @@ impl Part for Recipient {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCompatibleFields { /// Metrics which are compatible to be selected in the "metricNames" section of the report. - pub metrics: Vec<Metric>, + pub metrics: Option<Vec<Metric>>, /// The kind of resource this is, in this case dfareporting#reportCompatibleFields. - pub kind: String, + pub kind: Option<String>, /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. #[serde(rename="pivotedActivityMetrics")] - pub pivoted_activity_metrics: Vec<Metric>, + pub pivoted_activity_metrics: Option<Vec<Metric>>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. - pub dimensions: Vec<Dimension>, + pub dimensions: Option<Vec<Dimension>>, /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<Dimension>, + pub dimension_filters: Option<Vec<Dimension>>, } impl Part for ReportCompatibleFields {} @@ -3833,12 +4251,12 @@ impl Part for ReportCompatibleFields {} pub struct AdvertiserGroupsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroupsListResponse". - pub kind: String, + pub kind: Option<String>, /// Advertiser group collection. #[serde(rename="advertiserGroups")] - pub advertiser_groups: Vec<AdvertiserGroup>, + pub advertiser_groups: Option<Vec<AdvertiserGroup>>, } impl ResponseResult for AdvertiserGroupsListResponse {} @@ -3857,12 +4275,12 @@ impl ResponseResult for AdvertiserGroupsListResponse {} pub struct PlacementGroupsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse". - pub kind: String, + pub kind: Option<String>, /// Placement group collection. #[serde(rename="placementGroups")] - pub placement_groups: Vec<PlacementGroup>, + pub placement_groups: Option<Vec<PlacementGroup>>, } impl ResponseResult for PlacementGroupsListResponse {} @@ -3876,31 +4294,31 @@ impl ResponseResult for PlacementGroupsListResponse {} pub struct ReportPathToConversionCriteriaReportProperties { /// DFA checks to see if a click interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. #[serde(rename="clicksLookbackWindow")] - pub clicks_lookback_window: i32, + pub clicks_lookback_window: Option<i32>, /// Enable pivoting on interaction path. #[serde(rename="pivotOnInteractionPath")] - pub pivot_on_interaction_path: bool, + pub pivot_on_interaction_path: Option<bool>, /// DFA checks to see if an impression interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90. #[serde(rename="impressionsLookbackWindow")] - pub impressions_lookback_window: i32, + pub impressions_lookback_window: Option<i32>, /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. #[serde(rename="includeUnattributedIPConversions")] - pub include_unattributed_ip_conversions: bool, + pub include_unattributed_ip_conversions: Option<bool>, /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. #[serde(rename="includeUnattributedCookieConversions")] - pub include_unattributed_cookie_conversions: bool, + pub include_unattributed_cookie_conversions: Option<bool>, /// The maximum amount of time that can take place between interactions (clicks or impressions) by the same user. Valid values: 1-90. #[serde(rename="maximumInteractionGap")] - pub maximum_interaction_gap: i32, + pub maximum_interaction_gap: Option<i32>, /// Deprecated: has no effect. #[serde(rename="includeAttributedIPConversions")] - pub include_attributed_ip_conversions: bool, + pub include_attributed_ip_conversions: Option<bool>, /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. #[serde(rename="maximumClickInteractions")] - pub maximum_click_interactions: i32, + pub maximum_click_interactions: Option<i32>, /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report. #[serde(rename="maximumImpressionInteractions")] - pub maximum_impression_interactions: i32, + pub maximum_impression_interactions: Option<i32>, } impl NestedType for ReportPathToConversionCriteriaReportProperties {} @@ -3914,22 +4332,22 @@ impl Part for ReportPathToConversionCriteriaReportProperties {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TechnologyTargeting { /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used.The other fields are populated automatically when the ad is inserted or updated. - pub browsers: Vec<Browser>, + pub browsers: Option<Vec<Browser>>, /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system. #[serde(rename="operatingSystems")] - pub operating_systems: Vec<OperatingSystem>, + pub operating_systems: Option<Vec<OperatingSystem>>, /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes. #[serde(rename="mobileCarriers")] - pub mobile_carriers: Vec<MobileCarrier>, + pub mobile_carriers: Option<Vec<MobileCarrier>>, /// Connection types that this ad targets. For each connection type only id is required.The other fields are populated automatically when the ad is inserted or updated. #[serde(rename="connectionTypes")] - pub connection_types: Vec<ConnectionType>, + pub connection_types: Option<Vec<ConnectionType>>, /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated. #[serde(rename="platformTypes")] - pub platform_types: Vec<PlatformType>, + pub platform_types: Option<Vec<PlatformType>>, /// Operating system versions that this ad targets. To target all versions, use operatingSystems. For each operating system version, only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system version, do not set targeting for the corresponding operating system in operatingSystems. #[serde(rename="operatingSystemVersions")] - pub operating_system_versions: Vec<OperatingSystemVersion>, + pub operating_system_versions: Option<Vec<OperatingSystemVersion>>, } impl Part for TechnologyTargeting {} @@ -3943,12 +4361,12 @@ impl Part for TechnologyTargeting {} pub struct OptimizationActivity { /// Floodlight activity ID of this optimization activity. This is a required field. #[serde(rename="floodlightActivityId")] - pub floodlight_activity_id: String, + pub floodlight_activity_id: Option<String>, /// Dimension value for the ID of the floodlight activity. This is a read-only, auto-generated field. #[serde(rename="floodlightActivityIdDimensionValue")] - pub floodlight_activity_id_dimension_value: DimensionValue, + pub floodlight_activity_id_dimension_value: Option<DimensionValue>, /// Weight associated with this optimization. Must be greater than 1. The weight assigned will be understood in proportion to the weights assigned to the other optimization activities. - pub weight: i32, + pub weight: Option<i32>, } impl Part for OptimizationActivity {} @@ -3961,7 +4379,7 @@ impl Part for OptimizationActivity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListTargetingExpression { /// Expression describing which lists are being targeted by the ad. - pub expression: String, + pub expression: Option<String>, } impl Part for ListTargetingExpression {} @@ -4029,18 +4447,18 @@ impl ResponseResult for CreativeAssetMetadata {} pub struct TagData { /// Tag string to record a click. #[serde(rename="clickTag")] - pub click_tag: String, + pub click_tag: Option<String>, /// Tag string for serving an ad. #[serde(rename="impressionTag")] - pub impression_tag: String, + pub impression_tag: Option<String>, /// Creative associated with this placement tag. #[serde(rename="creativeId")] - pub creative_id: String, + pub creative_id: Option<String>, /// Ad associated with this placement tag. #[serde(rename="adId")] - pub ad_id: String, + pub ad_id: Option<String>, /// TagData tag format of this tag. - pub format: String, + pub format: Option<String>, } impl Part for TagData {} @@ -4054,25 +4472,25 @@ impl Part for TagData {} pub struct ReportFloodlightCriteria { /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'. #[serde(rename="floodlightConfigId")] - pub floodlight_config_id: DimensionValue, + pub floodlight_config_id: Option<DimensionValue>, /// The list of dimensions the report should include. - pub dimensions: Vec<SortedDimension>, + pub dimensions: Option<Vec<SortedDimension>>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, /// The date range this report should be run for. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// The list of custom rich media events to include. #[serde(rename="customRichMediaEvents")] - pub custom_rich_media_events: Vec<DimensionValue>, + pub custom_rich_media_events: Option<Vec<DimensionValue>>, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<DimensionValue>, + pub dimension_filters: Option<Vec<DimensionValue>>, /// The properties of the report. #[serde(rename="reportProperties")] - pub report_properties: ReportFloodlightCriteriaReportProperties, + pub report_properties: Option<ReportFloodlightCriteriaReportProperties>, } impl NestedType for ReportFloodlightCriteria {} @@ -4091,10 +4509,10 @@ impl Part for ReportFloodlightCriteria {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LandingPagesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPagesListResponse". - pub kind: String, + pub kind: Option<String>, /// Landing page collection #[serde(rename="landingPages")] - pub landing_pages: Vec<LandingPage>, + pub landing_pages: Option<Vec<LandingPage>>, } impl ResponseResult for LandingPagesListResponse {} @@ -4113,11 +4531,11 @@ impl ResponseResult for LandingPagesListResponse {} pub struct SitesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sitesListResponse". - pub kind: String, + pub kind: Option<String>, /// Site collection - pub sites: Vec<Site>, + pub sites: Option<Vec<Site>>, } impl ResponseResult for SitesListResponse {} @@ -4131,11 +4549,11 @@ impl ResponseResult for SitesListResponse {} pub struct DimensionFilter { /// The name of the dimension to filter. #[serde(rename="dimensionName")] - pub dimension_name: String, + pub dimension_name: Option<String>, /// The kind of resource this is, in this case dfareporting#dimensionFilter. - pub kind: String, + pub kind: Option<String>, /// The value of the dimension to filter. - pub value: String, + pub value: Option<String>, } impl Part for DimensionFilter {} @@ -4148,10 +4566,13 @@ impl Part for DimensionFilter {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// +/// * [get postal codes](struct.PostalCodeGetCall.html) (response) /// * [list postal codes](struct.PostalCodeListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostalCode { + /// Postal code. This is equivalent to the id field. + pub code: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCode". pub kind: Option<String>, /// DART ID of the country to which this postal code belongs. @@ -4165,6 +4586,63 @@ pub struct PostalCode { } impl Resource for PostalCode {} +impl ResponseResult for PostalCode {} + + +/// Contains properties of a remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource can be used to manage remarketing lists that are owned by your advertisers. To see all remarketing lists that are visible to your advertisers, including those that are shared to your advertiser or account, use the TargetableRemarketingList resource. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [insert remarketing lists](struct.RemarketingListInsertCall.html) (request|response) +/// * [get remarketing lists](struct.RemarketingListGetCall.html) (response) +/// * [update remarketing lists](struct.RemarketingListUpdateCall.html) (request|response) +/// * [list remarketing lists](struct.RemarketingListListCall.html) (none) +/// * [patch remarketing lists](struct.RemarketingListPatchCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RemarketingList { + /// Rule used to populate the remarketing list with users. + #[serde(rename="listPopulationRule")] + pub list_population_rule: Option<ListPopulationRule>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingList". + pub kind: Option<String>, + /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Remarketing list description. + pub description: Option<String>, + /// Number of users currently in the list. This is a read-only field. + #[serde(rename="listSize")] + pub list_size: Option<String>, + /// Number of days that a user should remain in the remarketing list without an impression. + #[serde(rename="lifeSpan")] + pub life_span: Option<String>, + /// Dimension value for the advertiser ID that owns this remarketing list. This is a required field. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Product from which this remarketing list was originated. + #[serde(rename="listSource")] + pub list_source: Option<String>, + /// Whether this remarketing list is active. + pub active: Option<bool>, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option<DimensionValue>, + /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Remarketing list ID. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Name of the remarketing list. This is a required field. Must be no greater than 128 characters long. + pub name: Option<String>, +} + +impl RequestValue for RemarketingList {} +impl Resource for RemarketingList {} +impl ResponseResult for RemarketingList {} /// Contains properties of a Floodlight activity. @@ -4331,12 +4809,12 @@ impl Resource for Browser {} pub struct AccountUserProfilesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Account user profile collection. #[serde(rename="accountUserProfiles")] - pub account_user_profiles: Vec<AccountUserProfile>, + pub account_user_profiles: Option<Vec<AccountUserProfile>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfilesListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AccountUserProfilesListResponse {} @@ -4369,6 +4847,9 @@ pub struct Advertiser { /// ID of the click-through event tag to apply by default to the landing pages of this advertiser's campaigns. #[serde(rename="defaultClickThroughEventTagId")] pub default_click_through_event_tag_id: Option<String>, + /// Original floodlight configuration before any sharing occurred. Set the floodlightConfigurationId of this advertiser to originalFloodlightConfigurationId to unshare the advertiser's current floodlight configuration. You cannot unshare an advertiser's floodlight configuration if the shared configuration has activities associated with any campaign or placement. + #[serde(rename="originalFloodlightConfigurationId")] + pub original_floodlight_configuration_id: Option<String>, /// Suffix added to click-through URL of ad creative associations under this advertiser. Must be less than 129 characters long. #[serde(rename="clickThroughUrlSuffix")] pub click_through_url_suffix: Option<String>, @@ -4413,10 +4894,10 @@ impl ResponseResult for Advertiser {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlatformTypesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformTypesListResponse". - pub kind: String, + pub kind: Option<String>, /// Platform type collection. #[serde(rename="platformTypes")] - pub platform_types: Vec<PlatformType>, + pub platform_types: Option<Vec<PlatformType>>, } impl ResponseResult for PlatformTypesListResponse {} @@ -4435,12 +4916,12 @@ impl ResponseResult for PlatformTypesListResponse {} pub struct ChangeLogsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLogsListResponse". - pub kind: String, + pub kind: Option<String>, /// Change log collection. #[serde(rename="changeLogs")] - pub change_logs: Vec<ChangeLog>, + pub change_logs: Option<Vec<ChangeLog>>, } impl ResponseResult for ChangeLogsListResponse {} @@ -4459,11 +4940,11 @@ impl ResponseResult for ChangeLogsListResponse {} pub struct PlacementsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsListResponse". - pub kind: String, + pub kind: Option<String>, /// Placement collection. - pub placements: Vec<Placement>, + pub placements: Option<Vec<Placement>>, } impl ResponseResult for PlacementsListResponse {} @@ -4482,11 +4963,11 @@ impl ResponseResult for PlacementsListResponse {} pub struct AdsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#adsListResponse". - pub kind: String, + pub kind: Option<String>, /// Ad collection. - pub ads: Vec<Ad>, + pub ads: Option<Vec<Ad>>, } impl ResponseResult for AdsListResponse {} @@ -4499,28 +4980,28 @@ impl ResponseResult for AdsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportReachCriteria { /// Activity group. - pub activities: Activities, + pub activities: Option<Activities>, /// The list of dimensions the report should include. - pub dimensions: Vec<SortedDimension>, + pub dimensions: Option<Vec<SortedDimension>>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, /// The date range this report should be run for. #[serde(rename="dateRange")] - pub date_range: DateRange, + pub date_range: Option<DateRange>, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<DimensionValue>, + pub dimension_filters: Option<Vec<DimensionValue>>, /// The list of names of Reach By Frequency metrics the report should include. #[serde(rename="reachByFrequencyMetricNames")] - pub reach_by_frequency_metric_names: Vec<String>, + pub reach_by_frequency_metric_names: Option<Vec<String>>, /// Custom Rich Media Events group. #[serde(rename="customRichMediaEvents")] - pub custom_rich_media_events: CustomRichMediaEvents, + pub custom_rich_media_events: Option<CustomRichMediaEvents>, /// Whether to enable all reach dimension combinations in the report. Defaults to false. If enabled, the date range of the report should be within the last three months. #[serde(rename="enableAllDimensionCombinations")] - pub enable_all_dimension_combinations: bool, + pub enable_all_dimension_combinations: Option<bool>, } impl NestedType for ReportReachCriteria {} @@ -4535,16 +5016,40 @@ impl Part for ReportReachCriteria {} pub struct FileUrls { /// The URL for downloading the report data through a browser. #[serde(rename="browserUrl")] - pub browser_url: String, + pub browser_url: Option<String>, /// The URL for downloading the report data through the API. #[serde(rename="apiUrl")] - pub api_url: String, + pub api_url: Option<String>, } impl NestedType for FileUrls {} impl Part for FileUrls {} +/// Order document List Response +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list order documents](struct.OrderDocumentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OrderDocumentsListResponse { + /// Pagination token to be used for the next list operation. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocumentsListResponse". + pub kind: Option<String>, + /// Order document collection + #[serde(rename="orderDocuments")] + pub order_documents: Option<Vec<OrderDocument>>, +} + +impl ResponseResult for OrderDocumentsListResponse {} + + /// User Defined Variable configuration. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -4553,18 +5058,46 @@ impl Part for FileUrls {} pub struct UserDefinedVariableConfiguration { /// Data type for the variable. This is a required field. #[serde(rename="dataType")] - pub data_type: String, + pub data_type: Option<String>, /// User-friendly name for the variable which will appear in reports. This is a required field, must be less than 64 characters long, and cannot contain the following characters: ""<>". #[serde(rename="reportName")] - pub report_name: String, + pub report_name: Option<String>, /// Variable name in the tag. This is a required field. #[serde(rename="variableType")] - pub variable_type: String, + pub variable_type: Option<String>, } impl Part for UserDefinedVariableConfiguration {} +/// Pricing Information +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Pricing { + /// Group type of this inventory item if it represents a placement group. Is null otherwise. There are two type of placement groups: PLANNING_PLACEMENT_GROUP_TYPE_PACKAGE is a simple group of inventory items that acts as a single pricing point for a group of tags. PLANNING_PLACEMENT_GROUP_TYPE_ROADBLOCK is a group of inventory items that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned inventory items to be marked as primary. + #[serde(rename="groupType")] + pub group_type: Option<String>, + /// Start date of this inventory item. + #[serde(rename="startDate")] + pub start_date: Option<String>, + /// Flights of this inventory item. A flight (a.k.a. pricing period) represents the inventory item pricing information for a specific period of time. + pub flights: Option<Vec<Flight>>, + /// End date of this inventory item. + #[serde(rename="endDate")] + pub end_date: Option<String>, + /// Pricing type of this inventory item. + #[serde(rename="pricingType")] + pub pricing_type: Option<String>, + /// Cap cost type of this inventory item. + #[serde(rename="capCostType")] + pub cap_cost_type: Option<String>, +} + +impl Part for Pricing {} + + /// Publisher Dynamic Tag /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -4573,22 +5106,22 @@ impl Part for UserDefinedVariableConfiguration {} pub struct FloodlightActivityPublisherDynamicTag { /// Whether this tag is applicable only for view-throughs. #[serde(rename="viewThrough")] - pub view_through: bool, + pub view_through: Option<bool>, /// Site ID of this dynamic tag. #[serde(rename="siteId")] - pub site_id: String, + pub site_id: Option<String>, /// Whether this tag is applicable only for click-throughs. #[serde(rename="clickThrough")] - pub click_through: bool, + pub click_through: Option<bool>, /// Directory site ID of this dynamic tag. This is a write-only field that can be used as an alternative to the siteId field. When this resource is retrieved, only the siteId field will be populated. #[serde(rename="directorySiteId")] - pub directory_site_id: String, + pub directory_site_id: Option<String>, /// Dimension value for the ID of the site. This is a read-only, auto-generated field. #[serde(rename="siteIdDimensionValue")] - pub site_id_dimension_value: DimensionValue, + pub site_id_dimension_value: Option<DimensionValue>, /// Dynamic floodlight tag. #[serde(rename="dynamicTag")] - pub dynamic_tag: FloodlightActivityDynamicTag, + pub dynamic_tag: Option<FloodlightActivityDynamicTag>, } impl Part for FloodlightActivityPublisherDynamicTag {} @@ -4664,30 +5197,30 @@ impl ResponseResult for Size {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct City { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#city". - pub kind: String, + pub kind: Option<String>, /// DART ID of the country to which this city belongs. #[serde(rename="countryDartId")] - pub country_dart_id: String, + pub country_dart_id: Option<String>, /// Name of this city. - pub name: String, + pub name: Option<String>, /// Country code of the country to which this city belongs. #[serde(rename="countryCode")] - pub country_code: String, + pub country_code: Option<String>, /// Metro region code of the metro region (DMA) to which this city belongs. #[serde(rename="metroCode")] - pub metro_code: String, + pub metro_code: Option<String>, /// Region code of the region to which this city belongs. #[serde(rename="regionCode")] - pub region_code: String, + pub region_code: Option<String>, /// ID of the metro region (DMA) to which this city belongs. #[serde(rename="metroDmaId")] - pub metro_dma_id: String, + pub metro_dma_id: Option<String>, /// DART ID of this city. This is the ID used for targeting and generating reports. #[serde(rename="dartId")] - pub dart_id: String, + pub dart_id: Option<String>, /// DART ID of the region to which this city belongs. #[serde(rename="regionDartId")] - pub region_dart_id: String, + pub region_dart_id: Option<String>, } impl Part for City {} @@ -4701,10 +5234,10 @@ impl Part for City {} pub struct ClickThroughUrlSuffixProperties { /// Click-through URL suffix to apply to all ads in this entity's scope. Must be less than 128 characters long. #[serde(rename="clickThroughUrlSuffix")] - pub click_through_url_suffix: String, + pub click_through_url_suffix: Option<String>, /// Whether this entity should override the inherited click-through URL suffix with its own defined value. #[serde(rename="overrideInheritedSuffix")] - pub override_inherited_suffix: bool, + pub override_inherited_suffix: Option<bool>, } impl Part for ClickThroughUrlSuffixProperties {} @@ -4815,10 +5348,10 @@ impl ResponseResult for PlacementGroup {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ThirdPartyTrackingUrl { /// URL for the specified third-party URL type. - pub url: String, + pub url: Option<String>, /// Third-party URL type for in-stream video creatives. #[serde(rename="thirdPartyUrlType")] - pub third_party_url_type: String, + pub third_party_url_type: Option<String>, } impl Part for ThirdPartyTrackingUrl {} @@ -4838,15 +5371,15 @@ impl Part for ThirdPartyTrackingUrl {} pub struct UserRolePermission { /// ID of the permission group that this user role permission belongs to. #[serde(rename="permissionGroupId")] - pub permission_group_id: String, + pub permission_group_id: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermission". - pub kind: String, + pub kind: Option<String>, /// Levels of availability for a user role permission. - pub availability: String, + pub availability: Option<String>, /// ID of this user role permission. - pub id: String, + pub id: Option<String>, /// Name of this user role permission. - pub name: String, + pub name: Option<String>, } impl Resource for UserRolePermission {} @@ -4865,9 +5398,9 @@ impl ResponseResult for UserRolePermission {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetrosListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metrosListResponse". - pub kind: String, + pub kind: Option<String>, /// Metro collection. - pub metros: Vec<Metro>, + pub metros: Option<Vec<Metro>>, } impl ResponseResult for MetrosListResponse {} @@ -4881,30 +5414,30 @@ impl ResponseResult for MetrosListResponse {} pub struct PricingSchedule { /// Placement start date. This date must be later than, or the same day as, the campaign start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This field is required on insertion. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// Placement end date. This date must be later than, or the same day as, the placement start date, but not later than the campaign end date. If, for example, you set 6/25/2015 as both the start and end dates, the effective placement date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This field is required on insertion. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// Whether this placement is flighted. If true, pricing periods will be computed automatically. - pub flighted: bool, + pub flighted: Option<bool>, /// Whether cap costs are ignored by ad serving. #[serde(rename="disregardOverdelivery")] - pub disregard_overdelivery: bool, + pub disregard_overdelivery: Option<bool>, /// Placement cap cost option. #[serde(rename="capCostOption")] - pub cap_cost_option: String, + pub cap_cost_option: Option<String>, /// Pricing periods for this placement. #[serde(rename="pricingPeriods")] - pub pricing_periods: Vec<PricingSchedulePricingPeriod>, + pub pricing_periods: Option<Vec<PricingSchedulePricingPeriod>>, /// Placement pricing type. This field is required on insertion. #[serde(rename="pricingType")] - pub pricing_type: String, + pub pricing_type: Option<String>, /// Testing start date of this placement. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. #[serde(rename="testingStartDate")] - pub testing_start_date: String, + pub testing_start_date: Option<String>, /// Floodlight activity ID associated with this placement. This field should be set when placement pricing type is set to PRICING_TYPE_CPA. #[serde(rename="floodlightActivityId")] - pub floodlight_activity_id: String, + pub floodlight_activity_id: Option<String>, } impl Part for PricingSchedule {} @@ -4923,11 +5456,11 @@ impl Part for PricingSchedule {} pub struct AccountsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountsListResponse". - pub kind: String, + pub kind: Option<String>, /// Account collection. - pub accounts: Vec<Account>, + pub accounts: Option<Vec<Account>>, } impl ResponseResult for AccountsListResponse {} @@ -4940,6 +5473,7 @@ impl ResponseResult for AccountsListResponse {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// +/// * [get operating systems](struct.OperatingSystemGetCall.html) (response) /// * [list operating systems](struct.OperatingSystemListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] @@ -4958,6 +5492,7 @@ pub struct OperatingSystem { } impl Resource for OperatingSystem {} +impl ResponseResult for OperatingSystem {} /// Represents an activity group. @@ -4967,17 +5502,52 @@ impl Resource for OperatingSystem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Activities { /// The kind of resource this is, in this case dfareporting#activities. - pub kind: String, + pub kind: Option<String>, /// List of activity filters. The dimension values need to be all either of type "dfa:activity" or "dfa:activityGroup". - pub filters: Vec<DimensionValue>, + pub filters: Option<Vec<DimensionValue>>, /// List of names of floodlight activity metrics. #[serde(rename="metricNames")] - pub metric_names: Vec<String>, + pub metric_names: Option<Vec<String>>, } impl Part for Activities {} +/// A group clause made up of list population terms representing constraints joined by ORs. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ListPopulationClause { + /// Terms of this list population clause. Each clause is made up of list population terms representing constraints and are joined by ORs. + pub terms: Option<Vec<ListPopulationTerm>>, +} + +impl Part for ListPopulationClause {} + + +/// Flight +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Flight { + /// Rate or cost of this flight. + #[serde(rename="rateOrCost")] + pub rate_or_cost: Option<String>, + /// Inventory item flight start date. + #[serde(rename="startDate")] + pub start_date: Option<String>, + /// Units of this flight. + pub units: Option<String>, + /// Inventory item flight end date. + #[serde(rename="endDate")] + pub end_date: Option<String>, +} + +impl Part for Flight {} + + /// Represents a sorted dimension. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -4985,12 +5555,12 @@ impl Part for Activities {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SortedDimension { /// The kind of resource this is, in this case dfareporting#sortedDimension. - pub kind: String, + pub kind: Option<String>, /// The name of the dimension. - pub name: String, + pub name: Option<String>, /// An optional sort order for the dimension column. #[serde(rename="sortOrder")] - pub sort_order: String, + pub sort_order: Option<String>, } impl Part for SortedDimension {} @@ -5009,12 +5579,12 @@ impl Part for SortedDimension {} pub struct PlacementStrategiesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategiesListResponse". - pub kind: String, + pub kind: Option<String>, /// Placement strategy collection. #[serde(rename="placementStrategies")] - pub placement_strategies: Vec<PlacementStrategy>, + pub placement_strategies: Option<Vec<PlacementStrategy>>, } impl ResponseResult for PlacementStrategiesListResponse {} @@ -5033,13 +5603,13 @@ impl ResponseResult for PlacementStrategiesListResponse {} pub struct ReportList { /// Continuation token used to page through reports. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The reports returned in this response. - pub items: Vec<Report>, + pub items: Option<Vec<Report>>, /// The kind of list this is, in this case dfareporting#reportList. - pub kind: String, + pub kind: Option<String>, /// The eTag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for ReportList {} @@ -5085,17 +5655,17 @@ impl ResponseResult for AdvertiserGroup {} pub struct FsCommand { /// Height of the window. #[serde(rename="windowHeight")] - pub window_height: i32, + pub window_height: Option<i32>, /// Distance from the top of the browser. Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. - pub top: i32, + pub top: Option<i32>, /// Width of the window. #[serde(rename="windowWidth")] - pub window_width: i32, + pub window_width: Option<i32>, /// Position in the browser where the window will open. #[serde(rename="positionOption")] - pub position_option: String, + pub position_option: Option<String>, /// Distance from the left of the browser.Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. - pub left: i32, + pub left: Option<i32>, } impl Part for FsCommand {} @@ -5109,14 +5679,14 @@ impl Part for FsCommand {} pub struct CreativeOptimizationConfiguration { /// List of optimization activities associated with this configuration. #[serde(rename="optimizationActivitys")] - pub optimization_activitys: Vec<OptimizationActivity>, + pub optimization_activitys: Option<Vec<OptimizationActivity>>, /// ID of this creative optimization config. This field is auto-generated when the campaign is inserted or updated. It can be null for existing campaigns. - pub id: String, + pub id: Option<String>, /// Name of this creative optimization config. This is a required field and must be less than 129 characters long. - pub name: String, + pub name: Option<String>, /// Optimization model for this configuration. #[serde(rename="optimizationModel")] - pub optimization_model: String, + pub optimization_model: Option<String>, } impl Part for CreativeOptimizationConfiguration {} @@ -5135,12 +5705,12 @@ impl Part for CreativeOptimizationConfiguration {} pub struct CreativeGroupsListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Creative group collection. #[serde(rename="creativeGroups")] - pub creative_groups: Vec<CreativeGroup>, + pub creative_groups: Option<Vec<CreativeGroup>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroupsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CreativeGroupsListResponse {} @@ -5153,9 +5723,9 @@ impl ResponseResult for CreativeGroupsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OffsetPosition { /// Offset distance from top side of an asset or a window. - pub top: i32, + pub top: Option<i32>, /// Offset distance from left side of an asset or a window. - pub left: i32, + pub left: Option<i32>, } impl Part for OffsetPosition {} @@ -5169,10 +5739,10 @@ impl Part for OffsetPosition {} pub struct TargetWindow { /// User-entered value. #[serde(rename="customHtml")] - pub custom_html: String, + pub custom_html: Option<String>, /// Type of browser window for which the backup image of the flash creative can be displayed. #[serde(rename="targetWindowOption")] - pub target_window_option: String, + pub target_window_option: Option<String>, } impl Part for TargetWindow {} @@ -5186,21 +5756,21 @@ impl Part for TargetWindow {} pub struct ProgrammaticSetting { /// Trafficker emails assigned to the placement. #[serde(rename="traffickerEmails")] - pub trafficker_emails: Vec<String>, + pub trafficker_emails: Option<Vec<String>>, /// Whether programmatic is enabled. - pub programmatic: bool, + pub programmatic: Option<bool>, /// Media cost for the programmatic placement. #[serde(rename="mediaCostNanos")] - pub media_cost_nanos: String, + pub media_cost_nanos: Option<String>, /// Adx deal IDs assigned to the placement. #[serde(rename="adxDealIds")] - pub adx_deal_ids: Vec<String>, + pub adx_deal_ids: Option<Vec<String>>, /// Insertion order ID. #[serde(rename="insertionOrderId")] - pub insertion_order_id: String, + pub insertion_order_id: Option<String>, /// Whether insertion order ID has been placed in DFP. This is a read-only field. #[serde(rename="insertionOrderIdStatus")] - pub insertion_order_id_status: bool, + pub insertion_order_id_status: Option<bool>, } impl Part for ProgrammaticSetting {} @@ -5212,19 +5782,25 @@ impl Part for ProgrammaticSetting {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteContact { - /// Last name of this site contact. - #[serde(rename="lastName")] - pub last_name: String, - /// Site contact type. - #[serde(rename="contactType")] - pub contact_type: String, - /// Email address of this site contact. This is a required field. - pub email: String, /// First name of this site contact. #[serde(rename="firstName")] - pub first_name: String, + pub first_name: Option<String>, + /// Title or designation of this site contact. + pub title: Option<String>, + /// Last name of this site contact. + #[serde(rename="lastName")] + pub last_name: Option<String>, + /// Site contact type. + #[serde(rename="contactType")] + pub contact_type: Option<String>, /// ID of this site contact. This is a read-only, auto-generated field. - pub id: String, + pub id: Option<String>, + /// Primary phone number of this site contact. + pub phone: Option<String>, + /// Address of this site contact. + pub address: Option<String>, + /// Email address of this site contact. This is a required field. + pub email: Option<String>, } impl Part for SiteContact {} @@ -5238,16 +5814,16 @@ impl Part for SiteContact {} pub struct CreativeRotation { /// Creative assignments in this creative rotation. #[serde(rename="creativeAssignments")] - pub creative_assignments: Vec<CreativeAssignment>, + pub creative_assignments: Option<Vec<CreativeAssignment>>, /// Strategy for calculating weights. Used with CREATIVE_ROTATION_TYPE_RANDOM. #[serde(rename="weightCalculationStrategy")] - pub weight_calculation_strategy: String, + pub weight_calculation_strategy: Option<String>, /// Creative optimization configuration that is used by this ad. It should refer to one of the existing optimization configurations in the ad's campaign. If it is unset or set to 0, then the campaign's default optimization configuration will be used for this ad. #[serde(rename="creativeOptimizationConfigurationId")] - pub creative_optimization_configuration_id: String, + pub creative_optimization_configuration_id: Option<String>, /// Type of creative rotation. Can be used to specify whether to use sequential or random rotation. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for CreativeRotation {} @@ -5301,17 +5877,17 @@ impl Resource for Metro {} pub struct Country { /// DART ID of this country. This is the ID used for targeting and generating reports. #[serde(rename="dartId")] - pub dart_id: String, + pub dart_id: Option<String>, /// Whether ad serving supports secure servers in this country. #[serde(rename="sslEnabled")] - pub ssl_enabled: bool, + pub ssl_enabled: Option<bool>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#country". - pub kind: String, + pub kind: Option<String>, /// Country code. #[serde(rename="countryCode")] - pub country_code: String, + pub country_code: Option<String>, /// Name of this country. - pub name: String, + pub name: Option<String>, } impl ResponseResult for Country {} @@ -5329,10 +5905,10 @@ impl ResponseResult for Country {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostalCodesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCodesListResponse". - pub kind: String, + pub kind: Option<String>, /// Postal code collection. #[serde(rename="postalCodes")] - pub postal_codes: Vec<PostalCode>, + pub postal_codes: Option<Vec<PostalCode>>, } impl ResponseResult for PostalCodesListResponse {} @@ -5346,88 +5922,60 @@ impl ResponseResult for PostalCodesListResponse {} pub struct TagSetting { /// Whether static landing page URLs should be included in the tags. This setting applies only to placements. #[serde(rename="includeClickThroughUrls")] - pub include_click_through_urls: bool, + pub include_click_through_urls: Option<bool>, /// Whether click-tracking string should be included in the tags. #[serde(rename="includeClickTracking")] - pub include_click_tracking: bool, + pub include_click_tracking: Option<bool>, /// Additional key-values to be included in tags. Each key-value pair must be of the form key=value, and pairs must be separated by a semicolon (;). Keys and values must not contain commas. For example, id=2;color=red is a valid value for this field. #[serde(rename="additionalKeyValues")] - pub additional_key_values: String, + pub additional_key_values: Option<String>, /// Option specifying how keywords are embedded in ad tags. This setting can be used to specify whether keyword placeholders are inserted in placement tags for this site. Publishers can then add keywords to those placeholders. #[serde(rename="keywordOption")] - pub keyword_option: String, + pub keyword_option: Option<String>, } impl Part for TagSetting {} -/// Contains properties of an event tag. +/// Contains properties of a creative field. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// -/// * [delete event tags](struct.EventTagDeleteCall.html) (none) -/// * [patch event tags](struct.EventTagPatchCall.html) (request|response) -/// * [list event tags](struct.EventTagListCall.html) (none) -/// * [update event tags](struct.EventTagUpdateCall.html) (request|response) -/// * [insert event tags](struct.EventTagInsertCall.html) (request|response) -/// * [get event tags](struct.EventTagGetCall.html) (response) +/// * [list creative fields](struct.CreativeFieldListCall.html) (none) +/// * [update creative fields](struct.CreativeFieldUpdateCall.html) (request|response) +/// * [get creative fields](struct.CreativeFieldGetCall.html) (response) +/// * [insert creative fields](struct.CreativeFieldInsertCall.html) (request|response) +/// * [delete creative fields](struct.CreativeFieldDeleteCall.html) (none) +/// * [patch creative fields](struct.CreativeFieldPatchCall.html) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct EventTag { - /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field. - pub status: Option<String>, - /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter. - #[serde(rename="siteIds")] - pub site_ids: Option<Vec<String>>, - /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion. - #[serde(rename="campaignId")] - pub campaign_id: Option<String>, - /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. - #[serde(rename="campaignIdDimensionValue")] - pub campaign_id_dimension_value: Option<DimensionValue>, - /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads. - #[serde(rename="enabledByDefault")] - pub enabled_by_default: Option<bool>, - /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion. +pub struct CreativeField { + /// Advertiser ID of this creative field. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option<String>, - /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites. - #[serde(rename="siteFilterType")] - pub site_filter_type: Option<String>, - /// Event tag type. Can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. This is a required field. - #[serde(rename="type")] - pub type_: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField". + pub kind: Option<String>, + /// Subaccount ID of this creative field. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Name of this creative field. This is a required field and must be less than 256 characters long and unique among creative fields of the same advertiser. + pub name: Option<String>, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option<DimensionValue>, - /// ID of this event tag. This is a read-only, auto-generated field. + /// ID of this creative field. This is a read-only, auto-generated field. pub id: Option<String>, - /// Account ID of this event tag. This is a read-only field that can be left blank. + /// Account ID of this creative field. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option<String>, - /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag". - pub kind: Option<String>, - /// Subaccount ID of this event tag. This is a read-only field that can be left blank. - #[serde(rename="subaccountId")] - pub subaccount_id: Option<String>, - /// Name of this event tag. This is a required field and must be less than 256 characters long. - pub name: Option<String>, - /// Payload URL for this event tag. The URL on a click-through event tag should have a landing page URL appended to the end of it. This field is required on insertion. - pub url: Option<String>, - /// Whether this tag is SSL-compliant or not. - #[serde(rename="sslCompliant")] - pub ssl_compliant: Option<bool>, - /// Number of times the landing page URL should be URL-escaped before being appended to the click-through event tag URL. Only applies to click-through event tags as specified by the event tag type. - #[serde(rename="urlEscapeLevels")] - pub url_escape_levels: Option<i32>, } -impl RequestValue for EventTag {} -impl Resource for EventTag {} -impl ResponseResult for EventTag {} +impl RequestValue for CreativeField {} +impl Resource for CreativeField {} +impl ResponseResult for CreativeField {} /// Creative Field Value List Response @@ -5443,17 +5991,38 @@ impl ResponseResult for EventTag {} pub struct CreativeFieldValuesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValuesListResponse". - pub kind: String, + pub kind: Option<String>, /// Creative field value collection. #[serde(rename="creativeFieldValues")] - pub creative_field_values: Vec<CreativeFieldValue>, + pub creative_field_values: Option<Vec<CreativeFieldValue>>, } impl ResponseResult for CreativeFieldValuesListResponse {} +/// The properties of the report. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ReportFloodlightCriteriaReportProperties { + /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion. + #[serde(rename="includeUnattributedIPConversions")] + pub include_unattributed_ip_conversions: Option<bool>, + /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window. + #[serde(rename="includeUnattributedCookieConversions")] + pub include_unattributed_cookie_conversions: Option<bool>, + /// Include conversions that have no cookie, but do have an exposure path. + #[serde(rename="includeAttributedIPConversions")] + pub include_attributed_ip_conversions: Option<bool>, +} + +impl NestedType for ReportFloodlightCriteriaReportProperties {} +impl Part for ReportFloodlightCriteriaReportProperties {} + + /// Contains properties of a Site Directory contact. /// /// # Activities @@ -5467,22 +6036,28 @@ impl ResponseResult for CreativeFieldValuesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySiteContact { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContact". - pub kind: String, - /// Directory site contact role. - pub role: String, + pub kind: Option<String>, /// First name of this directory site contact. #[serde(rename="firstName")] - pub first_name: String, + pub first_name: Option<String>, + /// Title or designation of this directory site contact. + pub title: Option<String>, /// Last name of this directory site contact. #[serde(rename="lastName")] - pub last_name: String, + pub last_name: Option<String>, + /// ID of this directory site contact. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Phone number of this directory site contact. + pub phone: Option<String>, + /// Directory site contact role. + pub role: Option<String>, + /// Address of this directory site contact. + pub address: Option<String>, /// Directory site contact type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Email address of this directory site contact. - pub email: String, - /// ID of this directory site contact. This is a read-only, auto-generated field. - pub id: String, + pub email: Option<String>, } impl Resource for DirectorySiteContact {} @@ -5532,12 +6107,12 @@ impl Resource for DimensionValue {} pub struct ContentCategoriesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategoriesListResponse". - pub kind: String, + pub kind: Option<String>, /// Content category collection. #[serde(rename="contentCategories")] - pub content_categories: Vec<ContentCategory>, + pub content_categories: Option<Vec<ContentCategory>>, } impl ResponseResult for ContentCategoriesListResponse {} @@ -5556,14 +6131,86 @@ impl ResponseResult for ContentCategoriesListResponse {} pub struct FloodlightConfigurationsListResponse { /// Floodlight configuration collection. #[serde(rename="floodlightConfigurations")] - pub floodlight_configurations: Vec<FloodlightConfiguration>, + pub floodlight_configurations: Option<Vec<FloodlightConfiguration>>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfigurationsListResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for FloodlightConfigurationsListResponse {} +/// Describes properties of a DoubleClick Planning order. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list orders](struct.OrderListCall.html) (none) +/// * [get orders](struct.OrderGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Order { + /// Terms and conditions of this order. + #[serde(rename="termsAndConditions")] + pub terms_and_conditions: Option<String>, + /// Name of the buyer organization. + #[serde(rename="buyerOrganizationName")] + pub buyer_organization_name: Option<String>, + /// Advertiser ID of this order. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Site IDs this order is associated with. + #[serde(rename="siteId")] + pub site_id: Option<Vec<String>>, + /// Buyer invoice ID associated with this order. + #[serde(rename="buyerInvoiceId")] + pub buyer_invoice_id: Option<String>, + /// ID of the terms and conditions template used in this order. + #[serde(rename="planningTermId")] + pub planning_term_id: Option<String>, + /// ID of this order. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Account ID of this order. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#order". + pub kind: Option<String>, + /// Subaccount ID of this order. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Name of this order. + pub name: Option<String>, + /// Contacts for this order. + pub contacts: Option<Vec<OrderContact>>, + /// Information about the most recent modification of this order. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option<LastModifiedInfo>, + /// Notes of this order. + pub notes: Option<String>, + /// Name of the seller organization. + #[serde(rename="sellerOrganizationName")] + pub seller_organization_name: Option<String>, + /// Comments in this order. + pub comments: Option<String>, + /// IDs for users that have to approve documents created for this order. + #[serde(rename="approverUserProfileIds")] + pub approver_user_profile_ids: Option<Vec<String>>, + /// Seller order ID associated with this order. + #[serde(rename="sellerOrderId")] + pub seller_order_id: Option<String>, + /// Project ID of this order. + #[serde(rename="projectId")] + pub project_id: Option<String>, + /// Free-form site names this order is associated with. + #[serde(rename="siteNames")] + pub site_names: Option<Vec<String>>, +} + +impl Resource for Order {} +impl ResponseResult for Order {} + + /// Popup Window Properties. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -5572,28 +6219,28 @@ impl ResponseResult for FloodlightConfigurationsListResponse {} pub struct PopupWindowProperties { /// Whether to display the browser status bar. #[serde(rename="showStatusBar")] - pub show_status_bar: bool, + pub show_status_bar: Option<bool>, /// Whether to display the browser scroll bar. #[serde(rename="showScrollBar")] - pub show_scroll_bar: bool, + pub show_scroll_bar: Option<bool>, /// Whether to display the browser address bar. #[serde(rename="showAddressBar")] - pub show_address_bar: bool, + pub show_address_bar: Option<bool>, /// Whether to display the browser menu bar. #[serde(rename="showMenuBar")] - pub show_menu_bar: bool, + pub show_menu_bar: Option<bool>, /// Title of popup window. - pub title: String, + pub title: Option<String>, /// Upper-left corner coordinates of the popup window. Applicable if positionType is COORDINATES. - pub offset: OffsetPosition, + pub offset: Option<OffsetPosition>, /// Popup window position either centered or at specific coordinate. #[serde(rename="positionType")] - pub position_type: String, + pub position_type: Option<String>, /// Whether to display the browser tool bar. #[serde(rename="showToolBar")] - pub show_tool_bar: bool, + pub show_tool_bar: Option<bool>, /// Popup dimension for a creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID - pub dimension: Size, + pub dimension: Option<Size>, } impl Part for PopupWindowProperties {} @@ -5613,28 +6260,104 @@ impl Part for PopupWindowProperties {} pub struct AccountPermission { /// Permission group of this account permission. #[serde(rename="permissionGroupId")] - pub permission_group_id: String, + pub permission_group_id: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermission". - pub kind: String, + pub kind: Option<String>, /// Name of this account permission. - pub name: String, + pub name: Option<String>, /// Administrative level required to enable this account permission. - pub level: String, + pub level: Option<String>, /// Account profiles associated with this account permission. /// /// Possible values are: /// - "ACCOUNT_PROFILE_BASIC" /// - "ACCOUNT_PROFILE_STANDARD" #[serde(rename="accountProfiles")] - pub account_profiles: Vec<String>, + pub account_profiles: Option<Vec<String>>, /// ID of this account permission. - pub id: String, + pub id: Option<String>, } impl Resource for AccountPermission {} impl ResponseResult for AccountPermission {} +/// Contains properties of a DoubleClick Planning project. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get projects](struct.ProjectGetCall.html) (response) +/// * [list projects](struct.ProjectListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Project { + /// Start date of the project. + #[serde(rename="startDate")] + pub start_date: Option<String>, + /// CPM that the advertiser is targeting. + #[serde(rename="targetCpmNanos")] + pub target_cpm_nanos: Option<String>, + /// End date of the project. + #[serde(rename="endDate")] + pub end_date: Option<String>, + /// Client billing code of this project. + #[serde(rename="clientBillingCode")] + pub client_billing_code: Option<String>, + /// Overview of this project. + pub overview: Option<String>, + /// Number of clicks that the advertiser is targeting. + #[serde(rename="targetClicks")] + pub target_clicks: Option<String>, + /// CPA that the advertiser is targeting. + #[serde(rename="targetCpaNanos")] + pub target_cpa_nanos: Option<String>, + /// Advertiser ID of this project. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Number of impressions that the advertiser is targeting. + #[serde(rename="targetImpressions")] + pub target_impressions: Option<String>, + /// Subaccount ID of this project. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Audience gender of this project. + #[serde(rename="audienceGender")] + pub audience_gender: Option<String>, + /// ID of this project. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Account ID of this project. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#project". + pub kind: Option<String>, + /// CPC that the advertiser is targeting. + #[serde(rename="targetCpcNanos")] + pub target_cpc_nanos: Option<String>, + /// Name of this project. + pub name: Option<String>, + /// Information about the most recent modification of this project. + #[serde(rename="lastModifiedInfo")] + pub last_modified_info: Option<LastModifiedInfo>, + /// Budget of this project in the currency specified by the current account. The value stored in this field represents only the non-fractional amount. For example, for USD, the smallest value that can be represented by this field is 1 US dollar. + pub budget: Option<String>, + /// Audience age group of this project. + #[serde(rename="audienceAgeGroup")] + pub audience_age_group: Option<String>, + /// Number of conversions that the advertiser is targeting. + #[serde(rename="targetConversions")] + pub target_conversions: Option<String>, + /// Name of the project client. + #[serde(rename="clientName")] + pub client_name: Option<String>, +} + +impl Resource for Project {} +impl ResponseResult for Project {} + + /// Contains properties of a DCM ad. /// /// # Activities @@ -5766,24 +6489,93 @@ impl ResponseResult for Ad {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PricingSchedulePricingPeriod { /// Units of this pricing period. - pub units: String, + pub units: Option<String>, /// Pricing period start date. This date must be later than, or the same day as, the placement start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// Rate or cost of this pricing period. #[serde(rename="rateOrCostNanos")] - pub rate_or_cost_nanos: String, + pub rate_or_cost_nanos: Option<String>, /// Pricing period end date. This date must be later than, or the same day as, the pricing period start date, but not later than the placement end date. The period end date can be the same date as the period start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective pricing period date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// Comments for this pricing period. #[serde(rename="pricingComment")] - pub pricing_comment: String, + pub pricing_comment: Option<String>, } impl Part for PricingSchedulePricingPeriod {} +/// Contains properties of an event tag. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [delete event tags](struct.EventTagDeleteCall.html) (none) +/// * [patch event tags](struct.EventTagPatchCall.html) (request|response) +/// * [list event tags](struct.EventTagListCall.html) (none) +/// * [update event tags](struct.EventTagUpdateCall.html) (request|response) +/// * [insert event tags](struct.EventTagInsertCall.html) (request|response) +/// * [get event tags](struct.EventTagGetCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct EventTag { + /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field. + pub status: Option<String>, + /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter. + #[serde(rename="siteIds")] + pub site_ids: Option<Vec<String>>, + /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion. + #[serde(rename="campaignId")] + pub campaign_id: Option<String>, + /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. + #[serde(rename="campaignIdDimensionValue")] + pub campaign_id_dimension_value: Option<DimensionValue>, + /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads. + #[serde(rename="enabledByDefault")] + pub enabled_by_default: Option<bool>, + /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion. + #[serde(rename="advertiserId")] + pub advertiser_id: Option<String>, + /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites. + #[serde(rename="siteFilterType")] + pub site_filter_type: Option<String>, + /// Event tag type. Can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. This is a required field. + #[serde(rename="type")] + pub type_: Option<String>, + /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. + #[serde(rename="advertiserIdDimensionValue")] + pub advertiser_id_dimension_value: Option<DimensionValue>, + /// ID of this event tag. This is a read-only, auto-generated field. + pub id: Option<String>, + /// Account ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="accountId")] + pub account_id: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag". + pub kind: Option<String>, + /// Subaccount ID of this event tag. This is a read-only field that can be left blank. + #[serde(rename="subaccountId")] + pub subaccount_id: Option<String>, + /// Name of this event tag. This is a required field and must be less than 256 characters long. + pub name: Option<String>, + /// Payload URL for this event tag. The URL on a click-through event tag should have a landing page URL appended to the end of it. This field is required on insertion. + pub url: Option<String>, + /// Whether this tag is SSL-compliant or not. + #[serde(rename="sslCompliant")] + pub ssl_compliant: Option<bool>, + /// Number of times the landing page URL should be URL-escaped before being appended to the click-through event tag URL. Only applies to click-through event tags as specified by the event tag type. + #[serde(rename="urlEscapeLevels")] + pub url_escape_levels: Option<i32>, +} + +impl RequestValue for EventTag {} +impl Resource for EventTag {} +impl ResponseResult for EventTag {} + + /// Placement Assignment. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -5791,16 +6583,16 @@ impl Part for PricingSchedulePricingPeriod {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementAssignment { /// Whether this placement assignment is active. When true, the placement will be included in the ad's rotation. - pub active: bool, + pub active: Option<bool>, /// Dimension value for the ID of the placement. This is a read-only, auto-generated field. #[serde(rename="placementIdDimensionValue")] - pub placement_id_dimension_value: DimensionValue, + pub placement_id_dimension_value: Option<DimensionValue>, /// ID of the placement to be assigned. This is a required field. #[serde(rename="placementId")] - pub placement_id: String, + pub placement_id: Option<String>, /// Whether the placement to be assigned requires SSL. This is a read-only field that is auto-generated when the ad is inserted or updated. #[serde(rename="sslRequired")] - pub ssl_required: bool, + pub ssl_required: Option<bool>, } impl Part for PlacementAssignment {} @@ -5813,20 +6605,20 @@ impl Part for PlacementAssignment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReachReportCompatibleFields { /// Metrics which are compatible to be selected in the "metricNames" section of the report. - pub metrics: Vec<Metric>, + pub metrics: Option<Vec<Metric>>, /// The kind of resource this is, in this case dfareporting#reachReportCompatibleFields. - pub kind: String, + pub kind: Option<String>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. - pub dimensions: Vec<Dimension>, + pub dimensions: Option<Vec<Dimension>>, /// Metrics which are compatible to be selected in the "reachByFrequencyMetricNames" section of the report. #[serde(rename="reachByFrequencyMetrics")] - pub reach_by_frequency_metrics: Vec<Metric>, + pub reach_by_frequency_metrics: Option<Vec<Metric>>, /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] - pub dimension_filters: Vec<Dimension>, + pub dimension_filters: Option<Vec<Dimension>>, /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. #[serde(rename="pivotedActivityMetrics")] - pub pivoted_activity_metrics: Vec<Metric>, + pub pivoted_activity_metrics: Option<Vec<Metric>>, } impl Part for ReachReportCompatibleFields {} @@ -5893,18 +6685,18 @@ impl ResponseResult for Site {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DfpSettings { /// DFP network name for this directory site. - pub dfp_network_name: String, + pub dfp_network_name: Option<String>, /// DFP network code for this directory site. - pub dfp_network_code: String, + pub dfp_network_code: Option<String>, /// Whether this directory site is available only via DoubleClick Publisher Portal. #[serde(rename="publisherPortalOnly")] - pub publisher_portal_only: bool, + pub publisher_portal_only: Option<bool>, /// Whether this directory site accepts programmatic placements. #[serde(rename="programmaticPlacementAccepted")] - pub programmatic_placement_accepted: bool, + pub programmatic_placement_accepted: Option<bool>, /// Whether this directory site accepts publisher-paid tags. #[serde(rename="pubPaidPlacementAccepted")] - pub pub_paid_placement_accepted: bool, + pub pub_paid_placement_accepted: Option<bool>, } impl Part for DfpSettings {} @@ -5922,10 +6714,10 @@ impl Part for DfpSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConnectionTypesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionTypesListResponse". - pub kind: String, + pub kind: Option<String>, /// Collection of connection types such as broadband and mobile. #[serde(rename="connectionTypes")] - pub connection_types: Vec<ConnectionType>, + pub connection_types: Option<Vec<ConnectionType>>, } impl ResponseResult for ConnectionTypesListResponse {} @@ -6013,15 +6805,15 @@ impl ResponseResult for FloodlightConfiguration {} pub struct DateRange { /// The start date of the date range, inclusive. A string of the format: "yyyy-MM-dd". #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// The kind of resource this is, in this case dfareporting#dateRange. - pub kind: String, + pub kind: Option<String>, /// The end date of the date range, inclusive. A string of the format: "yyyy-MM-dd". #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// The date range relative to the date of when the report is run. #[serde(rename="relativeDateRange")] - pub relative_date_range: String, + pub relative_date_range: Option<String>, } impl Part for DateRange {} @@ -6039,10 +6831,10 @@ impl Part for DateRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissionGroupsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroupsListResponse". - pub kind: String, + pub kind: Option<String>, /// Account permission group collection. #[serde(rename="accountPermissionGroups")] - pub account_permission_groups: Vec<AccountPermissionGroup>, + pub account_permission_groups: Option<Vec<AccountPermissionGroup>>, } impl ResponseResult for AccountPermissionGroupsListResponse {} @@ -6060,9 +6852,9 @@ impl ResponseResult for AccountPermissionGroupsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SizesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sizesListResponse". - pub kind: String, + pub kind: Option<String>, /// Size collection. - pub sizes: Vec<Size>, + pub sizes: Option<Vec<Size>>, } impl ResponseResult for SizesListResponse {} @@ -6081,12 +6873,12 @@ impl ResponseResult for SizesListResponse {} pub struct UserRolesListResponse { /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolesListResponse". - pub kind: String, + pub kind: Option<String>, /// User role collection. #[serde(rename="userRoles")] - pub user_roles: Vec<UserRole>, + pub user_roles: Option<Vec<UserRole>>, } impl ResponseResult for UserRolesListResponse {} @@ -6107,12 +6899,12 @@ impl ResponseResult for UserRolesListResponse {} /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6184,12 +6976,12 @@ impl<'a, C, A> UserRolePermissionGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6197,7 +6989,7 @@ impl<'a, C, A> UserRolePermissionGroupMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.platform_types(); /// # } @@ -6212,6 +7004,25 @@ impl<'a, C, A> MethodsBuilder for PlatformTypeMethods<'a, C, A> {} impl<'a, C, A> PlatformTypeMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Gets one platform type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Platform type ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlatformTypeGetCall<'a, C, A> { + PlatformTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves a list of platform types. @@ -6232,6 +7043,179 @@ impl<'a, C, A> PlatformTypeMethods<'a, C, A> { +/// A builder providing access to all methods supported on *creativeFieldValue* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.creative_field_values(); +/// # } +/// ``` +pub struct CreativeFieldValueMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for CreativeFieldValueMethods<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field value. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `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> { + CreativeFieldValuePatchCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one creative field value by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn get(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueGetCall<'a, C, A> { + CreativeFieldValueGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing creative field value. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + /// * `id` - Creative Field Value ID + pub fn delete(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + CreativeFieldValueDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative field value. + /// + /// # Arguments + /// + /// * `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> { + CreativeFieldValueInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing creative field value. + /// + /// # Arguments + /// + /// * `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> { + CreativeFieldValueUpdateCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of creative field values, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `creativeFieldId` - Creative field ID for this creative field value. + pub fn list(&self, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueListCall<'a, C, A> { + CreativeFieldValueListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _creative_field_id: creative_field_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *creativeField* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -6242,12 +7226,12 @@ impl<'a, C, A> PlatformTypeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6404,12 +7388,12 @@ impl<'a, C, A> CreativeFieldMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6567,12 +7551,12 @@ impl<'a, C, A> UserRoleMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6580,7 +7564,7 @@ impl<'a, C, A> UserRoleMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.operating_system_versions(); /// # } @@ -6595,6 +7579,25 @@ impl<'a, C, A> MethodsBuilder for OperatingSystemVersionMethods<'a, C, A> {} impl<'a, C, A> OperatingSystemVersionMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system version by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Operating system version ID. + pub fn get(&self, profile_id: &str, id: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + OperatingSystemVersionGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves a list of operating system versions. @@ -6625,12 +7628,12 @@ impl<'a, C, A> OperatingSystemVersionMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6782,6 +7785,68 @@ impl<'a, C, A> LandingPageMethods<'a, C, A> { +/// A builder providing access to all methods supported on *creativeAsset* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.creative_assets(); +/// # } +/// ``` +pub struct CreativeAssetMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for CreativeAssetMethods<'a, C, A> {} + +impl<'a, C, A> CreativeAssetMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new creative asset. + /// + /// # Arguments + /// + /// * `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> { + CreativeAssetInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *campaignCreativeAssociation* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -6792,12 +7857,12 @@ impl<'a, C, A> LandingPageMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6876,12 +7941,12 @@ impl<'a, C, A> CampaignCreativeAssociationMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6953,7 +8018,7 @@ impl<'a, C, A> ChangeLogMethods<'a, C, A> { -/// A builder providing access to all methods supported on *account* resources. +/// A builder providing access to all methods supported on *remarketingListShare* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example @@ -6963,12 +8028,12 @@ impl<'a, C, A> ChangeLogMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -6976,34 +8041,34 @@ impl<'a, C, A> ChangeLogMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // like `get(...)`, `patch(...)` and `update(...)` /// // to build up your call. -/// let rb = hub.accounts(); +/// let rb = hub.remarketing_list_shares(); /// # } /// ``` -pub struct AccountMethods<'a, C, A> +pub struct RemarketingListShareMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, } -impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for RemarketingListShareMethods<'a, C, A> {} -impl<'a, C, A> AccountMethods<'a, C, A> { +impl<'a, C, A> RemarketingListShareMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets one account by ID. + /// Gets one remarketing list share by remarketing list ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. - /// * `id` - Account ID. - pub fn get(&self, profile_id: &str, id: &str) -> AccountGetCall<'a, C, A> { - AccountGetCall { + /// * `remarketingListId` - Remarketing list ID. + pub fn get(&self, profile_id: &str, remarketing_list_id: &str) -> RemarketingListShareGetCall<'a, C, A> { + RemarketingListShareGetCall { hub: self.hub, _profile_id: profile_id.to_string(), - _id: id.to_string(), + _remarketing_list_id: remarketing_list_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -7012,120 +8077,283 @@ impl<'a, C, A> AccountMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Retrieves the list of accounts, possibly filtered. + /// Updates an existing remarketing list share. This method supports patch semantics. /// /// # Arguments /// + /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. - pub fn list(&self, profile_id: &str) -> AccountListCall<'a, C, A> { - AccountListCall { + /// * `remarketingListId` - Remarketing list ID. + pub fn patch(&self, request: &RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, C, A> { + RemarketingListSharePatchCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _remarketing_list_id: remarketing_list_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing remarketing list share. + /// + /// # Arguments + /// + /// * `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> { + RemarketingListShareUpdateCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *report* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.reports(); +/// # } +/// ``` +pub struct ReportMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {} + +impl<'a, C, A> ReportMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Runs a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + pub fn run(&self, profile_id: &str, report_id: &str) -> ReportRunCall<'a, C, A> { + ReportRunCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _synchronous: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `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> { + ReportPatchCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Lists files for a report. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the parent report. + pub fn files_list(&self, profile_id: &str, report_id: &str) -> ReportFileListCall<'a, C, A> { + ReportFileListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a report. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `profileId` - The DFA user profile ID. + pub fn insert(&self, request: &Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { + ReportInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a report. + /// + /// # Arguments + /// + /// * `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> { + ReportUpdateCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. + /// + /// # Arguments + /// + /// * `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> { + ReportCompatibleFieldQueryCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn get(&self, profile_id: &str, report_id: &str) -> ReportGetCall<'a, C, A> { + ReportGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a report file. + /// + /// # Arguments + /// + /// * `profileId` - The DFA profile ID. + /// * `reportId` - The ID of the report. + /// * `fileId` - The ID of the report file. + pub fn files_get(&self, profile_id: &str, report_id: &str, file_id: &str) -> ReportFileGetCall<'a, C, A> { + ReportFileGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _file_id: file_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a report by its ID. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + /// * `reportId` - The ID of the report. + pub fn delete(&self, profile_id: &str, report_id: &str) -> ReportDeleteCall<'a, C, A> { + ReportDeleteCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _report_id: report_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves list of reports. + /// + /// # Arguments + /// + /// * `profileId` - The DFA user profile ID. + pub fn list(&self, profile_id: &str) -> ReportListCall<'a, C, A> { + ReportListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), - _search_string: Default::default(), + _scope: Default::default(), _page_token: Default::default(), _max_results: Default::default(), - _ids: Default::default(), - _active: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an existing account. - /// - /// # Arguments - /// - /// * `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> { - AccountUpdateCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an existing account. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `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> { - AccountPatchCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _id: id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } -} - - - -/// A builder providing access to all methods supported on *postalCode* resources. -/// It is not used directly, but through the `Dfareporting` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// <MemoryStorage as Default>::default(), None); -/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` -/// // to build up your call. -/// let rb = hub.postal_codes(); -/// # } -/// ``` -pub struct PostalCodeMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, -} - -impl<'a, C, A> MethodsBuilder for PostalCodeMethods<'a, C, A> {} - -impl<'a, C, A> PostalCodeMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of postal codes. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - pub fn list(&self, profile_id: &str) -> PostalCodeListCall<'a, C, A> { - PostalCodeListCall { - hub: self.hub, - _profile_id: profile_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -7145,12 +8373,12 @@ impl<'a, C, A> PostalCodeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7293,12 +8521,12 @@ impl<'a, C, A> AdvertiserMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7355,12 +8583,12 @@ impl<'a, C, A> DimensionValueMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7519,12 +8747,12 @@ impl<'a, C, A> FloodlightActivityGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7567,6 +8795,94 @@ impl<'a, C, A> MetroMethods<'a, C, A> { +/// A builder providing access to all methods supported on *order* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.orders(); +/// # } +/// ``` +pub struct OrderMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for OrderMethods<'a, C, A> {} + +impl<'a, C, A> OrderMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of orders, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderListCall<'a, C, A> { + OrderListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one order by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for orders. + /// * `id` - Order ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderGetCall<'a, C, A> { + OrderGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *directorySiteContact* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -7577,12 +8893,12 @@ impl<'a, C, A> MetroMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7661,12 +8977,12 @@ impl<'a, C, A> DirectorySiteContactMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7731,12 +9047,12 @@ impl<'a, C, A> UserProfileMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7891,12 +9207,12 @@ impl<'a, C, A> AdMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7968,12 +9284,12 @@ impl<'a, C, A> AccountPermissionMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -7981,7 +9297,7 @@ impl<'a, C, A> AccountPermissionMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.connection_types(); /// # } @@ -8012,6 +9328,25 @@ impl<'a, C, A> ConnectionTypeMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Gets one connection type by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Connection type ID. + pub fn get(&self, profile_id: &str, id: &str) -> ConnectionTypeGetCall<'a, C, A> { + ConnectionTypeGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -8026,12 +9361,12 @@ impl<'a, C, A> ConnectionTypeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8187,12 +9522,12 @@ impl<'a, C, A> AdvertiserGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8338,12 +9673,12 @@ impl<'a, C, A> SiteMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8524,12 +9859,12 @@ impl<'a, C, A> FloodlightActivityMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8582,12 +9917,12 @@ impl<'a, C, A> RegionMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8716,6 +10051,91 @@ impl<'a, C, A> CreativeGroupMethods<'a, C, A> { +/// A builder providing access to all methods supported on *targetableRemarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.targetable_remarketing_lists(); +/// # } +/// ``` +pub struct TargetableRemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for TargetableRemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of targetable remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only targetable remarketing lists targetable by these advertisers. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> TargetableRemarketingListListCall<'a, C, A> { + TargetableRemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + TargetableRemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *subaccount* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -8726,12 +10146,12 @@ impl<'a, C, A> CreativeGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8868,12 +10288,12 @@ impl<'a, C, A> SubaccountMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8881,7 +10301,7 @@ impl<'a, C, A> SubaccountMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.mobile_carriers(); /// # } @@ -8896,6 +10316,25 @@ impl<'a, C, A> MethodsBuilder for MobileCarrierMethods<'a, C, A> {} impl<'a, C, A> MobileCarrierMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Gets one mobile carrier by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Mobile carrier ID. + pub fn get(&self, profile_id: &str, id: &str) -> MobileCarrierGetCall<'a, C, A> { + MobileCarrierGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves a list of mobile carriers. @@ -8926,12 +10365,12 @@ impl<'a, C, A> MobileCarrierMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -8954,6 +10393,25 @@ impl<'a, C, A> MethodsBuilder for FloodlightConfigurationMethods<'a, C, A> {} impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Gets one floodlight configuration by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Floodlight configuration ID. + pub fn get(&self, profile_id: &str, id: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + FloodlightConfigurationGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight configuration. @@ -8994,25 +10452,6 @@ impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Gets one floodlight configuration by ID. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - /// * `id` - Floodlight configuration ID. - pub fn get(&self, profile_id: &str, id: &str) -> FloodlightConfigurationGetCall<'a, C, A> { - FloodlightConfigurationGetCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _id: id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Retrieves a list of floodlight configurations, possibly filtered. @@ -9044,12 +10483,12 @@ impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9057,7 +10496,7 @@ impl<'a, C, A> FloodlightConfigurationMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `list(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.operating_systems(); /// # } @@ -9088,6 +10527,25 @@ impl<'a, C, A> OperatingSystemMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Gets one operating system by DART ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `dartId` - Operating system DART ID. + pub fn get(&self, profile_id: &str, dart_id: &str) -> OperatingSystemGetCall<'a, C, A> { + OperatingSystemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _dart_id: dart_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -9102,12 +10560,12 @@ impl<'a, C, A> OperatingSystemMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9184,12 +10642,12 @@ impl<'a, C, A> FileMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9325,7 +10783,7 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { -/// A builder providing access to all methods supported on *creativeAsset* resources. +/// A builder providing access to all methods supported on *inventoryItem* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example @@ -9335,12 +10793,12 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9348,36 +10806,63 @@ impl<'a, C, A> PlacementGroupMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `insert(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. -/// let rb = hub.creative_assets(); +/// let rb = hub.inventory_items(); /// # } /// ``` -pub struct CreativeAssetMethods<'a, C, A> +pub struct InventoryItemMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, } -impl<'a, C, A> MethodsBuilder for CreativeAssetMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for InventoryItemMethods<'a, C, A> {} -impl<'a, C, A> CreativeAssetMethods<'a, C, A> { +impl<'a, C, A> InventoryItemMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Inserts a new creative asset. + /// Retrieves a list of inventory items, possibly filtered. /// /// # Arguments /// - /// * `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> { - CreativeAssetInsertCall { + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> InventoryItemListCall<'a, C, A> { + InventoryItemListCall { hub: self.hub, - _request: request.clone(), _profile_id: profile_id.to_string(), - _advertiser_id: advertiser_id.to_string(), + _project_id: project_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _site_id: Default::default(), + _page_token: Default::default(), + _order_id: Default::default(), + _max_results: Default::default(), + _in_plan: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one inventory item by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `projectId` - Project ID for order documents. + /// * `id` - Inventory item ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> InventoryItemGetCall<'a, C, A> { + InventoryItemGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _project_id: project_id.to_string(), + _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -9397,12 +10882,12 @@ impl<'a, C, A> CreativeAssetMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9475,12 +10960,12 @@ impl<'a, C, A> UserRolePermissionMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9552,12 +11037,12 @@ impl<'a, C, A> AccountPermissionGroupMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9713,12 +11198,12 @@ impl<'a, C, A> ContentCategoryMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -9743,14 +11228,14 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Inserts a new creative. + /// Updates an existing creative. /// /// # Arguments /// /// * `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> { - CreativeInsertCall { + pub fn update(&self, request: &Creative, profile_id: &str) -> CreativeUpdateCall<'a, C, A> { + CreativeUpdateCall { hub: self.hub, _request: request.clone(), _profile_id: profile_id.to_string(), @@ -9762,14 +11247,14 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing creative. + /// Inserts a new creative. /// /// # Arguments /// /// * `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> { - CreativeUpdateCall { + pub fn insert(&self, request: &Creative, profile_id: &str) -> CreativeInsertCall<'a, C, A> { + CreativeInsertCall { hub: self.hub, _request: request.clone(), _profile_id: profile_id.to_string(), @@ -9865,12 +11350,12 @@ impl<'a, C, A> CreativeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10018,12 +11503,12 @@ impl<'a, C, A> CampaignMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10173,6 +11658,151 @@ impl<'a, C, A> EventTagMethods<'a, C, A> { +/// A builder providing access to all methods supported on *remarketingList* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.remarketing_lists(); +/// # } +/// ``` +pub struct RemarketingListMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for RemarketingListMethods<'a, C, A> {} + +impl<'a, C, A> RemarketingListMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one remarketing list by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Remarketing list ID. + pub fn get(&self, profile_id: &str, id: &str) -> RemarketingListGetCall<'a, C, A> { + RemarketingListGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing remarketing list. + /// + /// # Arguments + /// + /// * `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> { + RemarketingListUpdateCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of remarketing lists, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `advertiserId` - Select only remarketing lists owned by this advertiser. + pub fn list(&self, profile_id: &str, advertiser_id: &str) -> RemarketingListListCall<'a, C, A> { + RemarketingListListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _advertiser_id: advertiser_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _floodlight_activity_id: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing remarketing list. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `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> { + RemarketingListPatchCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new remarketing list. + /// + /// # Arguments + /// + /// * `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> { + RemarketingListInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *city* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -10183,12 +11813,12 @@ impl<'a, C, A> EventTagMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10245,12 +11875,12 @@ impl<'a, C, A> CityMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10273,29 +11903,6 @@ impl<'a, C, A> MethodsBuilder for PlacementStrategyMethods<'a, C, A> {} impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of placement strategies, possibly filtered. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - pub fn list(&self, profile_id: &str) -> PlacementStrategyListCall<'a, C, A> { - PlacementStrategyListCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _sort_order: Default::default(), - _sort_field: Default::default(), - _search_string: Default::default(), - _page_token: Default::default(), - _max_results: Default::default(), - _ids: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Updates an existing placement strategy. @@ -10334,6 +11941,29 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of placement strategies, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PlacementStrategyListCall<'a, C, A> { + PlacementStrategyListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes an existing placement strategy. @@ -10396,6 +12026,90 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { +/// A builder providing access to all methods supported on *project* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.projects(); +/// # } +/// ``` +pub struct ProjectMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {} + +impl<'a, C, A> ProjectMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of projects, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> ProjectListCall<'a, C, A> { + ProjectListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _advertiser_ids: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Gets one project by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Project ID. + pub fn get(&self, profile_id: &str, id: &str) -> ProjectGetCall<'a, C, A> { + ProjectGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *directorySite* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -10406,12 +12120,12 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10419,7 +12133,7 @@ impl<'a, C, A> PlacementStrategyMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)` and `list(...)` +/// // like `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.directory_sites(); /// # } @@ -10434,6 +12148,25 @@ impl<'a, C, A> MethodsBuilder for DirectorySiteMethods<'a, C, A> {} impl<'a, C, A> DirectorySiteMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Inserts a new directory site. + /// + /// # Arguments + /// + /// * `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> { + DirectorySiteInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves a list of directory sites, possibly filtered. @@ -10496,12 +12229,12 @@ impl<'a, C, A> DirectorySiteMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10596,12 +12329,12 @@ impl<'a, C, A> SizeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10656,12 +12389,12 @@ impl<'a, C, A> AccountActiveAdSummaryMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10669,7 +12402,7 @@ impl<'a, C, A> AccountActiveAdSummaryMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.account_user_profiles(); /// # } @@ -10729,6 +12462,25 @@ impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Inserts a new account user profile. + /// + /// # Arguments + /// + /// * `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> { + AccountUserProfileInsertCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Updates an existing account user profile. This method supports patch semantics. @@ -10782,12 +12534,12 @@ impl<'a, C, A> AccountUserProfileMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10849,7 +12601,7 @@ impl<'a, C, A> CountryMethods<'a, C, A> { -/// A builder providing access to all methods supported on *creativeFieldValue* resources. +/// A builder providing access to all methods supported on *orderDocument* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example @@ -10859,12 +12611,12 @@ impl<'a, C, A> CountryMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -10872,37 +12624,35 @@ impl<'a, C, A> CountryMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. -/// let rb = hub.creative_field_values(); +/// let rb = hub.order_documents(); /// # } /// ``` -pub struct CreativeFieldValueMethods<'a, C, A> +pub struct OrderDocumentMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, } -impl<'a, C, A> MethodsBuilder for CreativeFieldValueMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for OrderDocumentMethods<'a, C, A> {} -impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { +impl<'a, C, A> OrderDocumentMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an existing creative field value. This method supports patch semantics. + /// Gets one order document by ID. /// /// # Arguments /// - /// * `request` - No description provided. /// * `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> { - CreativeFieldValuePatchCall { + /// * `projectId` - Project ID for order documents. + /// * `id` - Order document ID. + pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderDocumentGetCall<'a, C, A> { + OrderDocumentGetCall { hub: self.hub, - _request: request.clone(), _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), + _project_id: project_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -10912,107 +12662,26 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Deletes an existing creative field value. + /// Retrieves a list of order documents, possibly filtered. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. - /// * `creativeFieldId` - Creative field ID for this creative field value. - /// * `id` - Creative Field Value ID - pub fn delete(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { - CreativeFieldValueDeleteCall { + /// * `projectId` - Project ID for order documents. + pub fn list(&self, profile_id: &str, project_id: &str) -> OrderDocumentListCall<'a, C, A> { + OrderDocumentListCall { hub: self.hub, _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), - _id: id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Inserts a new creative field value. - /// - /// # Arguments - /// - /// * `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> { - CreativeFieldValueInsertCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates an existing creative field value. - /// - /// # Arguments - /// - /// * `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> { - CreativeFieldValueUpdateCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Gets one creative field value by ID. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - /// * `creativeFieldId` - Creative field ID for this creative field value. - /// * `id` - Creative Field Value ID - pub fn get(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueGetCall<'a, C, A> { - CreativeFieldValueGetCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), - _id: id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a list of creative field values, possibly filtered. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - /// * `creativeFieldId` - Creative field ID for this creative field value. - pub fn list(&self, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueListCall<'a, C, A> { - CreativeFieldValueListCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _creative_field_id: creative_field_id.to_string(), + _project_id: project_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), + _site_id: Default::default(), _search_string: Default::default(), _page_token: Default::default(), + _order_id: Default::default(), _max_results: Default::default(), _ids: Default::default(), + _approved: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -11022,7 +12691,7 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { -/// A builder providing access to all methods supported on *report* resources. +/// A builder providing access to all methods supported on *postalCode* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example @@ -11032,12 +12701,12 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -11045,36 +12714,34 @@ impl<'a, C, A> CreativeFieldValueMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Dfareporting::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)` +/// // like `get(...)` and `list(...)` /// // to build up your call. -/// let rb = hub.reports(); +/// let rb = hub.postal_codes(); /// # } /// ``` -pub struct ReportMethods<'a, C, A> +pub struct PostalCodeMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, } -impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {} +impl<'a, C, A> MethodsBuilder for PostalCodeMethods<'a, C, A> {} -impl<'a, C, A> ReportMethods<'a, C, A> { +impl<'a, C, A> PostalCodeMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates a report. + /// Gets one postal code by ID. /// /// # Arguments /// - /// * `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> { - ReportUpdateCall { + /// * `profileId` - User profile ID associated with this request. + /// * `code` - Postal code ID. + pub fn get(&self, profile_id: &str, code: &str) -> PostalCodeGetCall<'a, C, A> { + PostalCodeGetCall { hub: self.hub, - _request: request.clone(), _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), + _code: code.to_string(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -11083,181 +12750,15 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Runs a report. + /// Retrieves a list of postal codes. /// /// # Arguments /// - /// * `profileId` - The DFA profile ID. - /// * `reportId` - The ID of the report. - pub fn run(&self, profile_id: &str, report_id: &str) -> ReportRunCall<'a, C, A> { - ReportRunCall { + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> PostalCodeListCall<'a, C, A> { + PostalCodeListCall { hub: self.hub, _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _synchronous: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Updates a report. This method supports patch semantics. - /// - /// # Arguments - /// - /// * `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> { - ReportPatchCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Lists files for a report. - /// - /// # Arguments - /// - /// * `profileId` - The DFA profile ID. - /// * `reportId` - The ID of the parent report. - pub fn files_list(&self, profile_id: &str, report_id: &str) -> ReportFileListCall<'a, C, A> { - ReportFileListCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _sort_order: Default::default(), - _sort_field: Default::default(), - _page_token: Default::default(), - _max_results: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Creates a report. - /// - /// # Arguments - /// - /// * `request` - No description provided. - /// * `profileId` - The DFA user profile ID. - pub fn insert(&self, request: &Report, profile_id: &str) -> ReportInsertCall<'a, C, A> { - ReportInsertCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. - /// - /// # Arguments - /// - /// * `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> { - ReportCompatibleFieldQueryCall { - hub: self.hub, - _request: request.clone(), - _profile_id: profile_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a report by its ID. - /// - /// # Arguments - /// - /// * `profileId` - The DFA user profile ID. - /// * `reportId` - The ID of the report. - pub fn get(&self, profile_id: &str, report_id: &str) -> ReportGetCall<'a, C, A> { - ReportGetCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves a report file. - /// - /// # Arguments - /// - /// * `profileId` - The DFA profile ID. - /// * `reportId` - The ID of the report. - /// * `fileId` - The ID of the report file. - pub fn files_get(&self, profile_id: &str, report_id: &str, file_id: &str) -> ReportFileGetCall<'a, C, A> { - ReportFileGetCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _file_id: file_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Deletes a report by its ID. - /// - /// # Arguments - /// - /// * `profileId` - The DFA user profile ID. - /// * `reportId` - The ID of the report. - pub fn delete(&self, profile_id: &str, report_id: &str) -> ReportDeleteCall<'a, C, A> { - ReportDeleteCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _report_id: report_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - - /// Create a builder to help you perform the following task: - /// - /// Retrieves list of reports. - /// - /// # Arguments - /// - /// * `profileId` - The DFA user profile ID. - pub fn list(&self, profile_id: &str) -> ReportListCall<'a, C, A> { - ReportListCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _sort_order: Default::default(), - _sort_field: Default::default(), - _scope: Default::default(), - _page_token: Default::default(), - _max_results: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -11277,12 +12778,12 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -11325,6 +12826,130 @@ impl<'a, C, A> BrowserMethods<'a, C, A> { +/// A builder providing access to all methods supported on *account* resources. +/// It is not used directly, but through the `Dfareporting` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use dfareporting2d1::Dfareporting; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.accounts(); +/// # } +/// ``` +pub struct AccountMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, +} + +impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} + +impl<'a, C, A> AccountMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets one account by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Account ID. + pub fn get(&self, profile_id: &str, id: &str) -> AccountGetCall<'a, C, A> { + AccountGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the list of accounts, possibly filtered. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + pub fn list(&self, profile_id: &str) -> AccountListCall<'a, C, A> { + AccountListCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _sort_order: Default::default(), + _sort_field: Default::default(), + _search_string: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _ids: Default::default(), + _active: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing account. + /// + /// # Arguments + /// + /// * `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> { + AccountUpdateCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing account. This method supports patch semantics. + /// + /// # Arguments + /// + /// * `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> { + AccountPatchCall { + hub: self.hub, + _request: request.clone(), + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *placement* resources. /// It is not used directly, but through the `Dfareporting` hub. /// @@ -11335,12 +12960,12 @@ impl<'a, C, A> BrowserMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dfareporting2 as dfareporting2; +/// extern crate google_dfareporting2d1 as dfareporting2d1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dfareporting2::Dfareporting; +/// use dfareporting2d1::Dfareporting; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -11419,25 +13044,6 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Gets one placement by ID. - /// - /// # Arguments - /// - /// * `profileId` - User profile ID associated with this request. - /// * `id` - Placement ID. - pub fn get(&self, profile_id: &str, id: &str) -> PlacementGetCall<'a, C, A> { - PlacementGetCall { - hub: self.hub, - _profile_id: profile_id.to_string(), - _id: id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Inserts a new placement. @@ -11495,6 +13101,25 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Gets one placement by ID. + /// + /// # Arguments + /// + /// * `profileId` - User profile ID associated with this request. + /// * `id` - Placement ID. + pub fn get(&self, profile_id: &str, id: &str) -> PlacementGetCall<'a, C, A> { + PlacementGetCall { + hub: self.hub, + _profile_id: profile_id.to_string(), + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -11517,11 +13142,11 @@ impl<'a, C, A> PlacementMethods<'a, C, A> { /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -11577,7 +13202,7 @@ impl<'a, C, A> UserRolePermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRolePermissionGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRolePermissionGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -11615,16 +13240,20 @@ impl<'a, C, A> UserRolePermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11759,11 +13388,11 @@ impl<'a, C, A> UserRolePermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -11817,7 +13446,7 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRolePermissionGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRolePermissionGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -11855,16 +13484,20 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11977,6 +13610,252 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype } +/// Gets one platform type by ID. +/// +/// A builder for the *get* method supported by a *platformType* resource. +/// It is not used directly, but through a `PlatformTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.platform_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlatformTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for PlatformTypeGetCall<'a, C, A> {} + +impl<'a, C, A> PlatformTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, PlatformType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.platformTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/platformTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Platform type ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlatformTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> PlatformTypeGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> PlatformTypeGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of platform types. /// /// A builder for the *list* method supported by a *platformType* resource. @@ -11989,11 +13868,11 @@ impl<'a, C, A> UserRolePermissionGroupListCall<'a, C, A> where C: BorrowMut<hype /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -12047,7 +13926,7 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/platformTypes".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/platformTypes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -12085,16 +13964,20 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12207,6 +14090,1656 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, } +/// Updates an existing creative field value. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CreativeFieldValue::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.creative_field_values().patch(&req, "profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValuePatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValuePatchCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "creativeFieldId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValuePatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValuePatchCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValuePatchCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one creative field value by ID. +/// +/// A builder for the *get* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueGetCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["profileId", "creativeFieldId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes an existing creative field value. +/// +/// A builder for the *delete* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().delete("profileId", "creativeFieldId", "id") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _creative_field_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueDeleteCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["profileId", "creativeFieldId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["profileId", "creativeFieldId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Creative Field Value ID + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueDeleteCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueDeleteCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new creative field value. +/// +/// A builder for the *insert* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CreativeFieldValue::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.creative_field_values().insert(&req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "creativeFieldId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing creative field value. +/// +/// A builder for the *update* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeFieldValue; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CreativeFieldValue::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.creative_field_values().update(&req, "profileId", "creativeFieldId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: CreativeFieldValue, + _profile_id: String, + _creative_field_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueUpdateCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + for &field in ["alt", "profileId", "creativeFieldId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "creativeFieldId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of creative field values, possibly filtered. +/// +/// A builder for the *list* method supported by a *creativeFieldValue* resource. +/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("profileId", "creativeFieldId") +/// .sort_order("amet") +/// .sort_field("no") +/// .search_string("labore") +/// .page_token("eirmod") +/// .max_results(-33) +/// .add_ids("invidunt") +/// .doit(); +/// # } +/// ``` +pub struct CreativeFieldValueListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _creative_field_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _search_string: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _ids: Vec<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeFieldValueListCall<'a, C, A> {} + +impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValuesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("creativeFieldId", self._creative_field_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + let mut s = String::new(); + for f in self._ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("ids", s)); + } + for &field in ["alt", "profileId", "creativeFieldId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "creativeFieldId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Creative field ID for this creative field value. + /// + /// Sets the *creative field id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._creative_field_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed. + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only creative field values with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an existing creative field. /// /// A builder for the *update* method supported by a *creativeField* resource. @@ -12219,12 +15752,12 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeField; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeField; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -12234,7 +15767,7 @@ impl<'a, C, A> PlatformTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeField = Default::default(); +/// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12284,7 +15817,7 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -12326,16 +15859,20 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12473,11 +16010,11 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -12488,13 +16025,13 @@ impl<'a, C, A> CreativeFieldUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().list("profileId") -/// .sort_order("et") -/// .sort_field("diam") -/// .search_string("ipsum") -/// .page_token("Lorem") +/// .sort_order("Lorem") +/// .sort_field("sea") +/// .search_string("et") +/// .page_token("duo") /// .max_results(-21) -/// .add_ids("duo") -/// .add_advertiser_ids("aliquyam") +/// .add_ids("eirmod") +/// .add_advertiser_ids("sanctus") /// .doit(); /// # } /// ``` @@ -12574,7 +16111,7 @@ impl<'a, C, A> CreativeFieldListCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -12612,16 +16149,20 @@ impl<'a, C, A> CreativeFieldListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12797,11 +16338,11 @@ impl<'a, C, A> CreativeFieldListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -12856,7 +16397,7 @@ impl<'a, C, A> CreativeFieldDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -12894,16 +16435,20 @@ impl<'a, C, A> CreativeFieldDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13028,11 +16573,11 @@ impl<'a, C, A> CreativeFieldDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -13088,7 +16633,7 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -13126,16 +16671,20 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13270,12 +16819,12 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeField; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeField; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -13285,7 +16834,7 @@ impl<'a, C, A> CreativeFieldGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeField = Default::default(); +/// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13335,7 +16884,7 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -13377,16 +16926,20 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13524,12 +17077,12 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeField; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeField; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -13539,7 +17092,7 @@ impl<'a, C, A> CreativeFieldInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeField = Default::default(); +/// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13591,7 +17144,7 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeFields".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -13633,16 +17186,20 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13790,12 +17347,12 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::UserRole; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::UserRole; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -13805,7 +17362,7 @@ impl<'a, C, A> CreativeFieldPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserRole = Default::default(); +/// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13855,7 +17412,7 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -13897,16 +17454,20 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14044,11 +17605,11 @@ impl<'a, C, A> UserRoleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -14104,7 +17665,7 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -14142,16 +17703,20 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14286,12 +17851,12 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::UserRole; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::UserRole; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -14301,7 +17866,7 @@ impl<'a, C, A> UserRoleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserRole = Default::default(); +/// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14351,7 +17916,7 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -14393,16 +17958,20 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14540,11 +18109,11 @@ impl<'a, C, A> UserRoleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -14599,7 +18168,7 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -14637,16 +18206,20 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -14771,12 +18344,12 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::UserRole; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::UserRole; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -14786,7 +18359,7 @@ impl<'a, C, A> UserRoleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserRole = Default::default(); +/// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14838,7 +18411,7 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -14880,16 +18453,20 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15037,11 +18614,11 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -15052,14 +18629,14 @@ impl<'a, C, A> UserRolePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().list("profileId") -/// .subaccount_id("Lorem") -/// .sort_order("sea") -/// .sort_field("et") -/// .search_string("duo") -/// .page_token("et") -/// .max_results(-40) -/// .add_ids("sanctus") -/// .account_user_role_only(true) +/// .subaccount_id("justo") +/// .sort_order("sit") +/// .sort_field("vero") +/// .search_string("diam") +/// .page_token("rebum.") +/// .max_results(-45) +/// .add_ids("sadipscing") +/// .account_user_role_only(false) /// .doit(); /// # } /// ``` @@ -15139,7 +18716,7 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRoles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRoles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -15177,16 +18754,20 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15356,6 +18937,252 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Gets one operating system version by ID. +/// +/// A builder for the *get* method supported by a *operatingSystemVersion* resource. +/// It is not used directly, but through a `OperatingSystemVersionMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.operating_system_versions().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemVersionGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for OperatingSystemVersionGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemVersionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, OperatingSystemVersion)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystemVersions.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/operatingSystemVersions/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system version ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperatingSystemVersionGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemVersionGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> OperatingSystemVersionGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of operating system versions. /// /// A builder for the *list* method supported by a *operatingSystemVersion* resource. @@ -15368,11 +19195,11 @@ impl<'a, C, A> UserRoleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -15426,7 +19253,7 @@ impl<'a, C, A> OperatingSystemVersionListCall<'a, C, A> where C: BorrowMut<hyper params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/operatingSystemVersions".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/operatingSystemVersions".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -15464,16 +19291,20 @@ impl<'a, C, A> OperatingSystemVersionListCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15598,11 +19429,11 @@ impl<'a, C, A> OperatingSystemVersionListCall<'a, C, A> where C: BorrowMut<hyper /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -15660,7 +19491,7 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -15698,16 +19529,20 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15852,12 +19687,12 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::LandingPage; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::LandingPage; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -15867,7 +19702,7 @@ impl<'a, C, A> LandingPageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LandingPage = Default::default(); +/// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15919,7 +19754,7 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -15961,16 +19796,20 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16118,11 +19957,11 @@ impl<'a, C, A> LandingPageUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -16178,7 +20017,7 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -16216,16 +20055,20 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16360,12 +20203,12 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::LandingPage; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::LandingPage; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -16375,7 +20218,7 @@ impl<'a, C, A> LandingPageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LandingPage = Default::default(); +/// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16427,7 +20270,7 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -16469,16 +20312,20 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16626,12 +20473,12 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::LandingPage; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::LandingPage; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -16641,7 +20488,7 @@ impl<'a, C, A> LandingPageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LandingPage = Default::default(); +/// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16695,7 +20542,7 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -16737,16 +20584,20 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16904,11 +20755,11 @@ impl<'a, C, A> LandingPagePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -16965,7 +20816,7 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/landingPages/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -17003,16 +20854,20 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -17135,6 +20990,391 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> } +/// Inserts a new creative asset. +/// +/// A builder for the *insert* method supported by a *creativeAsset* resource. +/// It is not used directly, but through a `CreativeAssetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeAssetMetadata; +/// use std::fs; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CreativeAssetMetadata::default(); +/// +/// // 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") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// # } +/// ``` +pub struct CreativeAssetInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: CreativeAssetMetadata, + _profile_id: String, + _advertiser_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeAssetInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creativeAssets.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + for &field in ["alt", "profileId", "advertiserId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + 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() + } else if protocol == "resumable" { + "https://www.googleapis.com/resumable/upload/dfareporting/v2.1/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string() + } else { + unreachable!() + }; + params.push(("uploadType", protocol.to_string())); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{advertiserId}", "advertiserId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "advertiserId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + let mut should_ask_dlg_for_url = false; + let mut upload_url_from_server; + let mut upload_url: Option<String> = None; + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { + should_ask_dlg_for_url = false; + upload_url_from_server = false; + let mut response = hyper::client::Response::new(Box::new(cmn::DummyNetworkStream)); + match response { + Ok(ref mut res) => { + res.status = hyper::status::StatusCode::Ok; + res.headers.set(Location(upload_url.as_ref().unwrap().clone())) + } + _ => unreachable!(), + } + response + } else { + let mut mp_reader: MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + "simple" => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(Error::UploadSizeLimitExceeded(size, 104857600)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + let mime_type = mp_reader.mime_type(); + (&mut mp_reader as &mut io::Read, ContentType(mime_type)) + }, + _ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())), + }; + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(content_type) + .body(&mut body_reader); + upload_url_from_server = true; + if protocol == "resumable" { + req = req.header(cmn::XUploadContentType(reader_mime_type.clone())); + } + + dlg.pre_request(); + req.send() + } + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + if protocol == "resumable" { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(Error::UploadSizeLimitExceeded(size, 104857600)) + } + 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; + if upload_url_from_server { + dlg.store_upload_url(url); + } + + cmn::ResumableUploadHelper { + client: &mut client.borrow_mut(), + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &mut *self.hub.auth.borrow_mut(), + user_agent: &self.hub._user_agent, + auth_header: auth_header.clone(), + url: url, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload() + }; + match upload_result { + None => { + dlg.finished(false); + return Err(Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Some(Ok(upload_result)) => { + res = upload_result; + if !res.status.is_success() { + dlg.finished(false); + return Err(Error::Failure(res)) + } + } + } + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *max size*: 100MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(stream, mime_type, "simple") + } + /// Upload media in a resumable fashion. + /// Even if the upload fails or is interrupted, it can be resumed for a + /// certain amount of time as the server maintains state temporarily. + /// + /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL + /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate + /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using + /// `cancel_chunk_upload(...)`. + /// + /// * *max size*: 100MB + /// * *multipart*: yes + /// * *valid mime types*: '*/*' + pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> + where RS: ReadSeek { + self.doit(resumeable_stream, mime_type, "resumable") + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Advertiser ID of this creative. This is a required field. + /// + /// Sets the *advertiser id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn advertiser_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeAssetInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeAssetInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeAssetInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already. /// /// A builder for the *insert* method supported by a *campaignCreativeAssociation* resource. @@ -17147,12 +21387,12 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CampaignCreativeAssociation; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CampaignCreativeAssociation; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -17162,7 +21402,7 @@ impl<'a, C, A> LandingPageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CampaignCreativeAssociation = Default::default(); +/// let mut req = CampaignCreativeAssociation::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17214,7 +21454,7 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -17256,16 +21496,20 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17413,11 +21657,11 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -17428,9 +21672,9 @@ impl<'a, C, A> CampaignCreativeAssociationInsertCall<'a, C, A> where C: BorrowMu /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaign_creative_associations().list("profileId", "campaignId") -/// .sort_order("consetetur") -/// .page_token("sadipscing") -/// .max_results(-76) +/// .sort_order("aliquyam") +/// .page_token("sit") +/// .max_results(-40) /// .doit(); /// # } /// ``` @@ -17488,7 +21732,7 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -17526,16 +21770,20 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17691,11 +21939,11 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -17706,16 +21954,16 @@ impl<'a, C, A> CampaignCreativeAssociationListCall<'a, C, A> where C: BorrowMut< /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.change_logs().list("profileId") -/// .add_user_profile_ids("invidunt") -/// .search_string("consetetur") -/// .page_token("dolore") -/// .object_type("duo") +/// .add_user_profile_ids("labore") +/// .search_string("sed") +/// .page_token("ea") +/// .object_type("gubergren") /// .add_object_ids("aliquyam") -/// .min_change_time("Lorem") -/// .max_results(-17) -/// .max_change_time("clita") -/// .add_ids("consetetur") -/// .action("takimata") +/// .min_change_time("eos") +/// .max_results(-38) +/// .max_change_time("sea") +/// .add_ids("labore") +/// .action("ipsum") /// .doit(); /// # } /// ``` @@ -17811,7 +22059,7 @@ impl<'a, C, A> ChangeLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/changeLogs".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/changeLogs".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -17849,16 +22097,20 @@ impl<'a, C, A> ChangeLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18056,11 +22308,11 @@ impl<'a, C, A> ChangeLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -18116,7 +22368,7 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/changeLogs/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/changeLogs/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -18154,16 +22406,20 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18286,10 +22542,10 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } -/// Gets one account by ID. +/// Gets one remarketing list share by remarketing list ID. /// -/// A builder for the *get* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. +/// A builder for the *get* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// @@ -18298,11 +22554,11 @@ impl<'a, C, A> ChangeLogGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -18312,28 +22568,28 @@ impl<'a, C, A> ChangeLogGetCall<'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().get("profileId", "id") +/// let result = hub.remarketing_list_shares().get("profileId", "remarketingListId") /// .doit(); /// # } /// ``` -pub struct AccountGetCall<'a, C, A> +pub struct RemarketingListShareGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, _profile_id: String, - _id: String, + _remarketing_list_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for RemarketingListShareGetCall<'a, C, A> {} -impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> RemarketingListShareGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -18341,12 +22597,12 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.accounts.get", + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "id"].iter() { + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -18358,12 +22614,12 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accounts/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingListShares/{remarketingListId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{remarketingListId}", "remarketingListId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -18375,7 +22631,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "id"].iter() { + for param_name in ["profileId", "remarketingListId"].iter() { for (index, &(ref name, _)) in params.iter().rev().enumerate() { if name == param_name { indices_for_removal.push(params.len() - index - 1); @@ -18396,16 +22652,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18462,18 +22722,18 @@ impl<'a, C, A> AccountGetCall<'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 profile_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Account ID. + /// Remarketing list ID. /// - /// Sets the *id* path property to the given value. + /// Sets the *remarketing list id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { - self._id = new_value.to_string(); + pub fn remarketing_list_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, C, A> { + self._remarketing_list_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -18482,7 +22742,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListShareGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -18503,7 +22763,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListShareGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -18520,7 +22780,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AccountGetCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListShareGetCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -18528,10 +22788,10 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } -/// Retrieves the list of accounts, possibly filtered. +/// Updates an existing remarketing list share. This method supports patch semantics. /// -/// A builder for the *list* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. +/// A builder for the *patch* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// @@ -18540,331 +22800,12 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::RemarketingListShare; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().list("profileId") -/// .sort_order("labore") -/// .sort_field("invidunt") -/// .search_string("ea") -/// .page_token("sadipscing") -/// .max_results(-66) -/// .add_ids("dolore") -/// .active(true) -/// .doit(); -/// # } -/// ``` -pub struct AccountListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _sort_order: Option<String>, - _sort_field: Option<String>, - _search_string: Option<String>, - _page_token: Option<String>, - _max_results: Option<i32>, - _ids: Vec<String>, - _active: Option<bool>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for AccountListCall<'a, C, A> {} - -impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, AccountsListResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.accounts.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - if let Some(value) = self._sort_order { - params.push(("sortOrder", value.to_string())); - } - if let Some(value) = self._sort_field { - params.push(("sortField", value.to_string())); - } - if let Some(value) = self._search_string { - params.push(("searchString", value.to_string())); - } - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if self._ids.len() > 0 { - let mut s = String::new(); - for f in self._ids.iter() { - s.push_str(&("/".to_string() + &f.to_string())); - } - params.push(("ids", s)); - } - if let Some(value) = self._active { - params.push(("active", value.to_string())); - } - for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accounts".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Order of sorted results, default is ASCENDING. - /// - /// Sets the *sort order* query property to the given value. - pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._sort_order = Some(new_value.to_string()); - self - } - /// Field by which to sort the list. - /// - /// Sets the *sort field* query property to the given value. - pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._sort_field = Some(new_value.to_string()); - self - } - /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "account*2015" will return objects with names like "account June 2015", "account April 2015", or simply "account 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "account" will match objects with name "my account", "account 2015", or simply "account". - /// - /// Sets the *search string* query property to the given value. - pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._search_string = Some(new_value.to_string()); - self - } - /// Value of the nextPageToken from the previous result page. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of results to return. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Select only accounts with these IDs. - /// - /// Append the given value to the *ids* query property. - /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_ids(mut self, new_value: &str) -> AccountListCall<'a, C, A> { - self._ids.push(new_value.to_string()); - self - } - /// Select only active accounts. Don't set this field to select both active and non-active accounts. - /// - /// Sets the *active* query property to the given value. - pub fn active(mut self, new_value: bool) -> AccountListCall<'a, C, A> { - self._active = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AccountListCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing account. -/// -/// A builder for the *update* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Account; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -18874,33 +22815,34 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = RemarketingListShare::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().update(&req, "profileId") +/// let result = hub.remarketing_list_shares().patch(&req, "profileId", "remarketingListId") /// .doit(); /// # } /// ``` -pub struct AccountUpdateCall<'a, C, A> +pub struct RemarketingListSharePatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, - _request: Account, + _request: RemarketingListShare, _profile_id: String, + _remarketing_list_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for RemarketingListSharePatchCall<'a, C, A> {} -impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> RemarketingListSharePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -18908,267 +22850,12 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.accounts.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "profileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accounts".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AccountUpdateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AccountUpdateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing account. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *account* resource. -/// It is not used directly, but through a `AccountMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Account; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::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, "profileId", "id") -/// .doit(); -/// # } -/// ``` -pub struct AccountPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Account, - _profile_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for AccountPatchCall<'a, C, A> {} - -impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.accounts.patch", + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.patch", http_method: hyper::method::Method::Patch }); let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "id"].iter() { + params.push(("remarketingListId", self._remarketing_list_id.to_string())); + for &field in ["alt", "profileId", "remarketingListId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -19180,7 +22867,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accounts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingListShares".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -19222,16 +22909,20 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19291,7 +22982,7 @@ 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> { + pub fn request(mut self, new_value: &RemarketingListShare) -> RemarketingListSharePatchCall<'a, C, A> { self._request = new_value.clone(); self } @@ -19301,18 +22992,18 @@ 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 profile_id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Account ID. + /// Remarketing list ID. /// - /// Sets the *id* query property to the given value. + /// Sets the *remarketing list id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { - self._id = new_value.to_string(); + pub fn remarketing_list_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, C, A> { + self._remarketing_list_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -19321,7 +23012,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountPatchCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListSharePatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -19342,7 +23033,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AccountPatchCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListSharePatchCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -19359,7 +23050,7 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AccountPatchCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListSharePatchCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -19367,10 +23058,10 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } -/// Retrieves a list of postal codes. +/// Updates an existing remarketing list share. /// -/// A builder for the *list* method supported by a *postalCode* resource. -/// It is not used directly, but through a `PostalCodeMethods` instance. +/// A builder for the *update* method supported by a *remarketingListShare* resource. +/// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// @@ -19379,41 +23070,48 @@ impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::RemarketingListShare; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = RemarketingListShare::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.postal_codes().list("profileId") +/// let result = hub.remarketing_list_shares().update(&req, "profileId") /// .doit(); /// # } /// ``` -pub struct PostalCodeListCall<'a, C, A> +pub struct RemarketingListShareUpdateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, + _request: RemarketingListShare, _profile_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for PostalCodeListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for RemarketingListShareUpdateCall<'a, C, A> {} -impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> RemarketingListShareUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, PostalCodesListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -19421,9 +23119,9 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.postalCodes.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "dfareporting.remarketingListShares.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { @@ -19437,7 +23135,7 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/postalCodes".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingListShares".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -19472,19 +23170,824 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); } + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListShareUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListShareUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListShareUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListShareUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Runs a report. +/// +/// A builder for the *run* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().run("profileId", "reportId") +/// .synchronous(true) +/// .doit(); +/// # } +/// ``` +pub struct ReportRunCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _report_id: String, + _synchronous: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportRunCall<'a, C, A> {} + +impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.run", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._synchronous { + params.push(("synchronous", value.to_string())); + } + for &field in ["alt", "profileId", "reportId", "synchronous"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}/run".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// If set and true, tries to run the report synchronously. + /// + /// Sets the *synchronous* query property to the given value. + pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, C, A> { + self._synchronous = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportRunCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportRunCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportRunCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Report::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.reports().patch(&req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportPatchCall<'a, C, A> {} + +impl<'a, C, A> ReportPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportPatchCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportPatchCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Lists files for a report. +/// +/// A builder for the *files.list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().files_list("profileId", "reportId") +/// .sort_order("invidunt") +/// .sort_field("ut") +/// .page_token("dolores") +/// .max_results(-24) +/// .doit(); +/// # } +/// ``` +pub struct ReportFileListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _report_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportFileListCall<'a, C, A> {} + +impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, FileList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "profileId", "reportId", "sortOrder", "sortField", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}/files".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19535,23 +24038,61 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } - /// User profile ID associated with this request. + /// The DFA profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> PostalCodeListCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { self._profile_id = new_value.to_string(); self } + /// The ID of the parent report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> PostalCodeListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportFileListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -19572,7 +24113,7 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> PostalCodeListCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> ReportFileListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -19581,7 +24122,7 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. + /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -19589,7 +24130,1847 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> PostalCodeListCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> ReportFileListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a report. +/// +/// A builder for the *insert* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Report::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.reports().insert(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportInsertCall<'a, C, A> {} + +impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a report. +/// +/// A builder for the *update* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Report::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.reports().update(&req, "profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Report, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportUpdateCall<'a, C, A> {} + +impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. +/// +/// A builder for the *compatibleFields.query* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Report; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Report::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.reports().compatible_fields_query(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportCompatibleFieldQueryCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Report, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportCompatibleFieldQueryCall<'a, C, A> {} + +impl<'a, C, A> ReportCompatibleFieldQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CompatibleFields)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.compatibleFields.query", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/compatiblefields/query".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportCompatibleFieldQueryCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportCompatibleFieldQueryCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportCompatibleFieldQueryCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report by its ID. +/// +/// A builder for the *get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportGetCall<'a, C, A> {} + +impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["alt", "profileId", "reportId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a report file. +/// +/// This method supports **media download**. To enable it, adjust the builder like this: +/// `.param("alt", "media")`. +/// Please note that due to missing multi-part support on the server side, you will only receive the media, +/// but not the `File` structure that you would usually get. The latter will be a default value. +/// +/// A builder for the *files.get* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().files_get("profileId", "reportId", "fileId") +/// .doit(); +/// # } +/// ``` +pub struct ReportFileGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _report_id: String, + _file_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportFileGetCall<'a, C, A> {} + +impl<'a, C, A> ReportFileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, File)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.files.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + params.push(("fileId", self._file_id.to_string())); + for &field in ["profileId", "reportId", "fileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + let (json_field_missing, enable_resource_parsing) = { + let mut enable = true; + let mut field_present = true; + for &(name, ref value) in params.iter() { + if name == "alt" { + field_present = false; + if <String as AsRef<str>>::as_ref(&value) != "json" { + enable = false; + } + break; + } + } + (field_present, enable) + }; + if json_field_missing { + params.push(("alt", "json".to_string())); + } + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}/files/{fileId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId"), ("{fileId}", "fileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["profileId", "reportId", "fileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = if enable_resource_parsing { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + } else { (res, Default::default()) }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The DFA profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The ID of the report file. + /// + /// Sets the *file id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn file_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { + self._file_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportFileGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportFileGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportFileGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a report by its ID. +/// +/// A builder for the *delete* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().delete("profileId", "reportId") +/// .doit(); +/// # } +/// ``` +pub struct ReportDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _report_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportDeleteCall<'a, C, A> {} + +impl<'a, C, A> ReportDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("reportId", self._report_id.to_string())); + for &field in ["profileId", "reportId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports/{reportId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "reportId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The ID of the report. + /// + /// Sets the *report id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn report_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { + self._report_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportDeleteCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportDeleteCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves list of reports. +/// +/// A builder for the *list* method supported by a *report* resource. +/// It is not used directly, but through a `ReportMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("profileId") +/// .sort_order("Lorem") +/// .sort_field("clita") +/// .scope("invidunt") +/// .page_token("eirmod") +/// .max_results(-77) +/// .doit(); +/// # } +/// ``` +pub struct ReportListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _scope: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReportListCall<'a, C, A> {} + +impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ReportList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.reports.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._scope { + params.push(("scope", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/reports".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The DFA user profile ID. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is 'DESCENDING'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// The field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// The scope that defines which results are returned, default is 'MINE'. + /// + /// Sets the *scope* query property to the given value. + pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._scope = Some(new_value.to_string()); + self + } + /// The value of the nextToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ReportListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReportListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReportListCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -19609,12 +25990,12 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Advertiser; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Advertiser; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -19624,7 +26005,7 @@ impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Advertiser = Default::default(); +/// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19674,7 +26055,7 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertisers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertisers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -19716,16 +26097,20 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19863,12 +26248,12 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Advertiser; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Advertiser; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -19878,7 +26263,7 @@ impl<'a, C, A> AdvertiserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Advertiser = Default::default(); +/// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19930,7 +26315,7 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertisers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertisers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -19972,16 +26357,20 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20129,11 +26518,11 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -20144,17 +26533,17 @@ impl<'a, C, A> AdvertiserPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().list("profileId") -/// .subaccount_id("gubergren") -/// .status("aliquyam") -/// .sort_order("eos") -/// .sort_field("tempor") -/// .search_string("sea") -/// .page_token("labore") -/// .only_parent(false) -/// .max_results(-31) -/// .include_advertisers_without_groups_only(false) -/// .add_ids("sit") -/// .add_floodlight_configuration_ids("diam") +/// .subaccount_id("takimata") +/// .status("elitr") +/// .sort_order("nonumy") +/// .sort_field("rebum.") +/// .search_string("Lorem") +/// .page_token("Lorem") +/// .only_parent(true) +/// .max_results(-36) +/// .include_advertisers_without_groups_only(true) +/// .add_ids("amet.") +/// .add_floodlight_configuration_ids("ipsum") /// .add_advertiser_group_ids("ut") /// .doit(); /// # } @@ -20259,7 +26648,7 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertisers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertisers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -20297,16 +26686,20 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -20518,12 +26911,12 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Advertiser; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Advertiser; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -20533,7 +26926,7 @@ impl<'a, C, A> AdvertiserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Advertiser = Default::default(); +/// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -20583,7 +26976,7 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertisers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertisers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -20625,16 +27018,20 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20772,11 +27169,11 @@ impl<'a, C, A> AdvertiserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -20832,7 +27229,7 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertisers/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertisers/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -20870,16 +27267,20 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21014,12 +27415,12 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::DimensionValueRequest; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::DimensionValueRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -21029,14 +27430,14 @@ impl<'a, C, A> AdvertiserGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DimensionValueRequest = Default::default(); +/// let mut req = DimensionValueRequest::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.dimension_values().query(&req, "profileId") -/// .page_token("clita") -/// .max_results(-79) +/// .page_token("sanctus") +/// .max_results(-27) /// .doit(); /// # } /// ``` @@ -21089,7 +27490,7 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/dimensionvalues/query".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/dimensionvalues/query".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -21131,16 +27532,20 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21292,11 +27697,11 @@ impl<'a, C, A> DimensionValueQueryCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -21351,7 +27756,7 @@ impl<'a, C, A> FloodlightActivityGroupDeleteCall<'a, C, A> where C: BorrowMut<hy } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -21389,16 +27794,20 @@ impl<'a, C, A> FloodlightActivityGroupDeleteCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -21523,11 +27932,11 @@ impl<'a, C, A> FloodlightActivityGroupDeleteCall<'a, C, A> where C: BorrowMut<hy /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -21583,7 +27992,7 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -21621,16 +28030,20 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21765,12 +28178,12 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivityGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivityGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -21780,7 +28193,7 @@ impl<'a, C, A> FloodlightActivityGroupGetCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivityGroup = Default::default(); +/// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -21832,7 +28245,7 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -21874,16 +28287,20 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22031,11 +28448,11 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -22046,15 +28463,15 @@ impl<'a, C, A> FloodlightActivityGroupPatchCall<'a, C, A> where C: BorrowMut<hyp /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().list("profileId") -/// .type_("voluptua.") -/// .sort_order("duo") -/// .sort_field("sed") -/// .search_string("aliquyam") -/// .page_token("ea") -/// .max_results(-17) +/// .type_("ipsum") +/// .sort_order("justo") +/// .sort_field("dolore") +/// .search_string("vero") +/// .page_token("dolor") +/// .max_results(-58) /// .add_ids("et") -/// .floodlight_configuration_id("dolor") -/// .advertiser_id("diam") +/// .floodlight_configuration_id("nonumy") +/// .advertiser_id("et") /// .doit(); /// # } /// ``` @@ -22138,7 +28555,7 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -22176,16 +28593,20 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22374,12 +28795,12 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivityGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivityGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -22389,7 +28810,7 @@ impl<'a, C, A> FloodlightActivityGroupListCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivityGroup = Default::default(); +/// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -22439,7 +28860,7 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -22481,16 +28902,20 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22628,12 +29053,12 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivityGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivityGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -22643,7 +29068,7 @@ impl<'a, C, A> FloodlightActivityGroupInsertCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivityGroup = Default::default(); +/// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -22693,7 +29118,7 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivityGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivityGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -22735,16 +29160,20 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -22882,11 +29311,11 @@ impl<'a, C, A> FloodlightActivityGroupUpdateCall<'a, C, A> where C: BorrowMut<hy /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -22940,7 +29369,7 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/metros".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/metros".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -22978,16 +29407,20 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23100,6 +29533,604 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau } +/// Retrieves a list of orders, possibly filtered. +/// +/// A builder for the *list* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.orders().list("profileId", "projectId") +/// .sort_order("aliquyam") +/// .sort_field("elitr") +/// .add_site_id("consetetur") +/// .search_string("sea") +/// .page_token("elitr") +/// .max_results(-77) +/// .add_ids("sea") +/// .doit(); +/// # } +/// ``` +pub struct OrderListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _project_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _site_id: Vec<String>, + _search_string: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _ids: Vec<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for OrderListCall<'a, C, A> {} + +impl<'a, C, A> OrderListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, OrdersListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + let mut s = String::new(); + for f in self._site_id.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("siteId", s)); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + let mut s = String::new(); + for f in self._ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("ids", s)); + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "maxResults", "ids"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/orders".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "projectId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// Sets the *project id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn project_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only orders that are associated with these site IDs. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for orders by name or ID. Wildcards (*) are allowed. For example, "order*2015" will return orders with names like "order June 2015", "order April 2015", or simply "order 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "order" will match orders with name "my order", "order 2015", or simply "order". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> OrderListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only orders with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> OrderListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrderListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> OrderListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> OrderListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one order by ID. +/// +/// A builder for the *get* method supported by a *order* resource. +/// It is not used directly, but through a `OrderMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.orders().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct OrderGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for OrderGetCall<'a, C, A> {} + +impl<'a, C, A> OrderGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Order)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.orders.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/orders/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["profileId", "projectId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for orders. + /// + /// Sets the *project id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn project_id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> OrderGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrderGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> OrderGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> OrderGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Gets one directory site contact by ID. /// /// A builder for the *get* method supported by a *directorySiteContact* resource. @@ -23112,11 +30143,11 @@ impl<'a, C, A> MetroListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -23172,7 +30203,7 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/directorySiteContacts/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/directorySiteContacts/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -23210,16 +30241,20 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23354,11 +30389,11 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -23369,13 +30404,13 @@ impl<'a, C, A> DirectorySiteContactGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_site_contacts().list("profileId") -/// .sort_order("eirmod") -/// .sort_field("At") -/// .search_string("consetetur") +/// .sort_order("aliquyam") +/// .sort_field("elitr") +/// .search_string("ea") /// .page_token("et") -/// .max_results(-80) -/// .add_ids("sit") -/// .add_directory_site_ids("takimata") +/// .max_results(-65) +/// .add_ids("sed") +/// .add_directory_site_ids("dolor") /// .doit(); /// # } /// ``` @@ -23455,7 +30490,7 @@ impl<'a, C, A> DirectorySiteContactListCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/directorySiteContacts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/directorySiteContacts".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -23493,16 +30528,20 @@ impl<'a, C, A> DirectorySiteContactListCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23678,11 +30717,11 @@ impl<'a, C, A> DirectorySiteContactListCall<'a, C, A> where C: BorrowMut<hyper:: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -23734,7 +30773,7 @@ impl<'a, C, A> UserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -23748,16 +30787,20 @@ impl<'a, C, A> UserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23872,11 +30915,11 @@ impl<'a, C, A> UserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -23930,7 +30973,7 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -23968,16 +31011,20 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -24102,12 +31149,12 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Ad; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Ad; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -24117,7 +31164,7 @@ impl<'a, C, A> UserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Ad = Default::default(); +/// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -24169,7 +31216,7 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/ads".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/ads".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -24211,16 +31258,20 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -24368,12 +31419,12 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Ad; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Ad; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -24383,7 +31434,7 @@ impl<'a, C, A> AdPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Ad = Default::default(); +/// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -24433,7 +31484,7 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/ads".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/ads".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -24475,16 +31526,20 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -24622,11 +31677,11 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -24637,30 +31692,30 @@ impl<'a, C, A> AdInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().list("profileId") -/// .add_type("diam") +/// .add_type("eirmod") /// .ssl_required(true) -/// .ssl_compliant(true) -/// .sort_order("amet.") -/// .sort_field("ipsum") -/// .add_size_ids("ut") -/// .search_string("dolor") -/// .add_remarketing_list_ids("sea") -/// .add_placement_ids("ut") -/// .page_token("eirmod") -/// .overridden_event_tag_id("sanctus") -/// .max_results(-27) -/// .add_landing_page_ids("dolor") -/// .add_ids("et") +/// .ssl_compliant(false) +/// .sort_order("et") +/// .sort_field("sadipscing") +/// .add_size_ids("accusam") +/// .search_string("magna") +/// .add_remarketing_list_ids("Lorem") +/// .add_placement_ids("rebum.") +/// .page_token("et") +/// .overridden_event_tag_id("clita") +/// .max_results(-24) +/// .add_landing_page_ids("dolores") +/// .add_ids("vero") /// .dynamic_click_tracker(false) /// .creative_type("vero") -/// .add_creative_optimization_configuration_ids("ut") -/// .add_creative_ids("sed") -/// .compatibility("et") -/// .add_campaign_ids("ipsum") -/// .add_audience_segment_ids("justo") -/// .archived(true) -/// .advertiser_id("vero") -/// .active(false) +/// .add_creative_optimization_configuration_ids("consetetur") +/// .add_creative_ids("eos") +/// .compatibility("justo") +/// .add_campaign_ids("tempor") +/// .add_audience_segment_ids("gubergren") +/// .archived(false) +/// .advertiser_id("amet.") +/// .active(true) /// .doit(); /// # } /// ``` @@ -24840,7 +31895,7 @@ impl<'a, C, A> AdListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/ads".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/ads".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -24878,16 +31933,20 @@ impl<'a, C, A> AdListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25190,11 +32249,11 @@ impl<'a, C, A> AdListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -25250,7 +32309,7 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/ads/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/ads/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -25288,16 +32347,20 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25432,12 +32495,12 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Ad; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Ad; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -25447,7 +32510,7 @@ impl<'a, C, A> AdGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Ad = Default::default(); +/// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -25497,7 +32560,7 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/ads".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/ads".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -25539,16 +32602,20 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -25686,11 +32753,11 @@ impl<'a, C, A> AdUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -25746,7 +32813,7 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountPermissions/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountPermissions/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -25784,16 +32851,20 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -25928,11 +32999,11 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -25986,7 +33057,7 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountPermissions".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountPermissions".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -26024,16 +33095,20 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26158,11 +33233,11 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -26216,7 +33291,7 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/connectionTypes".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/connectionTypes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -26254,16 +33329,20 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26376,6 +33455,252 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client } +/// Gets one connection type by ID. +/// +/// A builder for the *get* method supported by a *connectionType* resource. +/// It is not used directly, but through a `ConnectionTypeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.connection_types().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ConnectionTypeGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ConnectionTypeGetCall<'a, C, A> {} + +impl<'a, C, A> ConnectionTypeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ConnectionType)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.connectionTypes.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/connectionTypes/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Connection type ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConnectionTypeGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ConnectionTypeGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ConnectionTypeGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Gets one advertiser group by ID. /// /// A builder for the *get* method supported by a *advertiserGroup* resource. @@ -26388,11 +33713,11 @@ impl<'a, C, A> ConnectionTypeListCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -26448,7 +33773,7 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -26486,16 +33811,20 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26630,11 +33959,11 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -26645,12 +33974,12 @@ impl<'a, C, A> AdvertiserGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().list("profileId") -/// .sort_order("elitr") -/// .sort_field("consetetur") -/// .search_string("sea") -/// .page_token("elitr") -/// .max_results(-77) -/// .add_ids("sea") +/// .sort_order("dolor") +/// .sort_field("Lorem") +/// .search_string("dolor") +/// .page_token("vero") +/// .max_results(-91) +/// .add_ids("takimata") /// .doit(); /// # } /// ``` @@ -26722,7 +34051,7 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -26760,16 +34089,20 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -26937,12 +34270,12 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::AdvertiserGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AdvertiserGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -26952,7 +34285,7 @@ impl<'a, C, A> AdvertiserGroupListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AdvertiserGroup = Default::default(); +/// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -27002,7 +34335,7 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -27044,16 +34377,20 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -27191,12 +34528,12 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::AdvertiserGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AdvertiserGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -27206,7 +34543,7 @@ impl<'a, C, A> AdvertiserGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AdvertiserGroup = Default::default(); +/// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -27256,7 +34593,7 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -27298,16 +34635,20 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -27445,12 +34786,12 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::AdvertiserGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AdvertiserGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -27460,7 +34801,7 @@ impl<'a, C, A> AdvertiserGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AdvertiserGroup = Default::default(); +/// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -27512,7 +34853,7 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -27554,16 +34895,20 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -27711,11 +35056,11 @@ impl<'a, C, A> AdvertiserGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -27770,7 +35115,7 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/advertiserGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -27808,16 +35153,20 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -27942,12 +35291,12 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Site; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Site; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -27957,7 +35306,7 @@ impl<'a, C, A> AdvertiserGroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Site = Default::default(); +/// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -28007,7 +35356,7 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sites".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sites".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -28049,16 +35398,20 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -28196,11 +35549,11 @@ impl<'a, C, A> SiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -28256,7 +35609,7 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sites/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sites/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -28294,16 +35647,20 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -28438,11 +35795,11 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -28454,19 +35811,19 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().list("profileId") /// .unmapped_site(false) -/// .subaccount_id("sed") -/// .sort_order("dolor") -/// .sort_field("sanctus") -/// .search_string("dolore") -/// .page_token("Lorem") -/// .max_results(-96) -/// .add_ids("consetetur") -/// .add_directory_site_ids("eirmod") -/// .add_campaign_ids("labore") -/// .approved(false) +/// .subaccount_id("sit") +/// .sort_order("aliquyam") +/// .sort_field("sadipscing") +/// .search_string("magna") +/// .page_token("gubergren") +/// .max_results(-98) +/// .add_ids("gubergren") +/// .add_directory_site_ids("sit") +/// .add_campaign_ids("amet") +/// .approved(true) /// .ad_words_site(false) -/// .accepts_publisher_paid_placements(true) -/// .accepts_interstitial_placements(false) +/// .accepts_publisher_paid_placements(false) +/// .accepts_interstitial_placements(true) /// .accepts_in_stream_video_placements(true) /// .doit(); /// # } @@ -28583,7 +35940,7 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sites".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sites".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -28621,16 +35978,20 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -28863,12 +36224,12 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Site; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Site; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -28878,7 +36239,7 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Site = Default::default(); +/// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -28928,7 +36289,7 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sites".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sites".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -28970,16 +36331,20 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -29117,12 +36482,12 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Site; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Site; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -29132,7 +36497,7 @@ impl<'a, C, A> SiteUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Site = Default::default(); +/// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -29184,7 +36549,7 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sites".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sites".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -29226,16 +36591,20 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -29383,11 +36752,11 @@ impl<'a, C, A> SitePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -29443,7 +36812,7 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -29481,16 +36850,20 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -29625,11 +36998,11 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -29640,19 +37013,19 @@ impl<'a, C, A> FloodlightActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().list("profileId") -/// .tag_string("vero") -/// .sort_order("consetetur") -/// .sort_field("vero") -/// .search_string("consetetur") -/// .page_token("eos") -/// .max_results(-21) -/// .add_ids("tempor") -/// .floodlight_configuration_id("gubergren") -/// .floodlight_activity_group_type("dolore") -/// .floodlight_activity_group_tag_string("amet.") -/// .floodlight_activity_group_name("dolore") -/// .add_floodlight_activity_group_ids("magna") -/// .advertiser_id("elitr") +/// .tag_string("et") +/// .sort_order("At") +/// .sort_field("sit") +/// .search_string("ut") +/// .page_token("diam") +/// .max_results(-39) +/// .add_ids("et") +/// .floodlight_configuration_id("erat") +/// .floodlight_activity_group_type("dolores") +/// .floodlight_activity_group_tag_string("kasd") +/// .floodlight_activity_group_name("et") +/// .add_floodlight_activity_group_ids("clita") +/// .advertiser_id("sed") /// .doit(); /// # } /// ``` @@ -29756,7 +37129,7 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -29794,16 +37167,20 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -30021,12 +37398,12 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivity; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivity; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -30036,7 +37413,7 @@ impl<'a, C, A> FloodlightActivityListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivity = Default::default(); +/// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -30086,7 +37463,7 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -30128,16 +37505,20 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -30275,11 +37656,11 @@ impl<'a, C, A> FloodlightActivityInsertCall<'a, C, A> where C: BorrowMut<hyper:: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -30334,7 +37715,7 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -30372,16 +37753,20 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -30506,12 +37891,12 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivity; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivity; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -30521,7 +37906,7 @@ impl<'a, C, A> FloodlightActivityDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivity = Default::default(); +/// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -30573,7 +37958,7 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -30615,16 +38000,20 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -30772,11 +38161,11 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -30787,7 +38176,7 @@ impl<'a, C, A> FloodlightActivityPatchCall<'a, C, A> where C: BorrowMut<hyper::C /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().generatetag("profileId") -/// .floodlight_activity_id("nonumy") +/// .floodlight_activity_id("sit") /// .doit(); /// # } /// ``` @@ -30835,7 +38224,7 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities/generatetag".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities/generatetag".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -30873,16 +38262,20 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -31014,12 +38407,12 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightActivity; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightActivity; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -31029,7 +38422,7 @@ impl<'a, C, A> FloodlightActivityGeneratetagCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightActivity = Default::default(); +/// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -31079,7 +38472,7 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightActivities".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightActivities".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -31121,16 +38514,20 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -31268,11 +38665,11 @@ impl<'a, C, A> FloodlightActivityUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -31326,7 +38723,7 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/regions".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/regions".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -31364,16 +38761,20 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -31498,12 +38899,12 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -31513,7 +38914,7 @@ impl<'a, C, A> RegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeGroup = Default::default(); +/// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -31563,7 +38964,7 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -31605,16 +39006,20 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -31752,11 +39157,11 @@ impl<'a, C, A> CreativeGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -31812,7 +39217,7 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -31850,16 +39255,20 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -31994,12 +39403,12 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -32009,7 +39418,7 @@ impl<'a, C, A> CreativeGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeGroup = Default::default(); +/// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -32059,7 +39468,7 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -32101,16 +39510,20 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -32248,11 +39661,11 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -32263,14 +39676,14 @@ impl<'a, C, A> CreativeGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().list("profileId") -/// .sort_order("nonumy") -/// .sort_field("takimata") -/// .search_string("dolores") -/// .page_token("consetetur") -/// .max_results(-30) -/// .add_ids("amet.") -/// .group_number(-18) -/// .add_advertiser_ids("dolores") +/// .sort_order("Lorem") +/// .sort_field("voluptua.") +/// .search_string("rebum.") +/// .page_token("justo") +/// .max_results(-35) +/// .add_ids("voluptua.") +/// .group_number(-59) +/// .add_advertiser_ids("dolor") /// .doit(); /// # } /// ``` @@ -32354,7 +39767,7 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -32392,16 +39805,20 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -32584,12 +40001,12 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::CreativeGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -32599,7 +40016,7 @@ impl<'a, C, A> CreativeGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeGroup = Default::default(); +/// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -32651,7 +40068,7 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creativeGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -32693,16 +40110,20 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -32838,6 +40259,570 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client } +/// Retrieves a list of targetable remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.targetable_remarketing_lists().list("profileId", "advertiserId") +/// .sort_order("magna") +/// .sort_field("et") +/// .page_token("sed") +/// .name("est") +/// .max_results(-48) +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _page_token: Option<String>, + _name: Option<String>, + _max_results: Option<i32>, + _active: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, TargetableRemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "active"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/targetableRemarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only targetable remarketing lists targetable by these advertisers. + /// + /// Sets the *advertiser id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn advertiser_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> TargetableRemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only active or only inactive targetable remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> TargetableRemarketingListListCall<'a, C, A> { + self._active = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetableRemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> TargetableRemarketingListListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> TargetableRemarketingListListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *targetableRemarketingList* resource. +/// It is not used directly, but through a `TargetableRemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.targetable_remarketing_lists().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct TargetableRemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for TargetableRemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> TargetableRemarketingListGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, TargetableRemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.targetableRemarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/targetableRemarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> TargetableRemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> TargetableRemarketingListGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> TargetableRemarketingListGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an existing subaccount. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *subaccount* resource. @@ -32850,12 +40835,12 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Subaccount; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Subaccount; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -32865,7 +40850,7 @@ impl<'a, C, A> CreativeGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subaccount = Default::default(); +/// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -32917,7 +40902,7 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/subaccounts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/subaccounts".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -32959,16 +40944,20 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -33116,12 +41105,12 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Subaccount; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Subaccount; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -33131,7 +41120,7 @@ impl<'a, C, A> SubaccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subaccount = Default::default(); +/// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -33181,7 +41170,7 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/subaccounts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/subaccounts".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -33223,16 +41212,20 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -33370,11 +41363,11 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -33385,12 +41378,12 @@ impl<'a, C, A> SubaccountInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().list("profileId") -/// .sort_order("aliquyam") -/// .sort_field("sadipscing") -/// .search_string("magna") -/// .page_token("gubergren") -/// .max_results(-98) -/// .add_ids("gubergren") +/// .sort_order("sea") +/// .sort_field("vero") +/// .search_string("dolores") +/// .page_token("magna") +/// .max_results(-37) +/// .add_ids("amet") /// .doit(); /// # } /// ``` @@ -33462,7 +41455,7 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/subaccounts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/subaccounts".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -33500,16 +41493,20 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -33677,12 +41674,12 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Subaccount; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Subaccount; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -33692,7 +41689,7 @@ impl<'a, C, A> SubaccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subaccount = Default::default(); +/// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -33742,7 +41739,7 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/subaccounts".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/subaccounts".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -33784,16 +41781,20 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -33931,11 +41932,11 @@ impl<'a, C, A> SubaccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -33991,7 +41992,7 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/subaccounts/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/subaccounts/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -34029,16 +42030,20 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34161,6 +42166,252 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Gets one mobile carrier by ID. +/// +/// A builder for the *get* method supported by a *mobileCarrier* resource. +/// It is not used directly, but through a `MobileCarrierMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.mobile_carriers().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct MobileCarrierGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for MobileCarrierGetCall<'a, C, A> {} + +impl<'a, C, A> MobileCarrierGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, MobileCarrier)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.mobileCarriers.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/mobileCarriers/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Mobile carrier ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> MobileCarrierGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> MobileCarrierGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> MobileCarrierGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of mobile carriers. /// /// A builder for the *list* method supported by a *mobileCarrier* resource. @@ -34173,11 +42424,11 @@ impl<'a, C, A> SubaccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -34231,7 +42482,7 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/mobileCarriers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/mobileCarriers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -34269,16 +42520,20 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -34391,6 +42646,252 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> } +/// Gets one floodlight configuration by ID. +/// +/// A builder for the *get* method supported by a *floodlightConfiguration* resource. +/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct FloodlightConfigurationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for FloodlightConfigurationGetCall<'a, C, A> {} + +impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, FloodlightConfiguration)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightConfigurations/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Floodlight configuration ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> FloodlightConfigurationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> FloodlightConfigurationGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an existing floodlight configuration. /// /// A builder for the *update* method supported by a *floodlightConfiguration* resource. @@ -34403,12 +42904,12 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightConfiguration; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightConfiguration; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -34418,7 +42919,7 @@ impl<'a, C, A> MobileCarrierListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightConfiguration = Default::default(); +/// let mut req = FloodlightConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -34468,7 +42969,7 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightConfigurations".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightConfigurations".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -34510,16 +43011,20 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -34657,12 +43162,12 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::FloodlightConfiguration; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::FloodlightConfiguration; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -34672,7 +43177,7 @@ impl<'a, C, A> FloodlightConfigurationUpdateCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FloodlightConfiguration = Default::default(); +/// let mut req = FloodlightConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -34724,7 +43229,7 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightConfigurations".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightConfigurations".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -34766,16 +43271,20 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -34911,248 +43420,6 @@ impl<'a, C, A> FloodlightConfigurationPatchCall<'a, C, A> where C: BorrowMut<hyp } -/// Gets one floodlight configuration by ID. -/// -/// A builder for the *get* method supported by a *floodlightConfiguration* resource. -/// It is not used directly, but through a `FloodlightConfigurationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("profileId", "id") -/// .doit(); -/// # } -/// ``` -pub struct FloodlightConfigurationGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for FloodlightConfigurationGetCall<'a, C, A> {} - -impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, FloodlightConfiguration)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.floodlightConfigurations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "id"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightConfigurations/{id}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "id"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Floodlight configuration ID. - /// - /// Sets the *id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> FloodlightConfigurationGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> FloodlightConfigurationGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Retrieves a list of floodlight configurations, possibly filtered. /// /// A builder for the *list* method supported by a *floodlightConfiguration* resource. @@ -35165,11 +43432,11 @@ impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -35180,7 +43447,7 @@ impl<'a, C, A> FloodlightConfigurationGetCall<'a, C, A> where C: BorrowMut<hyper /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_configurations().list("profileId") -/// .add_ids("sed") +/// .add_ids("ipsum") /// .doit(); /// # } /// ``` @@ -35232,7 +43499,7 @@ impl<'a, C, A> FloodlightConfigurationListCall<'a, C, A> where C: BorrowMut<hype params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/floodlightConfigurations".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/floodlightConfigurations".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -35270,16 +43537,20 @@ impl<'a, C, A> FloodlightConfigurationListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35412,11 +43683,11 @@ impl<'a, C, A> FloodlightConfigurationListCall<'a, C, A> where C: BorrowMut<hype /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -35470,7 +43741,7 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/operatingSystems".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/operatingSystems".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -35508,16 +43779,20 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35630,6 +43905,252 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien } +/// Gets one operating system by DART ID. +/// +/// A builder for the *get* method supported by a *operatingSystem* resource. +/// It is not used directly, but through a `OperatingSystemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.operating_systems().get("profileId", "dartId") +/// .doit(); +/// # } +/// ``` +pub struct OperatingSystemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _dart_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for OperatingSystemGetCall<'a, C, A> {} + +impl<'a, C, A> OperatingSystemGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, OperatingSystem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.operatingSystems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("dartId", self._dart_id.to_string())); + for &field in ["alt", "profileId", "dartId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/operatingSystems/{dartId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "dartId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Operating system DART ID. + /// + /// Sets the *dart id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn dart_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, C, A> { + self._dart_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperatingSystemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> OperatingSystemGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists files for a user profile. /// /// A builder for the *list* method supported by a *file* resource. @@ -35642,11 +44163,11 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -35657,11 +44178,11 @@ impl<'a, C, A> OperatingSystemListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().list("profileId") -/// .sort_order("et") -/// .sort_field("At") -/// .scope("sit") -/// .page_token("ut") -/// .max_results(-78) +/// .sort_order("kasd") +/// .sort_field("duo") +/// .scope("et") +/// .page_token("sit") +/// .max_results(-40) /// .doit(); /// # } /// ``` @@ -35725,7 +44246,7 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/files".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/files".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -35763,16 +44284,20 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -35937,11 +44462,11 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -36013,7 +44538,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth params.push(("alt", "json".to_string())); } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/reports/{reportId}/files/{fileId}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/reports/{reportId}/files/{fileId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } @@ -36051,16 +44576,20 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -36195,11 +44724,11 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -36210,21 +44739,21 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().list("profileId") -/// .sort_order("dolores") -/// .sort_field("kasd") -/// .add_site_ids("et") -/// .search_string("clita") -/// .add_pricing_types("sed") -/// .add_placement_strategy_ids("dolores") -/// .placement_group_type("clita") -/// .page_token("eos") -/// .max_results(-47) -/// .add_ids("sed") -/// .add_directory_site_ids("takimata") -/// .add_content_category_ids("sit") -/// .add_campaign_ids("labore") -/// .archived(false) -/// .add_advertiser_ids("erat") +/// .sort_order("tempor") +/// .sort_field("clita") +/// .add_site_ids("kasd") +/// .search_string("elitr") +/// .add_pricing_types("et") +/// .add_placement_strategy_ids("vero") +/// .placement_group_type("sadipscing") +/// .page_token("sed") +/// .max_results(-76) +/// .add_ids("nonumy") +/// .add_directory_site_ids("magna") +/// .add_content_category_ids("ea") +/// .add_campaign_ids("sea") +/// .archived(true) +/// .add_advertiser_ids("labore") /// .doit(); /// # } /// ``` @@ -36360,7 +44889,7 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -36398,16 +44927,20 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -36645,12 +45178,12 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -36660,7 +45193,7 @@ impl<'a, C, A> PlacementGroupListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementGroup = Default::default(); +/// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -36710,7 +45243,7 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -36752,16 +45285,20 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -36899,12 +45436,12 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -36914,7 +45451,7 @@ impl<'a, C, A> PlacementGroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementGroup = Default::default(); +/// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -36964,7 +45501,7 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -37006,16 +45543,20 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -37153,11 +45694,11 @@ impl<'a, C, A> PlacementGroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -37213,7 +45754,7 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -37251,16 +45792,20 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -37395,12 +45940,12 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementGroup; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementGroup; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -37410,7 +45955,7 @@ impl<'a, C, A> PlacementGroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementGroup = Default::default(); +/// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -37462,7 +46007,7 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -37504,16 +46049,20 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -37649,10 +46198,10 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien } -/// Inserts a new creative asset. +/// Retrieves a list of inventory items, possibly filtered. /// -/// A builder for the *insert* method supported by a *creativeAsset* resource. -/// It is not used directly, but through a `CreativeAssetMethods` instance. +/// A builder for the *list* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. /// /// # Example /// @@ -37661,51 +46210,58 @@ impl<'a, C, A> PlacementGroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeAssetMetadata; -/// use std::fs; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeAssetMetadata = Default::default(); -/// /// // You can configure optional parameters by calling the respective setters at will, and -/// // execute the final call using `upload_resumable(...)`. +/// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! -/// let result = hub.creative_assets().insert(&req, "profileId", "advertiserId") -/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); +/// let result = hub.inventory_items().list("profileId", "projectId") +/// .sort_order("kasd") +/// .sort_field("ipsum") +/// .add_site_id("eos") +/// .page_token("nonumy") +/// .add_order_id("sanctus") +/// .max_results(-78) +/// .in_plan(false) +/// .add_ids("erat") +/// .doit(); /// # } /// ``` -pub struct CreativeAssetInsertCall<'a, C, A> +pub struct InventoryItemListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, - _request: CreativeAssetMetadata, _profile_id: String, - _advertiser_id: String, + _project_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _site_id: Vec<String>, + _page_token: Option<String>, + _order_id: Vec<String>, + _max_results: Option<i32>, + _in_plan: Option<bool>, + _ids: Vec<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for CreativeAssetInsertCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for InventoryItemListCall<'a, C, A> {} -impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> InventoryItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, CreativeAssetMetadata)> - where RS: ReadSeek { + pub fn doit(mut self) -> Result<(hyper::client::Response, InventoryItemsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -37713,12 +46269,48 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.creativeAssets.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("advertiserId", self._advertiser_id.to_string())); - for &field in ["alt", "profileId", "advertiserId"].iter() { + params.push(("projectId", self._project_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if self._site_id.len() > 0 { + let mut s = String::new(); + for f in self._site_id.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("siteId", s)); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if self._order_id.len() > 0 { + let mut s = String::new(); + for f in self._order_id.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("orderId", s)); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._in_plan { + params.push(("inPlan", value.to_string())); + } + if self._ids.len() > 0 { + let mut s = String::new(); + for f in self._ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("ids", s)); + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "pageToken", "orderId", "maxResults", "inPlan", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -37730,19 +46322,12 @@ 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.0/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string() - } else if protocol == "resumable" { - "https://www.googleapis.com/resumable/upload/dfareporting/v2.0/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets".to_string() - } else { - unreachable!() - }; - params.push(("uploadType", protocol.to_string())); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/inventoryItems".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{advertiserId}", "advertiserId")].iter() { + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -37754,7 +46339,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "advertiserId"].iter() { + for param_name in ["profileId", "projectId"].iter() { for (index, &(ref name, _)) in params.iter().rev().enumerate() { if name == param_name { indices_for_removal.push(params.len() - index - 1); @@ -37772,72 +46357,32 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); } - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut should_ask_dlg_for_url = false; - let mut upload_url_from_server; - let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { - should_ask_dlg_for_url = false; - upload_url_from_server = false; - let mut response = hyper::client::Response::new(Box::new(cmn::DummyNetworkStream)); - match response { - Ok(ref mut res) => { - res.status = hyper::status::StatusCode::Ok; - res.headers.set(Location(upload_url.as_ref().unwrap().clone())) + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) } - _ => unreachable!(), } - response - } else { - let mut mp_reader: MultiPartReader = Default::default(); - let (mut body_reader, content_type) = match protocol { - "simple" => { - mp_reader.reserve_exact(2); - let size = reader.seek(io::SeekFrom::End(0)).unwrap(); - reader.seek(io::SeekFrom::Start(0)).unwrap(); - if size > 104857600 { - return Err(Error::UploadSizeLimitExceeded(size, 104857600)) - } - mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) - .add_part(&mut reader, size, reader_mime_type.clone()); - let mime_type = mp_reader.mime_type(); - (&mut mp_reader as &mut io::Read, ContentType(mime_type)) - }, - _ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())), - }; - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(content_type) - .body(&mut body_reader); - upload_url_from_server = true; - if protocol == "resumable" { - req = req.header(cmn::XUploadContentType(reader_mime_type.clone())); - } - - dlg.pre_request(); - req.send() } }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; match req_result { Err(err) => { @@ -37859,50 +46404,6 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien dlg.finished(false); return Err(Error::Failure(res)) } - if protocol == "resumable" { - let size = reader.seek(io::SeekFrom::End(0)).unwrap(); - reader.seek(io::SeekFrom::Start(0)).unwrap(); - if size > 104857600 { - return Err(Error::UploadSizeLimitExceeded(size, 104857600)) - } - 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; - if upload_url_from_server { - dlg.store_upload_url(url); - } - - cmn::ResumableUploadHelper { - client: &mut client.borrow_mut(), - delegate: dlg, - start_at: if upload_url_from_server { Some(0) } else { None }, - auth: &mut *self.hub.auth.borrow_mut(), - user_agent: &self.hub._user_agent, - auth_header: auth_header.clone(), - url: url, - reader: &mut reader, - media_type: reader_mime_type.clone(), - content_length: size - }.upload() - }; - match upload_result { - None => { - dlg.finished(false); - return Err(Error::Cancelled) - } - Some(Err(err)) => { - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Some(Ok(upload_result)) => { - res = upload_result; - if !res.status.is_success() { - dlg.finished(false); - return Err(Error::Failure(res)) - } - } - } - } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); @@ -37922,60 +46423,84 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien } } - /// Upload media all at once. - /// If the upload fails for whichever reason, all progress is lost. - /// - /// * *max size*: 100MB - /// * *multipart*: yes - /// * *valid mime types*: '*/*' - pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> - where RS: ReadSeek { - self.doit(stream, mime_type, "simple") - } - /// Upload media in a resumable fashion. - /// Even if the upload fails or is interrupted, it can be resumed for a - /// certain amount of time as the server maintains state temporarily. - /// - /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL - /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate - /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using - /// `cancel_chunk_upload(...)`. - /// - /// * *max size*: 100MB - /// * *multipart*: yes - /// * *valid mime types*: '*/*' - pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CreativeAssetMetadata)> - where RS: ReadSeek { - self.doit(resumeable_stream, mime_type, "resumable") - } - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Advertiser ID of this creative. This is a required field. + /// Project ID for order documents. /// - /// Sets the *advertiser id* path property to the given value. + /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn advertiser_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, C, A> { - self._advertiser_id = new_value.to_string(); + pub fn project_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Select only inventory items that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Select only inventory items that belong to specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> InventoryItemListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only inventory items that are in plan. + /// + /// Sets the *in plan* query property to the given value. + pub fn in_plan(mut self, new_value: bool) -> InventoryItemListCall<'a, C, A> { + self._in_plan = Some(new_value); + self + } + /// Select only inventory items with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> InventoryItemListCall<'a, C, A> { + self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -37984,7 +46509,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeAssetInsertCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> InventoryItemListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -38005,7 +46530,7 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeAssetInsertCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> InventoryItemListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -38022,7 +46547,265 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeAssetInsertCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> InventoryItemListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one inventory item by ID. +/// +/// A builder for the *get* method supported by a *inventoryItem* resource. +/// It is not used directly, but through a `InventoryItemMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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_items().get("profileId", "projectId", "id") +/// .doit(); +/// # } +/// ``` +pub struct InventoryItemGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _project_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for InventoryItemGetCall<'a, C, A> {} + +impl<'a, C, A> InventoryItemGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, InventoryItem)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.inventoryItems.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("projectId", self._project_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "projectId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/inventoryItems/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["profileId", "projectId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID for order documents. + /// + /// Sets the *project id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn project_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._project_id = new_value.to_string(); + self + } + /// Inventory item ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> InventoryItemGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> InventoryItemGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> InventoryItemGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> InventoryItemGetCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -38042,11 +46825,11 @@ impl<'a, C, A> CreativeAssetInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -38102,7 +46885,7 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRolePermissions/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRolePermissions/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -38140,16 +46923,20 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -38284,11 +47071,11 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -38299,7 +47086,7 @@ impl<'a, C, A> UserRolePermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_role_permissions().list("profileId") -/// .add_ids("dolor") +/// .add_ids("Lorem") /// .doit(); /// # } /// ``` @@ -38351,7 +47138,7 @@ impl<'a, C, A> UserRolePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cl params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/userRolePermissions".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/userRolePermissions".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -38389,16 +47176,20 @@ impl<'a, C, A> UserRolePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -38531,11 +47322,11 @@ impl<'a, C, A> UserRolePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -38589,7 +47380,7 @@ impl<'a, C, A> AccountPermissionGroupListCall<'a, C, A> where C: BorrowMut<hyper params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountPermissionGroups".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountPermissionGroups".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -38627,16 +47418,20 @@ impl<'a, C, A> AccountPermissionGroupListCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -38761,11 +47556,11 @@ impl<'a, C, A> AccountPermissionGroupListCall<'a, C, A> where C: BorrowMut<hyper /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -38821,7 +47616,7 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountPermissionGroups/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountPermissionGroups/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -38859,16 +47654,20 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -39003,11 +47802,11 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -39018,12 +47817,12 @@ impl<'a, C, A> AccountPermissionGroupGetCall<'a, C, A> where C: BorrowMut<hyper: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().list("profileId") -/// .sort_order("magna") -/// .sort_field("et") -/// .search_string("sed") -/// .page_token("est") -/// .max_results(-48) -/// .add_ids("et") +/// .sort_order("eirmod") +/// .sort_field("ea") +/// .search_string("et") +/// .page_token("sed") +/// .max_results(-7) +/// .add_ids("sea") /// .doit(); /// # } /// ``` @@ -39095,7 +47894,7 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -39133,16 +47932,20 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -39310,12 +48113,12 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::ContentCategory; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::ContentCategory; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -39325,7 +48128,7 @@ impl<'a, C, A> ContentCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ContentCategory = Default::default(); +/// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -39375,7 +48178,7 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -39417,16 +48220,20 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -39564,12 +48371,12 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::ContentCategory; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::ContentCategory; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -39579,7 +48386,7 @@ impl<'a, C, A> ContentCategoryUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ContentCategory = Default::default(); +/// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -39629,7 +48436,7 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -39671,16 +48478,20 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -39818,11 +48629,11 @@ impl<'a, C, A> ContentCategoryInsertCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -39877,7 +48688,7 @@ impl<'a, C, A> ContentCategoryDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -39915,16 +48726,20 @@ impl<'a, C, A> ContentCategoryDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -40049,11 +48864,11 @@ impl<'a, C, A> ContentCategoryDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -40109,7 +48924,7 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -40147,16 +48962,20 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -40291,12 +49110,12 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::ContentCategory; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::ContentCategory; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -40306,7 +49125,7 @@ impl<'a, C, A> ContentCategoryGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ContentCategory = Default::default(); +/// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -40358,7 +49177,7 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/contentCategories".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/contentCategories".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -40400,16 +49219,20 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -40545,260 +49368,6 @@ impl<'a, C, A> ContentCategoryPatchCall<'a, C, A> where C: BorrowMut<hyper::Clie } -/// Inserts a new creative. -/// -/// A builder for the *insert* method supported by a *creative* resource. -/// It is not used directly, but through a `CreativeMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Creative; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Creative = Default::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.creatives().insert(&req, "profileId") -/// .doit(); -/// # } -/// ``` -pub struct CreativeInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Creative, - _profile_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for CreativeInsertCall<'a, C, A> {} - -impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Creative)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.creatives.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "profileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creatives".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeInsertCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeInsertCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeInsertCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates an existing creative. /// /// A builder for the *update* method supported by a *creative* resource. @@ -40811,12 +49380,12 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Creative; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Creative; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -40826,7 +49395,7 @@ impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Creative = Default::default(); +/// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -40876,7 +49445,7 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creatives".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creatives".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -40918,16 +49487,20 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -41053,6 +49626,264 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } +/// Inserts a new creative. +/// +/// A builder for the *insert* method supported by a *creative* resource. +/// It is not used directly, but through a `CreativeMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Creative; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Creative::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.creatives().insert(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct CreativeInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Creative, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CreativeInsertCall<'a, C, A> {} + +impl<'a, C, A> CreativeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Creative)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.creatives.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creatives".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> CreativeInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CreativeInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CreativeInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Gets one creative by ID. /// /// A builder for the *get* method supported by a *creative* resource. @@ -41065,11 +49896,11 @@ impl<'a, C, A> CreativeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -41125,7 +49956,7 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creatives/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creatives/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -41163,16 +49994,20 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -41307,11 +50142,11 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -41322,22 +50157,22 @@ impl<'a, C, A> CreativeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().list("profileId") -/// .add_types("sit") -/// .studio_creative_id("sit") -/// .sort_order("dolores") -/// .sort_field("et") -/// .add_size_ids("sanctus") -/// .search_string("takimata") -/// .add_rendering_ids("kasd") -/// .page_token("ut") -/// .max_results(-44) -/// .add_ids("et") -/// .add_creative_field_ids("clita") -/// .add_companion_creative_ids("ipsum") -/// .campaign_id("dolor") +/// .add_types("erat") +/// .studio_creative_id("ipsum") +/// .sort_order("no") +/// .sort_field("vero") +/// .add_size_ids("sed") +/// .search_string("vero") +/// .add_rendering_ids("dolore") +/// .page_token("Lorem") +/// .max_results(-37) +/// .add_ids("duo") +/// .add_creative_field_ids("dolor") +/// .add_companion_creative_ids("accusam") +/// .campaign_id("diam") /// .archived(false) -/// .advertiser_id("magna") -/// .active(true) +/// .advertiser_id("eirmod") +/// .active(false) /// .doit(); /// # } /// ``` @@ -41469,7 +50304,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creatives".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creatives".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -41507,16 +50342,20 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -41759,12 +50598,12 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Creative; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Creative; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -41774,7 +50613,7 @@ impl<'a, C, A> CreativeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Creative = Default::default(); +/// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -41826,7 +50665,7 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creatives".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/creatives".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -41868,16 +50707,20 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -42025,11 +50868,11 @@ impl<'a, C, A> CreativePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -42085,7 +50928,7 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -42123,16 +50966,20 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -42267,12 +51114,12 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Campaign; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Campaign; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -42282,7 +51129,7 @@ impl<'a, C, A> CampaignGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Campaign = Default::default(); +/// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -42336,7 +51183,7 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -42378,16 +51225,20 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -42545,12 +51396,12 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Campaign; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Campaign; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -42560,7 +51411,7 @@ impl<'a, C, A> CampaignInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Campaign = Default::default(); +/// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -42612,7 +51463,7 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -42654,16 +51505,20 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -42811,12 +51666,12 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Campaign; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Campaign; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -42826,7 +51681,7 @@ impl<'a, C, A> CampaignPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Campaign = Default::default(); +/// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -42876,7 +51731,7 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -42918,16 +51773,20 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -43065,11 +51924,11 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -43080,19 +51939,19 @@ impl<'a, C, A> CampaignUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().list("profileId") -/// .subaccount_id("elitr") -/// .sort_order("et") -/// .sort_field("vero") -/// .search_string("sadipscing") -/// .page_token("sed") -/// .overridden_event_tag_id("vero") -/// .max_results(-91) -/// .add_ids("magna") -/// .add_excluded_ids("ea") -/// .at_least_one_optimization_activity(false) -/// .archived(true) -/// .add_advertiser_ids("labore") -/// .add_advertiser_group_ids("Lorem") +/// .subaccount_id("diam") +/// .sort_order("sed") +/// .sort_field("et") +/// .search_string("tempor") +/// .page_token("justo") +/// .overridden_event_tag_id("takimata") +/// .max_results(-37) +/// .add_ids("amet") +/// .add_excluded_ids("dolor") +/// .at_least_one_optimization_activity(true) +/// .archived(false) +/// .add_advertiser_ids("elitr") +/// .add_advertiser_group_ids("kasd") /// .doit(); /// # } /// ``` @@ -43204,7 +52063,7 @@ impl<'a, C, A> CampaignListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/campaigns".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/campaigns".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -43242,16 +52101,20 @@ impl<'a, C, A> CampaignListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -43471,11 +52334,11 @@ impl<'a, C, A> CampaignListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -43530,7 +52393,7 @@ impl<'a, C, A> EventTagDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -43568,16 +52431,20 @@ impl<'a, C, A> EventTagDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -43702,11 +52569,11 @@ impl<'a, C, A> EventTagDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -43717,16 +52584,16 @@ impl<'a, C, A> EventTagDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().list("profileId") -/// .sort_order("consetetur") -/// .sort_field("et") -/// .search_string("justo") -/// .add_ids("kasd") -/// .add_event_tag_types("kasd") +/// .sort_order("ipsum") +/// .sort_field("amet.") +/// .search_string("dolor") +/// .add_ids("sanctus") +/// .add_event_tag_types("ut") /// .enabled(true) /// .definitions_only(true) -/// .campaign_id("nonumy") -/// .advertiser_id("sanctus") -/// .ad_id("voluptua.") +/// .campaign_id("eirmod") +/// .advertiser_id("ea") +/// .ad_id("ea") /// .doit(); /// # } /// ``` @@ -43818,7 +52685,7 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -43856,16 +52723,20 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -44062,12 +52933,12 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::EventTag; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::EventTag; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -44077,7 +52948,7 @@ impl<'a, C, A> EventTagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EventTag = Default::default(); +/// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -44127,7 +52998,7 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -44169,16 +53040,20 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -44316,12 +53191,12 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::EventTag; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::EventTag; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -44331,7 +53206,7 @@ impl<'a, C, A> EventTagInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EventTag = Default::default(); +/// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -44383,7 +53258,7 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -44425,16 +53300,20 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -44582,12 +53461,12 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::EventTag; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::EventTag; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -44597,7 +53476,7 @@ impl<'a, C, A> EventTagPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EventTag = Default::default(); +/// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -44647,7 +53526,7 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -44689,16 +53568,20 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -44836,11 +53719,11 @@ impl<'a, C, A> EventTagUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -44896,7 +53779,7 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/eventTags/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/eventTags/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -44934,16 +53817,20 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45066,6 +53953,1368 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } +/// Gets one remarketing list by ID. +/// +/// A builder for the *get* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for RemarketingListGetCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingLists/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> RemarketingListGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. +/// +/// A builder for the *update* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = RemarketingList::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.remarketing_lists().update(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for RemarketingListUpdateCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves a list of remarketing lists, possibly filtered. +/// +/// A builder for the *list* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("profileId", "advertiserId") +/// .sort_order("eirmod") +/// .sort_field("aliquyam") +/// .page_token("no") +/// .name("aliquyam") +/// .max_results(-22) +/// .floodlight_activity_id("sed") +/// .active(false) +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _advertiser_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _page_token: Option<String>, + _name: Option<String>, + _max_results: Option<i32>, + _floodlight_activity_id: Option<String>, + _active: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for RemarketingListListCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingListsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("advertiserId", self._advertiser_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._floodlight_activity_id { + params.push(("floodlightActivityId", value.to_string())); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "floodlightActivityId", "active"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Select only remarketing lists owned by this advertiser. + /// + /// Sets the *advertiser id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn advertiser_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._advertiser_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list". + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._name = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> RemarketingListListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only remarketing lists that have this floodlight activity ID. + /// + /// Sets the *floodlight activity id* query property to the given value. + pub fn floodlight_activity_id(mut self, new_value: &str) -> RemarketingListListCall<'a, C, A> { + self._floodlight_activity_id = Some(new_value.to_string()); + self + } + /// Select only active or only inactive remarketing lists. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> RemarketingListListCall<'a, C, A> { + self._active = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing remarketing list. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = RemarketingList::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.remarketing_lists().patch(&req, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: RemarketingList, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for RemarketingListPatchCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Remarketing list ID. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListPatchCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListPatchCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new remarketing list. +/// +/// A builder for the *insert* method supported by a *remarketingList* resource. +/// It is not used directly, but through a `RemarketingListMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::RemarketingList; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = RemarketingList::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.remarketing_lists().insert(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct RemarketingListInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: RemarketingList, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for RemarketingListInsertCall<'a, C, A> {} + +impl<'a, C, A> RemarketingListInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RemarketingList)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.remarketingLists.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/remarketingLists".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> RemarketingListInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RemarketingListInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RemarketingListInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> RemarketingListInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of cities, possibly filtered. /// /// A builder for the *list* method supported by a *city* resource. @@ -45078,11 +55327,11 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -45093,10 +55342,10 @@ impl<'a, C, A> EventTagGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.cities().list("profileId") -/// .add_region_dart_ids("amet") -/// .name_prefix("Lorem") -/// .add_dart_ids("eirmod") -/// .add_country_dart_ids("elitr") +/// .add_region_dart_ids("sit") +/// .name_prefix("ipsum") +/// .add_dart_ids("dolore") +/// .add_country_dart_ids("sadipscing") /// .doit(); /// # } /// ``` @@ -45168,7 +55417,7 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/cities".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/cities".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -45206,16 +55455,20 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45359,6 +55612,510 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut } +/// Updates an existing placement strategy. +/// +/// A builder for the *update* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementStrategy; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = PlacementStrategy::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.placement_strategies().update(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: PlacementStrategy, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for PlacementStrategyUpdateCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementStrategyUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> PlacementStrategyUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one placement strategy by ID. +/// +/// A builder for the *get* method supported by a *placementStrategy* resource. +/// It is not used directly, but through a `PlacementStrategyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementStrategyGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for PlacementStrategyGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementStrategyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, PlacementStrategy)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement strategy ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementStrategyGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> PlacementStrategyGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of placement strategies, possibly filtered. /// /// A builder for the *list* method supported by a *placementStrategy* resource. @@ -45371,11 +56128,11 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -45386,12 +56143,12 @@ impl<'a, C, A> CityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().list("profileId") -/// .sort_order("et") -/// .sort_field("eirmod") -/// .search_string("ea") +/// .sort_order("consetetur") +/// .sort_field("sadipscing") +/// .search_string("ipsum") /// .page_token("et") -/// .max_results(-30) -/// .add_ids("sanctus") +/// .max_results(-88) +/// .add_ids("amet.") /// .doit(); /// # } /// ``` @@ -45463,7 +56220,7 @@ impl<'a, C, A> PlacementStrategyListCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -45501,16 +56258,20 @@ impl<'a, C, A> PlacementStrategyListCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -45666,502 +56427,6 @@ impl<'a, C, A> PlacementStrategyListCall<'a, C, A> where C: BorrowMut<hyper::Cli } -/// Updates an existing placement strategy. -/// -/// A builder for the *update* method supported by a *placementStrategy* resource. -/// It is not used directly, but through a `PlacementStrategyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementStrategy; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementStrategy = Default::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.placement_strategies().update(&req, "profileId") -/// .doit(); -/// # } -/// ``` -pub struct PlacementStrategyUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: PlacementStrategy, - _profile_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for PlacementStrategyUpdateCall<'a, C, A> {} - -impl<'a, C, A> PlacementStrategyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, PlacementStrategy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "profileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyUpdateCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementStrategyUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyUpdateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> PlacementStrategyUpdateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets one placement strategy by ID. -/// -/// A builder for the *get* method supported by a *placementStrategy* resource. -/// It is not used directly, but through a `PlacementStrategyMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("profileId", "id") -/// .doit(); -/// # } -/// ``` -pub struct PlacementStrategyGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for PlacementStrategyGetCall<'a, C, A> {} - -impl<'a, C, A> PlacementStrategyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, PlacementStrategy)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.placementStrategies.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "id"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies/{id}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "id"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Placement strategy ID. - /// - /// Sets the *id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementStrategyGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> PlacementStrategyGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Deletes an existing placement strategy. /// /// A builder for the *delete* method supported by a *placementStrategy* resource. @@ -46174,11 +56439,11 @@ impl<'a, C, A> PlacementStrategyGetCall<'a, C, A> where C: BorrowMut<hyper::Clie /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -46233,7 +56498,7 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C } - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -46271,16 +56536,20 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -46405,12 +56674,12 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementStrategy; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementStrategy; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -46420,7 +56689,7 @@ impl<'a, C, A> PlacementStrategyDeleteCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementStrategy = Default::default(); +/// let mut req = PlacementStrategy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -46470,7 +56739,7 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -46512,16 +56781,20 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -46659,12 +56932,12 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::PlacementStrategy; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::PlacementStrategy; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -46674,7 +56947,7 @@ impl<'a, C, A> PlacementStrategyInsertCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlacementStrategy = Default::default(); +/// let mut req = PlacementStrategy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -46726,7 +56999,7 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placementStrategies".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placementStrategies".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -46768,16 +57041,20 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -46913,6 +57190,838 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl } +/// Retrieves a list of projects, possibly filtered. +/// +/// A builder for the *list* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("profileId") +/// .sort_order("nonumy") +/// .sort_field("accusam") +/// .search_string("est") +/// .page_token("sit") +/// .max_results(-81) +/// .add_ids("vero") +/// .add_advertiser_ids("accusam") +/// .doit(); +/// # } +/// ``` +pub struct ProjectListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _search_string: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _ids: Vec<String>, + _advertiser_ids: Vec<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ProjectListCall<'a, C, A> {} + +impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ProjectsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.projects.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + let mut s = String::new(); + for f in self._ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("ids", s)); + } + if self._advertiser_ids.len() > 0 { + let mut s = String::new(); + for f in self._advertiser_ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("advertiserIds", s)); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for projects by name or ID. Wildcards (*) are allowed. For example, "project*2015" will return projects with names like "project June 2015", "project April 2015", or simply "project 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "project" will match projects with name "my project", "project 2015", or simply "project". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ProjectListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only projects with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only projects with these advertiser IDs. + /// + /// Append the given value to the *advertiser ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_advertiser_ids(mut self, new_value: &str) -> ProjectListCall<'a, C, A> { + self._advertiser_ids.push(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ProjectListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ProjectListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Gets one project by ID. +/// +/// A builder for the *get* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct ProjectGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ProjectGetCall<'a, C, A> {} + +impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Project)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.projects.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Project ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> ProjectGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ProjectGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Inserts a new directory site. +/// +/// A builder for the *insert* method supported by a *directorySite* resource. +/// It is not used directly, but through a `DirectorySiteMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::DirectorySite; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = DirectorySite::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.directory_sites().insert(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct DirectorySiteInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: DirectorySite, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for DirectorySiteInsertCall<'a, C, A> {} + +impl<'a, C, A> DirectorySiteInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, DirectorySite)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.directorySites.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/directorySites".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> DirectorySiteInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> DirectorySiteInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> DirectorySiteInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves a list of directory sites, possibly filtered. /// /// A builder for the *list* method supported by a *directorySite* resource. @@ -46925,11 +58034,11 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -46940,19 +58049,19 @@ impl<'a, C, A> PlacementStrategyPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_sites().list("profileId") -/// .sort_order("sanctus") -/// .sort_field("gubergren") -/// .search_string("est") -/// .parent_id("invidunt") -/// .page_token("voluptua.") -/// .max_results(-30) -/// .add_ids("ipsum") -/// .dfp_network_code("no") -/// .country_id("vero") -/// .active(true) +/// .sort_order("kasd") +/// .sort_field("diam") +/// .search_string("ut") +/// .parent_id("diam") +/// .page_token("eos") +/// .max_results(-94) +/// .add_ids("tempor") +/// .dfp_network_code("ipsum") +/// .country_id("no") +/// .active(false) /// .accepts_publisher_paid_placements(false) -/// .accepts_interstitial_placements(false) -/// .accepts_in_stream_video_placements(false) +/// .accepts_interstitial_placements(true) +/// .accepts_in_stream_video_placements(true) /// .doit(); /// # } /// ``` @@ -47052,7 +58161,7 @@ impl<'a, C, A> DirectorySiteListCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/directorySites".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/directorySites".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -47090,16 +58199,20 @@ impl<'a, C, A> DirectorySiteListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -47316,11 +58429,11 @@ impl<'a, C, A> DirectorySiteListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -47376,7 +58489,7 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/directorySites/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/directorySites/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -47414,16 +58527,20 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -47558,12 +58675,12 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Size; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Size; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -47573,7 +58690,7 @@ impl<'a, C, A> DirectorySiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Size = Default::default(); +/// let mut req = Size::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -47623,7 +58740,7 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sizes".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sizes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -47665,16 +58782,20 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -47812,11 +58933,11 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -47827,10 +58948,10 @@ impl<'a, C, A> SizeInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sizes().list("profileId") -/// .width(-79) -/// .add_ids("dolor") -/// .iab_standard(false) -/// .height(-97) +/// .width(-10) +/// .add_ids("clita") +/// .iab_standard(true) +/// .height(-14) /// .doit(); /// # } /// ``` @@ -47894,7 +59015,7 @@ impl<'a, C, A> SizeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sizes".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sizes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -47932,16 +59053,20 @@ impl<'a, C, A> SizeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -48095,11 +59220,11 @@ impl<'a, C, A> SizeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -48155,7 +59280,7 @@ impl<'a, C, A> SizeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/sizes/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/sizes/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -48193,16 +59318,20 @@ impl<'a, C, A> SizeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -48337,11 +59466,11 @@ impl<'a, C, A> SizeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -48397,7 +59526,7 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -48435,16 +59564,20 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -48579,12 +59712,12 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::AccountUserProfile; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AccountUserProfile; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -48594,7 +59727,7 @@ impl<'a, C, A> AccountActiveAdSummaryGetCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccountUserProfile = Default::default(); +/// let mut req = AccountUserProfile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -48644,7 +59777,7 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountUserProfiles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountUserProfiles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -48686,16 +59819,20 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -48833,11 +59970,11 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -48848,15 +59985,15 @@ impl<'a, C, A> AccountUserProfileUpdateCall<'a, C, A> where C: BorrowMut<hyper:: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().list("profileId") -/// .user_role_id("dolor") -/// .subaccount_id("dolor") -/// .sort_order("dolore") -/// .sort_field("duo") -/// .search_string("ipsum") -/// .page_token("diam") -/// .max_results(-43) -/// .add_ids("et") -/// .active(true) +/// .user_role_id("rebum.") +/// .subaccount_id("sit") +/// .sort_order("Lorem") +/// .sort_field("sanctus") +/// .search_string("accusam") +/// .page_token("dolore") +/// .max_results(-6) +/// .add_ids("invidunt") +/// .active(false) /// .doit(); /// # } /// ``` @@ -48940,7 +60077,7 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountUserProfiles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountUserProfiles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -48978,16 +60115,20 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -49164,6 +60305,264 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl } +/// Inserts a new account user profile. +/// +/// A builder for the *insert* method supported by a *accountUserProfile* resource. +/// It is not used directly, but through a `AccountUserProfileMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AccountUserProfile; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = AccountUserProfile::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.account_user_profiles().insert(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUserProfileInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: AccountUserProfile, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AccountUserProfileInsertCall<'a, C, A> {} + +impl<'a, C, A> AccountUserProfileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, AccountUserProfile)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accountUserProfiles.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountUserProfiles".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> AccountUserProfileInsertCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountUserProfileInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfileInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AccountUserProfileInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an existing account user profile. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *accountUserProfile* resource. @@ -49176,12 +60575,12 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::AccountUserProfile; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::AccountUserProfile; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -49191,7 +60590,7 @@ impl<'a, C, A> AccountUserProfileListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AccountUserProfile = Default::default(); +/// let mut req = AccountUserProfile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -49243,7 +60642,7 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountUserProfiles".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountUserProfiles".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -49285,16 +60684,20 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -49442,11 +60845,11 @@ impl<'a, C, A> AccountUserProfilePatchCall<'a, C, A> where C: BorrowMut<hyper::C /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -49502,7 +60905,7 @@ impl<'a, C, A> AccountUserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/accountUserProfiles/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accountUserProfiles/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -49540,16 +60943,20 @@ impl<'a, C, A> AccountUserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -49684,11 +61091,11 @@ impl<'a, C, A> AccountUserProfileGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -49742,7 +61149,7 @@ impl<'a, C, A> CountryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/countries".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/countries".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -49780,16 +61187,20 @@ impl<'a, C, A> CountryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -49914,11 +61325,11 @@ impl<'a, C, A> CountryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -49974,7 +61385,7 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/countries/{dartId}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/countries/{dartId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -50012,16 +61423,20 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -50144,10 +61559,10 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } -/// Updates an existing creative field value. This method supports patch semantics. +/// Gets one order document by ID. /// -/// A builder for the *patch* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// A builder for the *get* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. /// /// # Example /// @@ -50156,50 +61571,43 @@ impl<'a, C, A> CountryGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeFieldValue; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeFieldValue = Default::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.creative_field_values().patch(&req, "profileId", "creativeFieldId", "id") +/// let result = hub.order_documents().get("profileId", "projectId", "id") /// .doit(); /// # } /// ``` -pub struct CreativeFieldValuePatchCall<'a, C, A> +pub struct OrderDocumentGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, - _request: CreativeFieldValue, _profile_id: String, - _creative_field_id: String, + _project_id: String, _id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for CreativeFieldValuePatchCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for OrderDocumentGetCall<'a, C, A> {} -impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> OrderDocumentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, OrderDocument)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -50207,1059 +61615,13 @@ impl<'a, C, A> CreativeFieldValuePatchCall<'a, C, A> where C: BorrowMut<hyper::C Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "creativeFieldId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Creative field ID for this creative field value. - /// - /// Sets the *creative field id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); - self - } - /// Creative Field Value ID - /// - /// Sets the *id* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValuePatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValuePatchCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValuePatchCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes an existing creative field value. -/// -/// A builder for the *delete* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().delete("profileId", "creativeFieldId", "id") -/// .doit(); -/// # } -/// ``` -pub struct CreativeFieldValueDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _creative_field_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for CreativeFieldValueDeleteCall<'a, C, A> {} - -impl<'a, C, A> CreativeFieldValueDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<hyper::client::Response> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.delete", - http_method: hyper::method::Method::Delete }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["profileId", "creativeFieldId", "id"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); - for param_name in ["profileId", "creativeFieldId", "id"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Creative field ID for this creative field value. - /// - /// Sets the *creative field id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); - self - } - /// Creative Field Value ID - /// - /// Sets the *id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueDeleteCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueDeleteCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Inserts a new creative field value. -/// -/// A builder for the *insert* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeFieldValue; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeFieldValue = Default::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.creative_field_values().insert(&req, "profileId", "creativeFieldId") -/// .doit(); -/// # } -/// ``` -pub struct CreativeFieldValueInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: CreativeFieldValue, - _profile_id: String, - _creative_field_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for CreativeFieldValueInsertCall<'a, C, A> {} - -impl<'a, C, A> CreativeFieldValueInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); - for &field in ["alt", "profileId", "creativeFieldId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "creativeFieldId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Creative field ID for this creative field value. - /// - /// Sets the *creative field id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueInsertCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueInsertCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates an existing creative field value. -/// -/// A builder for the *update* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::CreativeFieldValue; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: CreativeFieldValue = Default::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.creative_field_values().update(&req, "profileId", "creativeFieldId") -/// .doit(); -/// # } -/// ``` -pub struct CreativeFieldValueUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: CreativeFieldValue, - _profile_id: String, - _creative_field_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for CreativeFieldValueUpdateCall<'a, C, A> {} - -impl<'a, C, A> CreativeFieldValueUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); - for &field in ["alt", "profileId", "creativeFieldId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "creativeFieldId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Creative field ID for this creative field value. - /// - /// Sets the *creative field id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueUpdateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueUpdateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Gets one creative field value by ID. -/// -/// A builder for the *get* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("profileId", "creativeFieldId", "id") -/// .doit(); -/// # } -/// ``` -pub struct CreativeFieldValueGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _creative_field_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for CreativeFieldValueGetCall<'a, C, A> {} - -impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValue)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.get", + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("projectId", self._project_id.to_string())); params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { + for &field in ["alt", "profileId", "projectId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -51271,12 +61633,12 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/orderDocuments/{id}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -51288,7 +61650,7 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); - for param_name in ["profileId", "creativeFieldId", "id"].iter() { + for param_name in ["profileId", "projectId", "id"].iter() { for (index, &(ref name, _)) in params.iter().rev().enumerate() { if name == param_name { indices_for_removal.push(params.len() - index - 1); @@ -51309,16 +61671,20 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -51375,27 +61741,27 @@ impl<'a, C, A> CreativeFieldValueGetCall<'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 profile_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Creative field ID for this creative field value. + /// Project ID for order documents. /// - /// Sets the *creative field id* path property to the given value. + /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); + pub fn project_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { + self._project_id = new_value.to_string(); self } - /// Creative Field Value ID + /// Order document ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, C, A> { + pub fn id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, C, A> { self._id = new_value.to_string(); self } @@ -51405,7 +61771,7 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrderDocumentGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -51426,7 +61792,7 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueGetCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> OrderDocumentGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -51443,7 +61809,7 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueGetCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> OrderDocumentGetCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -51451,10 +61817,10 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli } -/// Retrieves a list of creative field values, possibly filtered. +/// Retrieves a list of order documents, possibly filtered. /// -/// A builder for the *list* method supported by a *creativeFieldValue* resource. -/// It is not used directly, but through a `CreativeFieldValueMethods` instance. +/// A builder for the *list* method supported by a *orderDocument* resource. +/// It is not used directly, but through a `OrderDocumentMethods` instance. /// /// # Example /// @@ -51463,11 +61829,11 @@ impl<'a, C, A> CreativeFieldValueGetCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -51477,40 +61843,46 @@ impl<'a, C, A> CreativeFieldValueGetCall<'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.creative_field_values().list("profileId", "creativeFieldId") -/// .sort_order("et") -/// .sort_field("sanctus") -/// .search_string("diam") -/// .page_token("eos") -/// .max_results(-38) -/// .add_ids("sea") +/// let result = hub.order_documents().list("profileId", "projectId") +/// .sort_order("consetetur") +/// .sort_field("magna") +/// .add_site_id("invidunt") +/// .search_string("At") +/// .page_token("rebum.") +/// .add_order_id("sit") +/// .max_results(-100) +/// .add_ids("clita") +/// .approved(true) /// .doit(); /// # } /// ``` -pub struct CreativeFieldValueListCall<'a, C, A> +pub struct OrderDocumentListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, _profile_id: String, - _creative_field_id: String, + _project_id: String, _sort_order: Option<String>, _sort_field: Option<String>, + _site_id: Vec<String>, _search_string: Option<String>, _page_token: Option<String>, + _order_id: Vec<String>, _max_results: Option<i32>, _ids: Vec<String>, + _approved: Option<bool>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for CreativeFieldValueListCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for OrderDocumentListCall<'a, C, A> {} -impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> OrderDocumentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CreativeFieldValuesListResponse)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, OrderDocumentsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -51518,23 +61890,37 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.creativeFieldValues.list", + dlg.begin(MethodInfo { id: "dfareporting.orderDocuments.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("creativeFieldId", self._creative_field_id.to_string())); + params.push(("projectId", self._project_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } + if self._site_id.len() > 0 { + let mut s = String::new(); + for f in self._site_id.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("siteId", s)); + } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } + if self._order_id.len() > 0 { + let mut s = String::new(); + for f in self._order_id.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("orderId", s)); + } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } @@ -51545,7 +61931,10 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl } params.push(("ids", s)); } - for &field in ["alt", "profileId", "creativeFieldId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { + if let Some(value) = self._approved { + params.push(("approved", value.to_string())); + } + for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "orderId", "maxResults", "ids", "approved"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -51557,12 +61946,12 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/projects/{projectId}/orderDocuments".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -51574,7 +61963,7 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "creativeFieldId"].iter() { + for param_name in ["profileId", "projectId"].iter() { for (index, &(ref name, _)) in params.iter().rev().enumerate() { if name == param_name { indices_for_removal.push(params.len() - index - 1); @@ -51595,16 +61984,20 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -51661,70 +62054,93 @@ impl<'a, C, A> CreativeFieldValueListCall<'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 profile_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Creative field ID for this creative field value. + /// Project ID for order documents. /// - /// Sets the *creative field id* path property to the given value. + /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { - self._creative_field_id = new_value.to_string(); + pub fn project_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._project_id = new_value.to_string(); self } /// Order of sorted results, default is ASCENDING. /// /// Sets the *sort order* query property to the given value. - pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn sort_order(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. - pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn sort_field(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._sort_field = Some(new_value.to_string()); self } - /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed. + /// Select only order documents that are associated with these sites. + /// + /// Append the given value to the *site id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_site_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._site_id.push(new_value.to_string()); + self + } + /// Allows searching for order documents by name or ID. Wildcards (*) are allowed. For example, "orderdocument*2015" will return order documents with names like "orderdocument June 2015", "orderdocument April 2015", or simply "orderdocument 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "orderdocument" will match order documents with name "my orderdocument", "orderdocument 2015", or simply "orderdocument". /// /// Sets the *search string* query property to the given value. - pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn search_string(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn page_token(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } + /// Select only order documents for specified orders. + /// + /// Append the given value to the *order id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_order_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { + self._order_id.push(new_value.to_string()); + self + } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, C, A> { + pub fn max_results(mut self, new_value: i32) -> OrderDocumentListCall<'a, C, A> { self._max_results = Some(new_value); self } - /// Select only creative field values with these IDs. + /// Select only order documents with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. - pub fn add_ids(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C, A> { + pub fn add_ids(mut self, new_value: &str) -> OrderDocumentListCall<'a, C, A> { self._ids.push(new_value.to_string()); self } + /// Select only order documents that have been approved by at least one user. + /// + /// Sets the *approved* query property to the given value. + pub fn approved(mut self, new_value: bool) -> OrderDocumentListCall<'a, C, A> { + self._approved = Some(new_value); + self + } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> CreativeFieldValueListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> OrderDocumentListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -51745,7 +62161,7 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueListCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> OrderDocumentListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -51762,7 +62178,7 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> CreativeFieldValueListCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> OrderDocumentListCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -51770,10 +62186,10 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl } -/// Updates a report. +/// Gets one postal code by ID. /// -/// A builder for the *update* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. +/// A builder for the *get* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. /// /// # Example /// @@ -51782,277 +62198,11 @@ impl<'a, C, A> CreativeFieldValueListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Report; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Report = Default::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.reports().update(&req, "profileId", "reportId") -/// .doit(); -/// # } -/// ``` -pub struct ReportUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Report, - _profile_id: String, - _report_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportUpdateCall<'a, C, A> {} - -impl<'a, C, A> ReportUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - for &field in ["alt", "profileId", "reportId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportUpdateCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportUpdateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportUpdateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Runs a report. -/// -/// A builder for the *run* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -52062,30 +62212,28 @@ 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().run("profileId", "reportId") -/// .synchronous(true) +/// let result = hub.postal_codes().get("profileId", "code") /// .doit(); /// # } /// ``` -pub struct ReportRunCall<'a, C, A> +pub struct PostalCodeGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, _profile_id: String, - _report_id: String, - _synchronous: Option<bool>, + _code: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for ReportRunCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for PostalCodeGetCall<'a, C, A> {} -impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> PostalCodeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, File)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, PostalCode)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -52093,550 +62241,12 @@ impl<'a, C, A> ReportRunCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.reports.run", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - if let Some(value) = self._synchronous { - params.push(("synchronous", value.to_string())); - } - for &field in ["alt", "profileId", "reportId", "synchronous"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}/run".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The DFA profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportRunCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// If set and true, tries to run the report synchronously. - /// - /// Sets the *synchronous* query property to the given value. - pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, C, A> { - self._synchronous = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportRunCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportRunCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportRunCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Updates a report. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Report; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Report = Default::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.reports().patch(&req, "profileId", "reportId") -/// .doit(); -/// # } -/// ``` -pub struct ReportPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Report, - _profile_id: String, - _report_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportPatchCall<'a, C, A> {} - -impl<'a, C, A> ReportPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - for &field in ["alt", "profileId", "reportId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportPatchCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportPatchCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportPatchCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Lists files for a report. -/// -/// A builder for the *files.list* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().files_list("profileId", "reportId") -/// .sort_order("accusam") -/// .sort_field("sed") -/// .page_token("sea") -/// .max_results(-1) -/// .doit(); -/// # } -/// ``` -pub struct ReportFileListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _report_id: String, - _sort_order: Option<String>, - _sort_field: Option<String>, - _page_token: Option<String>, - _max_results: Option<i32>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportFileListCall<'a, C, A> {} - -impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, FileList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.files.list", + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - if let Some(value) = self._sort_order { - params.push(("sortOrder", value.to_string())); - } - if let Some(value) = self._sort_field { - params.push(("sortField", value.to_string())); - } - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - for &field in ["alt", "profileId", "reportId", "sortOrder", "sortField", "pageToken", "maxResults"].iter() { + params.push(("code", self._code.to_string())); + for &field in ["alt", "profileId", "code"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -52648,12 +62258,12 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}/files".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/postalCodes/{code}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{code}", "code")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { @@ -52665,7 +62275,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } { let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { + for param_name in ["profileId", "code"].iter() { for (index, &(ref name, _)) in params.iter().rev().enumerate() { if name == param_name { indices_for_removal.push(params.len() - index - 1); @@ -52686,16 +62296,20 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -52746,52 +62360,24 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } - /// The DFA profile ID. + /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// The ID of the parent report. + /// Postal code ID. /// - /// Sets the *report id* path property to the given value. + /// Sets the *code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// Order of sorted results, default is 'DESCENDING'. - /// - /// Sets the *sort order* query property to the given value. - pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { - self._sort_order = Some(new_value.to_string()); - self - } - /// The field by which to sort the list. - /// - /// Sets the *sort field* query property to the given value. - pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { - self._sort_field = Some(new_value.to_string()); - self - } - /// The value of the nextToken from the previous result page. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of results to return. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'a, C, A> { - self._max_results = Some(new_value); + pub fn code(mut self, new_value: &str) -> PostalCodeGetCall<'a, C, A> { + self._code = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong @@ -52800,7 +62386,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportFileListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PostalCodeGetCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -52821,7 +62407,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportFileListCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> PostalCodeGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -52830,7 +62416,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. + /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -52838,7 +62424,7 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportFileListCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> PostalCodeGetCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -52846,10 +62432,10 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } -/// Creates a report. +/// Retrieves a list of postal codes. /// -/// A builder for the *insert* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. +/// A builder for the *list* method supported by a *postalCode* resource. +/// It is not used directly, but through a `PostalCodeMethods` instance. /// /// # Example /// @@ -52858,519 +62444,11 @@ impl<'a, C, A> ReportFileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Report; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Report = Default::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.reports().insert(&req, "profileId") -/// .doit(); -/// # } -/// ``` -pub struct ReportInsertCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Report, - _profile_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportInsertCall<'a, C, A> {} - -impl<'a, C, A> ReportInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.insert", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "profileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportInsertCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportInsertCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportInsertCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportInsertCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions. -/// -/// A builder for the *compatibleFields.query* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Report; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Report = Default::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.reports().compatible_fields_query(&req, "profileId") -/// .doit(); -/// # } -/// ``` -pub struct ReportCompatibleFieldQueryCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _request: Report, - _profile_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportCompatibleFieldQueryCall<'a, C, A> {} - -impl<'a, C, A> ReportCompatibleFieldQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, CompatibleFields)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.compatibleFields.query", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - for &field in ["alt", "profileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/compatiblefields/query".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["profileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportCompatibleFieldQueryCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportCompatibleFieldQueryCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportCompatibleFieldQueryCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportCompatibleFieldQueryCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a report by its ID. -/// -/// A builder for the *get* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -53380,28 +62458,27 @@ impl<'a, C, A> ReportCompatibleFieldQueryCall<'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.reports().get("profileId", "reportId") +/// let result = hub.postal_codes().list("profileId") /// .doit(); /// # } /// ``` -pub struct ReportGetCall<'a, C, A> +pub struct PostalCodeListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Dfareporting<C, A>, _profile_id: String, - _report_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for ReportGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for PostalCodeListCall<'a, C, A> {} -impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> PostalCodeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> { + pub fn doit(mut self) -> Result<(hyper::client::Response, PostalCodesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; let mut dd = DefaultDelegate; @@ -53409,783 +62486,11 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "dfareporting.reports.get", + dlg.begin(MethodInfo { id: "dfareporting.postalCodes.list", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - for &field in ["alt", "profileId", "reportId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportGetCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves a report file. -/// -/// This method supports **media download**. To enable it, adjust the builder like this: -/// `.param("alt", "media")`. -/// Please note that due to missing multi-part support on the server side, you will only receive the media, -/// but not the `File` structure that you would usually get. The latter will be a default value. -/// -/// A builder for the *files.get* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().files_get("profileId", "reportId", "fileId") -/// .doit(); -/// # } -/// ``` -pub struct ReportFileGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _report_id: String, - _file_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportFileGetCall<'a, C, A> {} - -impl<'a, C, A> ReportFileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, File)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.files.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - params.push(("fileId", self._file_id.to_string())); - for &field in ["profileId", "reportId", "fileId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - let (json_field_missing, enable_resource_parsing) = { - let mut enable = true; - let mut field_present = true; - for &(name, ref value) in params.iter() { - if name == "alt" { - field_present = false; - if <String as AsRef<str>>::as_ref(&value) != "json" { - enable = false; - } - break; - } - } - (field_present, enable) - }; - if json_field_missing { - params.push(("alt", "json".to_string())); - } - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}/files/{fileId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId"), ("{fileId}", "fileId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); - for param_name in ["profileId", "reportId", "fileId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = if enable_resource_parsing { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - } else { (res, Default::default()) }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The DFA profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// The ID of the report file. - /// - /// Sets the *file id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn file_id(mut self, new_value: &str) -> ReportFileGetCall<'a, C, A> { - self._file_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportFileGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportFileGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportFileGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Deletes a report by its ID. -/// -/// A builder for the *delete* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().delete("profileId", "reportId") -/// .doit(); -/// # } -/// ``` -pub struct ReportDeleteCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _report_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportDeleteCall<'a, C, A> {} - -impl<'a, C, A> ReportDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<hyper::client::Response> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.delete", - http_method: hyper::method::Method::Delete }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("profileId", self._profile_id.to_string())); - params.push(("reportId", self._report_id.to_string())); - for &field in ["profileId", "reportId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports/{reportId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "reportId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = res; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The DFA user profile ID. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// The ID of the report. - /// - /// Sets the *report id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn report_id(mut self, new_value: &str) -> ReportDeleteCall<'a, C, A> { - self._report_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportDeleteCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportDeleteCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportDeleteCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - -/// Retrieves list of reports. -/// -/// A builder for the *list* method supported by a *report* resource. -/// It is not used directly, but through a `ReportMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().list("profileId") -/// .sort_order("dolor") -/// .sort_field("consetetur") -/// .scope("sadipscing") -/// .page_token("ipsum") -/// .max_results(-17) -/// .doit(); -/// # } -/// ``` -pub struct ReportListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _sort_order: Option<String>, - _sort_field: Option<String>, - _scope: Option<String>, - _page_token: Option<String>, - _max_results: Option<i32>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReportListCall<'a, C, A> {} - -impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ReportList)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.reports.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - if let Some(value) = self._sort_order { - params.push(("sortOrder", value.to_string())); - } - if let Some(value) = self._sort_field { - params.push(("sortField", value.to_string())); - } - if let Some(value) = self._scope { - params.push(("scope", value.to_string())); - } - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "maxResults"].iter() { + for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -54197,9 +62502,9 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/reports".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/postalCodes".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { @@ -54235,16 +62540,20 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -54295,58 +62604,23 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } - /// The DFA user profile ID. + /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> ReportListCall<'a, C, A> { + pub fn profile_id(mut self, new_value: &str) -> PostalCodeListCall<'a, C, A> { self._profile_id = new_value.to_string(); self } - /// Order of sorted results, default is 'DESCENDING'. - /// - /// Sets the *sort order* query property to the given value. - pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, C, A> { - self._sort_order = Some(new_value.to_string()); - self - } - /// The field by which to sort the list. - /// - /// Sets the *sort field* query property to the given value. - pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, C, A> { - self._sort_field = Some(new_value.to_string()); - self - } - /// The scope that defines which results are returned, default is 'MINE'. - /// - /// Sets the *scope* query property to the given value. - pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, C, A> { - self._scope = Some(new_value.to_string()); - self - } - /// The value of the nextToken from the previous result page. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of results to return. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: i32) -> ReportListCall<'a, C, A> { - self._max_results = Some(new_value); - self - } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportListCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PostalCodeListCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -54367,7 +62641,7 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReportListCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> PostalCodeListCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -54376,7 +62650,7 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. + /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -54384,7 +62658,7 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReportListCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> PostalCodeListCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -54404,11 +62678,11 @@ impl<'a, C, A> ReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -54462,7 +62736,7 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/browsers".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/browsers".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -54500,16 +62774,20 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -54622,6 +62900,1103 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } +/// Gets one account by ID. +/// +/// A builder for the *get* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} + +impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accounts/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AccountGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Retrieves the list of accounts, possibly filtered. +/// +/// A builder for the *list* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("profileId") +/// .sort_order("dolor") +/// .sort_field("vero") +/// .search_string("erat") +/// .page_token("dolore") +/// .max_results(-33) +/// .add_ids("Stet") +/// .active(true) +/// .doit(); +/// # } +/// ``` +pub struct AccountListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _sort_order: Option<String>, + _sort_field: Option<String>, + _search_string: Option<String>, + _page_token: Option<String>, + _max_results: Option<i32>, + _ids: Vec<String>, + _active: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AccountListCall<'a, C, A> {} + +impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, AccountsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_field { + params.push(("sortField", value.to_string())); + } + if let Some(value) = self._search_string { + params.push(("searchString", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if self._ids.len() > 0 { + let mut s = String::new(); + for f in self._ids.iter() { + s.push_str(&("/".to_string() + &f.to_string())); + } + params.push(("ids", s)); + } + if let Some(value) = self._active { + params.push(("active", value.to_string())); + } + for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Order of sorted results, default is ASCENDING. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Field by which to sort the list. + /// + /// Sets the *sort field* query property to the given value. + pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._sort_field = Some(new_value.to_string()); + self + } + /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "account*2015" will return objects with names like "account June 2015", "account April 2015", or simply "account 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "account" will match objects with name "my account", "account 2015", or simply "account". + /// + /// Sets the *search string* query property to the given value. + pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._search_string = Some(new_value.to_string()); + self + } + /// Value of the nextPageToken from the previous result page. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Select only accounts with these IDs. + /// + /// Append the given value to the *ids* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_ids(mut self, new_value: &str) -> AccountListCall<'a, C, A> { + self._ids.push(new_value.to_string()); + self + } + /// Select only active accounts. Don't set this field to select both active and non-active accounts. + /// + /// Sets the *active* query property to the given value. + pub fn active(mut self, new_value: bool) -> AccountListCall<'a, C, A> { + self._active = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AccountListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. +/// +/// A builder for the *update* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// 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().update(&req, "profileId") +/// .doit(); +/// # } +/// ``` +pub struct AccountUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Account, + _profile_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AccountUpdateCall<'a, C, A> {} + +impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + for &field in ["alt", "profileId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> AccountUpdateCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AccountUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AccountUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates an existing account. This method supports patch semantics. +/// +/// A builder for the *patch* method supported by a *account* resource. +/// It is not used directly, but through a `AccountMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Account; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// 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, "profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct AccountPatchCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _request: Account, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AccountPatchCall<'a, C, A> {} + +impl<'a, C, A> AccountPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Account)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.accounts.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/accounts".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["profileId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Account ID. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> AccountPatchCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountPatchCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AccountPatchCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AccountPatchCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an existing placement. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *placement* resource. @@ -54634,12 +64009,12 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Placement; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Placement; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -54649,7 +64024,7 @@ impl<'a, C, A> BrowserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Placement = Default::default(); +/// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -54701,7 +64076,7 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -54743,16 +64118,20 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -54900,11 +64279,11 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -54916,23 +64295,23 @@ impl<'a, C, A> PlacementPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().list("profileId") /// .sort_order("et") -/// .sort_field("amet") -/// .add_size_ids("sit") -/// .add_site_ids("vero") -/// .search_string("nonumy") -/// .add_pricing_types("accusam") -/// .add_placement_strategy_ids("est") -/// .payment_source("sit") -/// .page_token("erat") -/// .max_results(-25) -/// .add_ids("accusam") -/// .add_group_ids("et") -/// .add_directory_site_ids("clita") -/// .add_content_category_ids("tempor") -/// .add_compatibilities("ut") -/// .add_campaign_ids("kasd") -/// .archived(false) -/// .add_advertiser_ids("ut") +/// .sort_field("kasd") +/// .add_size_ids("sed") +/// .add_site_ids("tempor") +/// .search_string("diam") +/// .add_pricing_types("takimata") +/// .add_placement_strategy_ids("Lorem") +/// .payment_source("dolor") +/// .page_token("amet.") +/// .max_results(-29) +/// .add_ids("sea") +/// .add_group_ids("consetetur") +/// .add_directory_site_ids("sea") +/// .add_content_category_ids("voluptua.") +/// .add_compatibilities("At") +/// .add_campaign_ids("sanctus") +/// .archived(true) +/// .add_advertiser_ids("sit") /// .doit(); /// # } /// ``` @@ -55092,7 +64471,7 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -55130,16 +64509,20 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -55389,248 +64772,6 @@ impl<'a, C, A> PlacementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } -/// Gets one placement by ID. -/// -/// A builder for the *get* method supported by a *placement* resource. -/// It is not used directly, but through a `PlacementMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("profileId", "id") -/// .doit(); -/// # } -/// ``` -pub struct PlacementGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Dfareporting<C, A>, - _profile_id: String, - _id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for PlacementGetCall<'a, C, A> {} - -impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Placement)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "dfareporting.placements.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("profileId", self._profile_id.to_string())); - params.push(("id", self._id.to_string())); - for &field in ["alt", "profileId", "id"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements/{id}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); - for param_name in ["profileId", "id"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// User profile ID associated with this request. - /// - /// Sets the *profile id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn profile_id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { - self._profile_id = new_value.to_string(); - self - } - /// Placement ID. - /// - /// Sets the *id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> PlacementGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Dfatrafficking`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> PlacementGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Inserts a new placement. /// /// A builder for the *insert* method supported by a *placement* resource. @@ -55643,12 +64784,12 @@ impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Placement; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Placement; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -55658,7 +64799,7 @@ impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Placement = Default::default(); +/// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -55708,7 +64849,7 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -55750,16 +64891,20 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -55897,12 +65042,12 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; -/// use dfareporting2::Placement; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// use dfareporting2d1::Placement; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -55912,7 +65057,7 @@ impl<'a, C, A> PlacementInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Placement = Default::default(); +/// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -55962,7 +65107,7 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -56004,16 +65149,20 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -56151,11 +65300,11 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dfareporting2 as dfareporting2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dfareporting2::Dfareporting; +/// # use dfareporting2d1::Dfareporting; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -56166,9 +65315,9 @@ impl<'a, C, A> PlacementUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().generatetags("profileId") -/// .add_tag_formats("no") -/// .add_placement_ids("takimata") -/// .campaign_id("takimata") +/// .add_tag_formats("Stet") +/// .add_placement_ids("sed") +/// .campaign_id("eirmod") /// .doit(); /// # } /// ``` @@ -56232,7 +65381,7 @@ impl<'a, C, A> PlacementGeneratetagCall<'a, C, A> where C: BorrowMut<hyper::Clie params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dfareporting/v2.0/userprofiles/{profileId}/placements/generatetags".to_string(); + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements/generatetags".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } @@ -56270,16 +65419,20 @@ impl<'a, C, A> PlacementGeneratetagCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -56415,3 +65568,249 @@ impl<'a, C, A> PlacementGeneratetagCall<'a, C, A> where C: BorrowMut<hyper::Clie } +/// Gets one placement by ID. +/// +/// A builder for the *get* method supported by a *placement* resource. +/// It is not used directly, but through a `PlacementMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_dfareporting2d1 as dfareporting2d1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use dfareporting2d1::Dfareporting; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Dfareporting::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("profileId", "id") +/// .doit(); +/// # } +/// ``` +pub struct PlacementGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Dfareporting<C, A>, + _profile_id: String, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for PlacementGetCall<'a, C, A> {} + +impl<'a, C, A> PlacementGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Placement)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "dfareporting.placements.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("profileId", self._profile_id.to_string())); + params.push(("id", self._id.to_string())); + for &field in ["alt", "profileId", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/dfareporting/v2.1/userprofiles/{profileId}/placements/{id}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["profileId", "id"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// User profile ID associated with this request. + /// + /// Sets the *profile id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn profile_id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._profile_id = new_value.to_string(); + self + } + /// Placement ID. + /// + /// Sets the *id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> PlacementGetCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> PlacementGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> PlacementGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Dfatrafficking`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> PlacementGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + diff --git a/gen/discovery1-cli/Cargo.toml b/gen/discovery1-cli/Cargo.toml index ba7b102d90..130a2d964b 100644 --- a/gen/discovery1-cli/Cargo.toml +++ b/gen/discovery1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-discovery1-cli" version = "0.0.1+00000000" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/discovery/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/discovery1-cli/src/cmn.rs b/gen/discovery1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/discovery1-cli/src/cmn.rs +++ b/gen/discovery1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/discovery1-cli/src/main.rs b/gen/discovery1-cli/src/main.rs index d2ef6d8a0f..2af64066eb 100644 --- a/gen/discovery1-cli/src/main.rs +++ b/gen/discovery1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -29,6 +30,12 @@ Configuration: 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. "); mod cmn; @@ -52,7 +59,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.apis().get_rest(&self.opt.arg_api, &self.opt.arg_version); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -84,8 +91,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -96,7 +102,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.apis().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "preferred" => { call = call.preferred(arg_from_str(value.unwrap_or("false"), err, "preferred", "boolean")); @@ -134,8 +140,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -175,21 +180,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "discovery1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "discovery1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "discovery1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "discovery1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Discovery::new(hyper::Client::new(), auth), + hub: api::Discovery::new(client, auth), }; match engine._doit(true) { @@ -209,12 +230,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/discovery1/Cargo.toml b/gen/discovery1/Cargo.toml index e39a25ecd6..93660a0b9c 100644 --- a/gen/discovery1/Cargo.toml +++ b/gen/discovery1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-discovery1" version = "0.1.5+00000000" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/discovery/" diff --git a/gen/discovery1/src/cmn.rs b/gen/discovery1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/discovery1/src/cmn.rs +++ b/gen/discovery1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/discovery1/src/lib.rs b/gen/discovery1/src/lib.rs index 3966af3f3e..c19d85461c 100644 --- a/gen/discovery1/src/lib.rs +++ b/gen/discovery1/src/lib.rs @@ -305,7 +305,7 @@ impl<'a, C, A> Discovery<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestDescriptionAuthOauth2 { /// Available OAuth 2.0 scopes. - pub scopes: HashMap<String, RestDescriptionAuthOauth2Scopes>, + pub scopes: Option<HashMap<String, RestDescriptionAuthOauth2Scopes>>, } impl NestedType for RestDescriptionAuthOauth2 {} @@ -320,7 +320,7 @@ impl Part for RestDescriptionAuthOauth2 {} pub struct RestMethodResponse { /// Schema ID for the response schema. #[serde(rename="$ref")] - pub ref_: String, + pub ref_: Option<String>, } impl NestedType for RestMethodResponse {} @@ -334,9 +334,9 @@ impl Part for RestMethodResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JsonSchemaVariant { /// The map of discriminant value to schema to use for parsing.. - pub map: Vec<JsonSchemaVariantMap>, + pub map: Option<Vec<JsonSchemaVariantMap>>, /// The name of the type discriminant property. - pub discriminant: String, + pub discriminant: Option<String>, } impl NestedType for JsonSchemaVariant {} @@ -350,9 +350,9 @@ impl Part for JsonSchemaVariant {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestMethodMediaUploadProtocols { /// Supports uploading as a single HTTP request. - pub simple: RestMethodMediaUploadProtocolsSimple, + pub simple: Option<RestMethodMediaUploadProtocolsSimple>, /// Supports the Resumable Media Upload protocol. - pub resumable: RestMethodMediaUploadProtocolsResumable, + pub resumable: Option<RestMethodMediaUploadProtocolsResumable>, } impl NestedType for RestMethodMediaUploadProtocols {} @@ -366,9 +366,9 @@ impl Part for RestMethodMediaUploadProtocols {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestMethodMediaUploadProtocolsResumable { /// The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level. - pub path: String, + pub path: Option<String>, /// True if this endpoint supports uploading multipart media. - pub multipart: bool, + pub multipart: Option<bool>, } impl NestedType for RestMethodMediaUploadProtocolsResumable {} @@ -382,7 +382,7 @@ impl Part for RestMethodMediaUploadProtocolsResumable {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JsonSchemaAnnotations { /// A list of methods for which this property is required on requests. - pub required: Vec<String>, + pub required: Option<Vec<String>>, } impl NestedType for JsonSchemaAnnotations {} @@ -396,10 +396,10 @@ impl Part for JsonSchemaAnnotations {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JsonSchemaVariantMap { /// no description provided - pub type_value: String, + pub type_value: Option<String>, /// no description provided #[serde(rename="$ref")] - pub ref_: String, + pub ref_: Option<String>, } impl NestedType for JsonSchemaVariantMap {} @@ -413,9 +413,9 @@ impl Part for JsonSchemaVariantMap {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestDescriptionIcons { /// The URL of the 32x32 icon. - pub x32: String, + pub x32: Option<String>, /// The URL of the 16x16 icon. - pub x16: String, + pub x16: Option<String>, } impl NestedType for RestDescriptionIcons {} @@ -429,43 +429,43 @@ impl Part for RestDescriptionIcons {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestMethod { /// OAuth 2.0 scopes applicable to this method. - pub scopes: Vec<String>, + pub scopes: Option<Vec<String>>, /// Description of this method. - pub description: String, + pub description: Option<String>, /// Details for all parameters in this method. - pub parameters: HashMap<String, JsonSchema>, + pub parameters: Option<HashMap<String, JsonSchema>>, /// Whether this method supports media uploads. #[serde(rename="supportsMediaUpload")] - pub supports_media_upload: bool, + pub supports_media_upload: Option<bool>, /// Whether this method requires an ETag to be specified. The ETag is sent as an HTTP If-Match or If-None-Match header. #[serde(rename="etagRequired")] - pub etag_required: bool, + pub etag_required: Option<bool>, /// Media upload parameters. #[serde(rename="mediaUpload")] - pub media_upload: RestMethodMediaUpload, + pub media_upload: Option<RestMethodMediaUpload>, /// The schema for the request. - pub request: RestMethodRequest, + pub request: Option<RestMethodRequest>, /// Indicates that downloads from this method should use the download service URL (i.e. "/download"). Only applies if the method supports media download. #[serde(rename="useMediaDownloadService")] - pub use_media_download_service: bool, + pub use_media_download_service: Option<bool>, /// HTTP method used by this method. #[serde(rename="httpMethod")] - pub http_method: String, + pub http_method: Option<String>, /// Whether this method supports subscriptions. #[serde(rename="supportsSubscription")] - pub supports_subscription: bool, + pub supports_subscription: Option<bool>, /// Ordered list of required parameters, serves as a hint to clients on how to structure their method signatures. The array is ordered such that the "most-significant" parameter appears first. #[serde(rename="parameterOrder")] - pub parameter_order: Vec<String>, + pub parameter_order: Option<Vec<String>>, /// A unique ID for this method. This property can be used to match methods between different versions of Discovery. - pub id: String, + pub id: Option<String>, /// The URI path of this REST method. Should be used in conjunction with the basePath property at the api-level. - pub path: String, + pub path: Option<String>, /// The schema for the response. - pub response: RestMethodResponse, + pub response: Option<RestMethodResponse>, /// Whether this method supports media downloads. #[serde(rename="supportsMediaDownload")] - pub supports_media_download: bool, + pub supports_media_download: Option<bool>, } impl Part for RestMethod {} @@ -483,72 +483,72 @@ impl Part for RestMethod {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestDescription { /// The protocol described by this document. - pub protocol: String, + pub protocol: Option<String>, /// API-level methods for this API. - pub methods: HashMap<String, RestMethod>, + pub methods: Option<HashMap<String, RestMethod>>, /// Labels for the status of this API, such as labs or deprecated. - pub labels: Vec<String>, + pub labels: Option<Vec<String>>, /// The kind for this response. - pub kind: String, + pub kind: Option<String>, /// Indicates how the API name should be capitalized and split into various parts. Useful for generating pretty class names. #[serde(rename="canonicalName")] - pub canonical_name: String, + pub canonical_name: Option<String>, /// The name of the owner of this API. See ownerDomain. #[serde(rename="ownerName")] - pub owner_name: String, + pub owner_name: Option<String>, /// A link to human readable documentation for the API. #[serde(rename="documentationLink")] - pub documentation_link: String, + pub documentation_link: Option<String>, /// Authentication information. - pub auth: RestDescriptionAuth, + pub auth: Option<RestDescriptionAuth>, /// The package of the owner of this API. See ownerDomain. #[serde(rename="packagePath")] - pub package_path: String, + pub package_path: Option<String>, /// The path for REST batch requests. #[serde(rename="batchPath")] - pub batch_path: String, + pub batch_path: Option<String>, /// The ID of this API. - pub id: String, + pub id: Option<String>, /// A list of supported features for this API. - pub features: Vec<String>, + pub features: Option<Vec<String>>, /// The domain of the owner of this API. Together with the ownerName and a packagePath values, this can be used to generate a library for this API which would have a unique fully qualified name. #[serde(rename="ownerDomain")] - pub owner_domain: String, + pub owner_domain: Option<String>, /// The root URL under which all API services live. #[serde(rename="rootUrl")] - pub root_url: String, + pub root_url: Option<String>, /// The name of this API. - pub name: String, + pub name: Option<String>, /// Common parameters that apply across all apis. - pub parameters: HashMap<String, JsonSchema>, + pub parameters: Option<HashMap<String, JsonSchema>>, /// Links to 16x16 and 32x32 icons representing the API. - pub icons: RestDescriptionIcons, + pub icons: Option<RestDescriptionIcons>, /// The description of this API. - pub description: String, + pub description: Option<String>, /// The title of this API. - pub title: String, + pub title: Option<String>, /// [DEPRECATED] The base URL for REST requests. #[serde(rename="baseUrl")] - pub base_url: String, + pub base_url: Option<String>, /// The ETag for this response. - pub etag: String, + pub etag: Option<String>, /// The version of this API. - pub version: String, + pub version: Option<String>, /// The base path for all REST requests. #[serde(rename="servicePath")] - pub service_path: String, + pub service_path: Option<String>, /// Indicate the version of the Discovery API used to generate this doc. #[serde(rename="discoveryVersion")] - pub discovery_version: String, + pub discovery_version: Option<String>, /// The schemas for this API. - pub schemas: HashMap<String, JsonSchema>, + pub schemas: Option<HashMap<String, JsonSchema>>, /// [DEPRECATED] The base path for REST requests. #[serde(rename="basePath")] - pub base_path: String, + pub base_path: Option<String>, /// The resources in this API. - pub resources: HashMap<String, RestResource>, + pub resources: Option<HashMap<String, RestResource>>, /// The version of this API. - pub revision: String, + pub revision: Option<String>, } impl ResponseResult for RestDescription {} @@ -562,11 +562,11 @@ impl ResponseResult for RestDescription {} pub struct RestMethodMediaUpload { /// Maximum size of a media upload, such as "1MB", "2GB" or "3TB". #[serde(rename="maxSize")] - pub max_size: String, + pub max_size: Option<String>, /// MIME Media Ranges for acceptable media uploads to this method. - pub accept: Vec<String>, + pub accept: Option<Vec<String>>, /// Supported upload protocols. - pub protocols: RestMethodMediaUploadProtocols, + pub protocols: Option<RestMethodMediaUploadProtocols>, } impl NestedType for RestMethodMediaUpload {} @@ -585,12 +585,12 @@ impl Part for RestMethodMediaUpload {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectoryList { /// The individual directory entries. One entry per api/version pair. - pub items: Vec<DirectoryListItems>, + pub items: Option<Vec<DirectoryListItems>>, /// Indicate the version of the Discovery API used to generate this doc. #[serde(rename="discoveryVersion")] - pub discovery_version: String, + pub discovery_version: Option<String>, /// The kind for this response. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for DirectoryList {} @@ -603,51 +603,51 @@ impl ResponseResult for DirectoryList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JsonSchema { /// A description of this object. - pub description: String, + pub description: Option<String>, /// An additional regular expression or key that helps constrain the value. For more details see: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23 - pub format: String, + pub format: Option<String>, /// Values this parameter may take (if it is an enum). #[serde(rename="enum")] - pub enum_: Vec<String>, + pub enum_: Option<Vec<String>>, /// In a variant data type, the value of one property is used to determine how to interpret the entire entity. Its value must exist in a map of descriminant values to schema names. - pub variant: JsonSchemaVariant, + pub variant: Option<JsonSchemaVariant>, /// The descriptions for the enums. Each position maps to the corresponding value in the "enum" array. #[serde(rename="enumDescriptions")] - pub enum_descriptions: Vec<String>, + pub enum_descriptions: Option<Vec<String>>, /// The value is read-only, generated by the service. The value cannot be modified by the client. If the value is included in a POST, PUT, or PATCH request, it is ignored by the service. #[serde(rename="readOnly")] - pub read_only: bool, + pub read_only: Option<bool>, /// The minimum value of this parameter. - pub minimum: String, + pub minimum: Option<String>, /// Whether this parameter may appear multiple times. - pub repeated: bool, + pub repeated: Option<bool>, /// Unique identifier for this schema. - pub id: String, + pub id: Option<String>, /// A reference to another schema. The value of this property is the "id" of another schema. #[serde(rename="$ref")] - pub ref_: String, + pub ref_: Option<String>, /// The default value of this property (if one exists). - pub default: String, + pub default: Option<String>, /// If this is a schema for an array, this property is the schema for each element in the array. - pub items: Option<Box<JsonSchema>>, + pub items: Option<Option<Box<JsonSchema>>>, /// Whether the parameter is required. - pub required: bool, + pub required: Option<bool>, /// The maximum value of this parameter. - pub maximum: String, + pub maximum: Option<String>, /// If this is a schema for an object, list the schema for each property of this object. - pub properties: HashMap<String, JsonSchema>, + pub properties: Option<HashMap<String, JsonSchema>>, /// Whether this parameter goes in the query or the path for REST requests. - pub location: String, + pub location: Option<String>, /// The regular expression this parameter must conform to. Uses Java 6 regex format: http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html - pub pattern: String, + pub pattern: Option<String>, /// If this is a schema for an object, this property is the schema for any additional properties with dynamic keys on this object. #[serde(rename="additionalProperties")] - pub additional_properties: Option<Box<JsonSchema>>, + pub additional_properties: Option<Option<Box<JsonSchema>>>, /// The value type for this schema. A list of values can be found here: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1 #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Additional information about this property. - pub annotations: JsonSchemaAnnotations, + pub annotations: Option<JsonSchemaAnnotations>, } impl Part for JsonSchema {} @@ -660,32 +660,32 @@ impl Part for JsonSchema {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectoryListItems { /// The kind for this response. - pub kind: String, + pub kind: Option<String>, /// The URL for the discovery REST document. #[serde(rename="discoveryRestUrl")] - pub discovery_rest_url: String, + pub discovery_rest_url: Option<String>, /// The description of this API. - pub description: String, + pub description: Option<String>, /// Links to 16x16 and 32x32 icons representing the API. - pub icons: DirectoryListItemsIcons, + pub icons: Option<DirectoryListItemsIcons>, /// Labels for the status of this API, such as labs or deprecated. - pub labels: Vec<String>, + pub labels: Option<Vec<String>>, /// True if this version is the preferred version to use. - pub preferred: bool, + pub preferred: Option<bool>, /// A link to the discovery document. #[serde(rename="discoveryLink")] - pub discovery_link: String, + pub discovery_link: Option<String>, /// The version of the API. - pub version: String, + pub version: Option<String>, /// The title of this API. - pub title: String, + pub title: Option<String>, /// A link to human readable documentation for the API. #[serde(rename="documentationLink")] - pub documentation_link: String, + pub documentation_link: Option<String>, /// The id of this API. - pub id: String, + pub id: Option<String>, /// The name of the API. - pub name: String, + pub name: Option<String>, } impl NestedType for DirectoryListItems {} @@ -699,7 +699,7 @@ impl Part for DirectoryListItems {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestDescriptionAuth { /// OAuth 2.0 authentication information. - pub oauth2: RestDescriptionAuthOauth2, + pub oauth2: Option<RestDescriptionAuthOauth2>, } impl NestedType for RestDescriptionAuth {} @@ -713,7 +713,7 @@ impl Part for RestDescriptionAuth {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestDescriptionAuthOauth2Scopes { /// Description of scope. - pub description: String, + pub description: Option<String>, } impl NestedType for RestDescriptionAuthOauth2Scopes {} @@ -727,9 +727,9 @@ impl Part for RestDescriptionAuthOauth2Scopes {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectoryListItemsIcons { /// The URL of the 32x32 icon. - pub x32: String, + pub x32: Option<String>, /// The URL of the 16x16 icon. - pub x16: String, + pub x16: Option<String>, } impl NestedType for DirectoryListItemsIcons {} @@ -744,10 +744,10 @@ impl Part for DirectoryListItemsIcons {} pub struct RestMethodRequest { /// parameter name. #[serde(rename="parameterName")] - pub parameter_name: String, + pub parameter_name: Option<String>, /// Schema ID for the request schema. #[serde(rename="$ref")] - pub ref_: String, + pub ref_: Option<String>, } impl NestedType for RestMethodRequest {} @@ -761,9 +761,9 @@ impl Part for RestMethodRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestResource { /// Methods on this resource. - pub methods: HashMap<String, RestMethod>, + pub methods: Option<HashMap<String, RestMethod>>, /// Sub-resources on this resource. - pub resources: HashMap<String, RestResource>, + pub resources: Option<HashMap<String, RestResource>>, } impl Part for RestResource {} @@ -776,9 +776,9 @@ impl Part for RestResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RestMethodMediaUploadProtocolsSimple { /// The URI path to be used for upload. Should be used in conjunction with the basePath property at the api-level. - pub path: String, + pub path: Option<String>, /// True if this endpoint supports upload multipart media. - pub multipart: bool, + pub multipart: Option<bool>, } impl NestedType for RestMethodMediaUploadProtocolsSimple {} @@ -940,18 +940,6 @@ impl<'a, C, A> ApiGetRestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/discovery/v1/apis/{api}/{version}/rest".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } for &(find_this, param_name) in [("{api}", "api"), ("{version}", "version")].iter() { let mut replace_with: Option<&str> = None; @@ -1169,18 +1157,6 @@ impl<'a, C, A> ApiListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/discovery/v1/apis".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } if params.len() > 0 { diff --git a/gen/dns1_beta1-cli/Cargo.toml b/gen/dns1-cli/Cargo.toml similarity index 71% rename from gen/dns1_beta1-cli/Cargo.toml rename to gen/dns1-cli/Cargo.toml index 3b3d5b723d..9da48f56b3 100644 --- a/gen/dns1_beta1-cli/Cargo.toml +++ b/gen/dns1-cli/Cargo.toml @@ -3,18 +3,18 @@ # DO NOT EDIT ! [package] -name = "google-dns1_beta1-cli" -version = "0.0.1+20150114" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dns (protocol v1beta1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dns1_beta1-cli" +name = "google-dns1-cli" +version = "0.0.1+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" homepage = "https://developers.google.com/cloud-dns" -documentation = "http://byron.github.io/google-apis-rs/google_dns1_beta1_cli" +documentation = "http://byron.github.io/google-apis-rs/google_dns1_cli" license = "MIT" keywords = ["dns", "google", "cli"] [[bin]] -name = "dns1-beta1" +name = "dns1" [dependencies] hyper = "*" @@ -23,8 +23,9 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" -[dependencies.google-dns1_beta1] -path = "../dns1_beta1" +[dependencies.google-dns1] +path = "../dns1" diff --git a/gen/admin2_email_migration-cli/LICENSE.md b/gen/dns1-cli/LICENSE.md similarity index 100% rename from gen/admin2_email_migration-cli/LICENSE.md rename to gen/dns1-cli/LICENSE.md diff --git a/gen/drive2-cli/README.md b/gen/dns1-cli/README.md similarity index 56% rename from gen/drive2-cli/README.md rename to gen/dns1-cli/README.md index f608701e6a..c6cee63985 100644 --- a/gen/drive2-cli/README.md +++ b/gen/dns1-cli/README.md @@ -1,4 +1,4 @@ -# HELLO DRIVE:V2 +# HELLO DNS:V1 Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/dns1_beta1-cli/mkdocs.yml b/gen/dns1-cli/mkdocs.yml similarity index 85% rename from gen/dns1_beta1-cli/mkdocs.yml rename to gen/dns1-cli/mkdocs.yml index 5ec92d0eb2..bd14ac1162 100644 --- a/gen/dns1_beta1-cli/mkdocs.yml +++ b/gen/dns1-cli/mkdocs.yml @@ -1,8 +1,8 @@ -site_name: dns v0.0.1+20150114 -site_url: http://byron.github.io/google-apis-rs/google-dns1_beta1-cli +site_name: dns v0.0.1+20150218 +site_url: http://byron.github.io/google-apis-rs/google-dns1-cli site_description: Write integrating applications with bcore -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dns1_beta1-cli +repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/dns1-cli docs_dir: docs site_dir: build_html diff --git a/gen/adsensehost4d1-cli/src/cmn.rs b/gen/dns1-cli/src/cmn.rs similarity index 84% rename from gen/adsensehost4d1-cli/src/cmn.rs rename to gen/dns1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/adsensehost4d1-cli/src/cmn.rs +++ b/gen/dns1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/dns1_beta1-cli/src/main.rs b/gen/dns1-cli/src/main.rs similarity index 82% rename from gen/dns1_beta1-cli/src/main.rs rename to gen/dns1-cli/src/main.rs index cda769750a..807caab1e9 100644 --- a/gen/dns1_beta1-cli/src/main.rs +++ b/gen/dns1-cli/src/main.rs @@ -7,27 +7,28 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; extern crate mime; -extern crate google_dns1_beta1 as api; +extern crate google_dns1 as api; use std::env; use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - dns1-beta1 [options] changes create <project> <managed-zone> -r <kv>... [-p <v>]... [-o <out>] - dns1-beta1 [options] changes get <project> <managed-zone> <change-id> [-p <v>]... [-o <out>] - dns1-beta1 [options] changes list <project> <managed-zone> [-p <v>]... [-o <out>] - dns1-beta1 [options] managed-zones create <project> -r <kv>... [-p <v>]... [-o <out>] - dns1-beta1 [options] managed-zones delete <project> <managed-zone> [-p <v>]... - dns1-beta1 [options] managed-zones get <project> <managed-zone> [-p <v>]... [-o <out>] - dns1-beta1 [options] managed-zones list <project> [-p <v>]... [-o <out>] - dns1-beta1 [options] projects get <project> [-p <v>]... [-o <out>] - dns1-beta1 [options] resource-record-sets list <project> <managed-zone> [-p <v>]... [-o <out>] - dns1-beta1 --help + 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> @@ -40,6 +41,12 @@ Configuration: 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. "); mod cmn; @@ -61,10 +68,10 @@ struct Engine { impl Engine { fn _changes_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Change = Default::default(); + let mut request = api::Change::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -84,9 +91,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -120,8 +128,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -132,7 +139,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.changes().get(&self.opt.arg_project, &self.opt.arg_managed_zone, &self.opt.arg_change_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -164,8 +171,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -176,7 +182,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.changes().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -220,8 +226,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -230,10 +235,10 @@ impl Engine { fn _managed_zones_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ManagedZone = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -253,9 +258,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -268,9 +274,9 @@ impl Engine { }, "name-servers" => { if request.name_servers.is_none() { - request.name_servers = Some(Default::default()); + request.name_servers = Some(Default::default()); } - request.name_servers.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.name_servers.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); @@ -304,8 +310,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -316,7 +321,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.managed_zones().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -347,7 +352,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -358,7 +362,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.managed_zones().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -390,8 +394,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -402,7 +405,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.managed_zones().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -440,8 +443,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -452,7 +454,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().get(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -484,8 +486,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -496,7 +497,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.resource_record_sets().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); @@ -540,8 +541,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -563,7 +563,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_managed_zones { + } + else if self.opt.cmd_managed_zones { if self.opt.cmd_create { call_result = self._managed_zones_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -575,13 +576,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_projects { + } + else if self.opt.cmd_projects { if self.opt.cmd_get { call_result = self._projects_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_resource_record_sets { + } + else if self.opt.cmd_resource_record_sets { if self.opt.cmd_list { call_result = self._resource_record_sets_list(dry_run, &mut err); } else { @@ -607,21 +610,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "dns1-beta1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "dns1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "dns1-beta1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "dns1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Dns::new(hyper::Client::new(), auth), + hub: api::Dns::new(client, auth), }; match engine._doit(true) { @@ -641,12 +660,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/dns1_beta1/Cargo.toml b/gen/dns1/Cargo.toml similarity index 79% rename from gen/dns1_beta1/Cargo.toml rename to gen/dns1/Cargo.toml index 7ba97e04bf..3c837ce947 100644 --- a/gen/dns1_beta1/Cargo.toml +++ b/gen/dns1/Cargo.toml @@ -3,13 +3,13 @@ # DO NOT EDIT ! [package] -name = "google-dns1_beta1" -version = "0.1.5+20150114" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with dns (protocol v1beta1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/dns1_beta1" +name = "google-dns1" +version = "0.1.5+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" homepage = "https://developers.google.com/cloud-dns" -documentation = "http://byron.github.io/google-apis-rs/google_dns1_beta1" +documentation = "http://byron.github.io/google-apis-rs/google_dns1" license = "MIT" keywords = ["dns", "google", "protocol", "web", "api"] diff --git a/gen/adsensehost4d1-cli/LICENSE.md b/gen/dns1/LICENSE.md similarity index 100% rename from gen/adsensehost4d1-cli/LICENSE.md rename to gen/dns1/LICENSE.md diff --git a/gen/dns1_beta1/README.md b/gen/dns1/README.md similarity index 66% rename from gen/dns1_beta1/README.md rename to gen/dns1/README.md index b635556bd3..22e29d70c2 100644 --- a/gen/dns1_beta1/README.md +++ b/gen/dns1/README.md @@ -3,24 +3,24 @@ DO NOT EDIT ! This file was generated automatically from 'src/mako/api/README.md.mako' DO NOT EDIT ! --> -The `google-dns1_beta1` library allows access to all features of the *Google dns* service. +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+20150114*, where *20150114* is the exact revision of the *dns:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +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*. -Everything else about the *dns* *v1_beta1* API can be found at the +Everything else about the *dns* *v1* API can be found at the [official documentation site](https://developers.google.com/cloud-dns). # Features -Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.Dns.html) ... +Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_dns1/struct.Dns.html) ... -* [changes](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.Change.html) - * [*create*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ChangeCreateCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ChangeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ChangeListCall.html) -* [managed zones](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ManagedZone.html) - * [*create*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ManagedZoneCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ManagedZoneDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ManagedZoneGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ManagedZoneListCall.html) -* [projects](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.Project.html) - * [*get*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ProjectGetCall.html) -* [resource record sets](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ResourceRecordSet.html) - * [*list*](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.ResourceRecordSetListCall.html) +* [changes](http://byron.github.io/google-apis-rs/google_dns1/struct.Change.html) + * [*create*](http://byron.github.io/google-apis-rs/google_dns1/struct.ChangeCreateCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dns1/struct.ChangeGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dns1/struct.ChangeListCall.html) +* [managed zones](http://byron.github.io/google-apis-rs/google_dns1/struct.ManagedZone.html) + * [*create*](http://byron.github.io/google-apis-rs/google_dns1/struct.ManagedZoneCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_dns1/struct.ManagedZoneDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_dns1/struct.ManagedZoneGetCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_dns1/struct.ManagedZoneListCall.html) +* [projects](http://byron.github.io/google-apis-rs/google_dns1/struct.Project.html) + * [*get*](http://byron.github.io/google-apis-rs/google_dns1/struct.ProjectGetCall.html) +* [resource record sets](http://byron.github.io/google-apis-rs/google_dns1/struct.ResourceRecordSet.html) + * [*list*](http://byron.github.io/google-apis-rs/google_dns1/struct.ResourceRecordSetListCall.html) @@ -29,17 +29,17 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g The API is structured into the following primary items: -* **[Hub](http://byron.github.io/google-apis-rs/google_dns1_beta1/struct.Dns.html)** +* **[Hub](http://byron.github.io/google-apis-rs/google_dns1/struct.Dns.html)** * a central object to maintain state and allow accessing all *Activities* - * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.MethodsBuilder.html) which in turn - allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.CallBuilder.html) -* **[Resources](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Resource.html)** + * creates [*Method Builders*](http://byron.github.io/google-apis-rs/google_dns1/trait.MethodsBuilder.html) which in turn + allow access to individual [*Call Builders*](http://byron.github.io/google-apis-rs/google_dns1/trait.CallBuilder.html) +* **[Resources](http://byron.github.io/google-apis-rs/google_dns1/trait.Resource.html)** * primary types that you can apply *Activities* to * a collection of properties and *Parts* - * **[Parts](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Part.html)** + * **[Parts](http://byron.github.io/google-apis-rs/google_dns1/trait.Part.html)** * a collection of properties * never directly used in *Activities* -* **[Activities](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.CallBuilder.html)** +* **[Activities](http://byron.github.io/google-apis-rs/google_dns1/trait.CallBuilder.html)** * operations to apply to *Resources* All *structures* are marked with applicable traits to further categorize them and ease browsing. @@ -72,7 +72,7 @@ To use this library, you would put the following lines into your `Cargo.toml` fi ```toml [dependencies] -google-dns1_beta1 = "*" +google-dns1 = "*" ``` ## A complete example @@ -80,11 +80,11 @@ google-dns1_beta1 = "*" ```Rust extern crate hyper; extern crate yup_oauth2 as oauth2; -extern crate google_dns1_beta1 as dns1_beta1; -use dns1_beta1::{Result, Error}; +extern crate google_dns1 as dns1; +use dns1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -use dns1_beta1::Dns; +use dns1::Dns; // Get an ApplicationSecret instance by some means. It contains the `client_id` and // `client_secret`, among other things. @@ -125,17 +125,17 @@ match result { ``` ## Handling Errors -All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_dns1_beta1/enum.Result.html) enumeration as return value of +All errors produced by the system are provided either as [Result](http://byron.github.io/google-apis-rs/google_dns1/enum.Result.html) enumeration as return value of the doit() methods, or handed as possibly intermediate results to either the -[Hub Delegate](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dns1_beta1/../yup-oauth2/trait.AuthenticatorDelegate.html). +[Hub Delegate](http://byron.github.io/google-apis-rs/google_dns1/trait.Delegate.html), or the [Authenticator Delegate](http://byron.github.io/google-apis-rs/google_dns1/../yup-oauth2/trait.AuthenticatorDelegate.html). When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This makes the system potentially resilient to all kinds of errors. ## Uploads and Downloads -If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google_dns1_beta1/enum.Result.html), should be +If a method supports downloads, the response body, which is part of the [Result](http://byron.github.io/google-apis-rs/google_dns1/enum.Result.html), should be read by you to obtain the media. -If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.ResponseResult.html), it will return that by default. +If such a method also supports a [Response Result](http://byron.github.io/google-apis-rs/google_dns1/trait.ResponseResult.html), it will return that by default. You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making this call: `.param("alt", "media")`. @@ -145,29 +145,29 @@ Methods supporting uploads can do so using up to 2 different protocols: ## Customization and Callbacks -You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Delegate.html) to the -[Method Builder](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.CallBuilder.html) before making the final `doit()` call. +You may alter the way an `doit()` method is called by providing a [delegate](http://byron.github.io/google-apis-rs/google_dns1/trait.Delegate.html) to the +[Method Builder](http://byron.github.io/google-apis-rs/google_dns1/trait.CallBuilder.html) before making the final `doit()` call. Respective methods will be called to provide progress information, as well as determine whether the system should retry on failure. -The [delegate trait](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. +The [delegate trait](http://byron.github.io/google-apis-rs/google_dns1/trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. ## Optional Parts in Server-Requests -All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.RequestValue.html) and -[decodable](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses +All structures provided by this library are made to be [enocodable](http://byron.github.io/google-apis-rs/google_dns1/trait.RequestValue.html) and +[decodable](http://byron.github.io/google-apis-rs/google_dns1/trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses are valid. -Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.Part.html) which are identifiable by name, which will be sent to +Most optionals are are considered [Parts](http://byron.github.io/google-apis-rs/google_dns1/trait.Part.html) which are identifiable by name, which will be sent to the server to indicate either the set parts of the request or the desired parts in the response. ## Builder Arguments -Using [method builders](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. +Using [method builders](http://byron.github.io/google-apis-rs/google_dns1/trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. These will always take a single argument, for which the following statements are true. * [PODs][wiki-pod] are handed by copy * strings are passed as `&str` -* [request values](http://byron.github.io/google-apis-rs/google_dns1_beta1/trait.RequestValue.html) are borrowed +* [request values](http://byron.github.io/google-apis-rs/google_dns1/trait.RequestValue.html) are borrowed Arguments will always be copied or cloned into the builder, to make them independent of their original life times. @@ -176,7 +176,7 @@ Arguments will always be copied or cloned into the builder, to make them indepen [google-go-api]: https://github.com/google/google-api-go-client # License -The **dns1_beta1** library was generated by Sebastian Thiel, and is placed +The **dns1** library was generated by Sebastian Thiel, and is placed under the *MIT* license. You can read the full text at the repository's [license file][repo-license]. diff --git a/gen/dfareporting2/src/cmn.rs b/gen/dns1/src/cmn.rs similarity index 97% rename from gen/dfareporting2/src/cmn.rs rename to gen/dns1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/dfareporting2/src/cmn.rs +++ b/gen/dns1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/dns1_beta1/src/lib.rs b/gen/dns1/src/lib.rs similarity index 94% rename from gen/dns1_beta1/src/lib.rs rename to gen/dns1/src/lib.rs index 777775cd0c..6f9faf1b9e 100644 --- a/gen/dns1_beta1/src/lib.rs +++ b/gen/dns1/src/lib.rs @@ -2,11 +2,11 @@ // 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+20150114*, where *20150114* is the exact revision of the *dns:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.5*. +//! 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*. //! -//! Everything else about the *dns* *v1_beta1* API can be found at the +//! Everything else about the *dns* *v1* API can be found at the //! [official documentation site](https://developers.google.com/cloud-dns). -//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dns1_beta1). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/dns1). //! # Features //! //! Handle the following *Resources* with ease from the central [hub](struct.Dns.html) ... @@ -72,7 +72,7 @@ //! //! ```toml //! [dependencies] -//! google-dns1_beta1 = "*" +//! google-dns1 = "*" //! ``` //! //! ## A complete example @@ -80,12 +80,12 @@ //! ```test_harness,no_run //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; -//! extern crate google_dns1_beta1 as dns1_beta1; -//! use dns1_beta1::{Result, Error}; +//! extern crate google_dns1 as dns1; +//! use dns1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -//! use dns1_beta1::Dns; +//! use dns1::Dns; //! //! // Get an ApplicationSecret instance by some means. It contains the `client_id` and //! // `client_secret`, among other things. @@ -259,12 +259,12 @@ impl Default for Scope { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dns1_beta1 as dns1_beta1; -/// use dns1_beta1::{Result, Error}; +/// extern crate google_dns1 as dns1; +/// use dns1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dns1_beta1::Dns; +/// use dns1::Dns; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. @@ -402,11 +402,11 @@ impl ResponseResult for ManagedZone {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResourceRecordSet { - /// As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) + /// As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1). pub rrdatas: Option<Vec<String>>, /// Identifies what kind of resource this is. Value: the fixed string "dns#resourceRecordSet". pub kind: Option<String>, - /// One of A, AAAA, SOA, MX, NS, TXT + /// The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on. #[serde(rename="type")] pub type_: Option<String>, /// For example, www.example.com. @@ -426,24 +426,24 @@ impl Resource for ResourceRecordSet {} pub struct Quota { /// Maximum allowed number of ResourceRecordSets per zone in the project. #[serde(rename="rrsetsPerManagedZone")] - pub rrsets_per_managed_zone: i32, + pub rrsets_per_managed_zone: Option<i32>, /// Identifies what kind of resource this is. Value: the fixed string "dns#quota". - pub kind: String, + pub kind: Option<String>, /// Maximum allowed number of ResourceRecordSets to add per ChangesCreateRequest. #[serde(rename="rrsetAdditionsPerChange")] - pub rrset_additions_per_change: i32, + pub rrset_additions_per_change: Option<i32>, /// Maximum allowed size for total rrdata in one ChangesCreateRequest in bytes. #[serde(rename="totalRrdataSizePerChange")] - pub total_rrdata_size_per_change: i32, + pub total_rrdata_size_per_change: Option<i32>, /// Maximum allowed number of ResourceRecords per ResourceRecordSet. #[serde(rename="resourceRecordsPerRrset")] - pub resource_records_per_rrset: i32, + pub resource_records_per_rrset: Option<i32>, /// Maximum allowed number of ResourceRecordSets to delete per ChangesCreateRequest. #[serde(rename="rrsetDeletionsPerChange")] - pub rrset_deletions_per_change: i32, + pub rrset_deletions_per_change: Option<i32>, /// Maximum allowed number of managed zones in the project. #[serde(rename="managedZones")] - pub managed_zones: i32, + pub managed_zones: Option<i32>, } impl Part for Quota {} @@ -461,13 +461,13 @@ impl Part for Quota {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Project { /// Quotas assigned to this project (output only). - pub quota: Quota, + pub quota: Option<Quota>, /// Identifies what kind of resource this is. Value: the fixed string "dns#project". - pub kind: String, + pub kind: Option<String>, /// User assigned unique identifier for the resource (output only). - pub id: String, + pub id: Option<String>, /// Unique numeric identifier for the resource; defined by the server (output only). - pub number: String, + pub number: Option<String>, } impl Resource for Project {} @@ -489,11 +489,11 @@ pub struct ChangesListResponse { /// /// In this way you can retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned will be an inconsistent view of the collection. There is no way to retrieve a "snapshot" of collections larger than the maximum page size. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// The requested changes. - pub changes: Vec<Change>, + pub changes: Option<Vec<Change>>, } impl ResponseResult for ChangesListResponse {} @@ -514,12 +514,12 @@ pub struct ManagedZonesListResponse { /// /// In this way you can retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned will be an inconsistent view of the collection. There is no way to retrieve a consistent snapshot of a collection larger than the maximum page size. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// The managed zone resources. #[serde(rename="managedZones")] - pub managed_zones: Vec<ManagedZone>, + pub managed_zones: Option<Vec<ManagedZone>>, } impl ResponseResult for ManagedZonesListResponse {} @@ -540,7 +540,7 @@ impl ResponseResult for ManagedZonesListResponse {} pub struct Change { /// Which ResourceRecordSets to remove? Must match existing data exactly. pub deletions: Option<Vec<ResourceRecordSet>>, - /// Status of the operation. Can be one of the following: "PENDING" or "DONE" (output only). + /// Status of the operation (output only). pub status: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "dns#change". pub kind: Option<String>, @@ -573,11 +573,11 @@ pub struct ResourceRecordSetsListResponse { /// /// In this way you can retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned will be an inconsistent view of the collection. There is no way to retrieve a consistent snapshot of a collection larger than the maximum page size. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The resource record set resources. - pub rrsets: Vec<ResourceRecordSet>, + pub rrsets: Option<Vec<ResourceRecordSet>>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for ResourceRecordSetsListResponse {} @@ -598,12 +598,12 @@ impl ResponseResult for ResourceRecordSetsListResponse {} /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dns1_beta1 as dns1_beta1; +/// extern crate google_dns1 as dns1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dns1_beta1::Dns; +/// use dns1::Dns; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -704,12 +704,12 @@ impl<'a, C, A> ChangeMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dns1_beta1 as dns1_beta1; +/// extern crate google_dns1 as dns1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dns1_beta1::Dns; +/// use dns1::Dns; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -821,12 +821,12 @@ impl<'a, C, A> ManagedZoneMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dns1_beta1 as dns1_beta1; +/// extern crate google_dns1 as dns1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dns1_beta1::Dns; +/// use dns1::Dns; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -885,12 +885,12 @@ impl<'a, C, A> ResourceRecordSetMethods<'a, C, A> { /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; -/// extern crate google_dns1_beta1 as dns1_beta1; +/// extern crate google_dns1 as dns1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use dns1_beta1::Dns; +/// use dns1::Dns; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -951,12 +951,12 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; -/// use dns1_beta1::Change; +/// # extern crate google_dns1 as dns1; +/// use dns1::Change; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -966,7 +966,7 @@ impl<'a, C, A> ProjectMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Change = Default::default(); +/// let mut req = Change::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1018,7 +1018,7 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}/changes".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}/changes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } @@ -1060,16 +1060,20 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1217,11 +1221,11 @@ impl<'a, C, A> ChangeCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -1297,7 +1301,7 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}/changes".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}/changes".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -1335,16 +1339,20 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1507,11 +1515,11 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -1569,7 +1577,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}/changes/{changeId}".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}/changes/{changeId}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -1607,16 +1615,20 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1761,12 +1773,12 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; -/// use dns1_beta1::ManagedZone; +/// # extern crate google_dns1 as dns1; +/// use dns1::ManagedZone; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -1776,7 +1788,7 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ManagedZone = Default::default(); +/// let mut req = ManagedZone::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1826,7 +1838,7 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } @@ -1868,16 +1880,20 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2015,11 +2031,11 @@ impl<'a, C, A> ManagedZoneCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -2074,7 +2090,7 @@ impl<'a, C, A> ManagedZoneDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> } - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); } @@ -2112,16 +2128,20 @@ impl<'a, C, A> ManagedZoneDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2246,11 +2266,11 @@ impl<'a, C, A> ManagedZoneDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -2306,7 +2326,7 @@ impl<'a, C, A> ManagedZoneGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -2344,16 +2364,20 @@ impl<'a, C, A> ManagedZoneGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2488,11 +2512,11 @@ impl<'a, C, A> ManagedZoneGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -2556,7 +2580,7 @@ impl<'a, C, A> ManagedZoneListCall<'a, C, A> where C: BorrowMut<hyper::Client>, params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -2594,16 +2618,20 @@ impl<'a, C, A> ManagedZoneListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2742,11 +2770,11 @@ impl<'a, C, A> ManagedZoneListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -2822,7 +2850,7 @@ impl<'a, C, A> ResourceRecordSetListCall<'a, C, A> where C: BorrowMut<hyper::Cli params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}/managedZones/{managedZone}/rrsets".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}/rrsets".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -2860,16 +2888,20 @@ impl<'a, C, A> ResourceRecordSetListCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3032,11 +3064,11 @@ impl<'a, C, A> ResourceRecordSetListCall<'a, C, A> where C: BorrowMut<hyper::Cli /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_dns1_beta1 as dns1_beta1; +/// # extern crate google_dns1 as dns1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use dns1_beta1::Dns; +/// # use dns1::Dns; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, @@ -3090,7 +3122,7 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa params.push(("alt", "json".to_string())); - let mut url = "https://www.googleapis.com/dns/v1beta1/projects/{project}".to_string(); + let mut url = "https://www.googleapis.com/dns/v1/projects/{project}".to_string(); if self._scopes.len() == 0 { self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); } @@ -3128,16 +3160,20 @@ impl<'a, C, A> ProjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/dns1_beta1-cli/LICENSE.md b/gen/dns1_beta1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dns1_beta1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dns1_beta1-cli/README.md b/gen/dns1_beta1-cli/README.md deleted file mode 100644 index c0386d0f3a..0000000000 --- a/gen/dns1_beta1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO DNS:V1BETA1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/dns1_beta1-cli/src/cmn.rs b/gen/dns1_beta1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/dns1_beta1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/dns1_beta1/LICENSE.md b/gen/dns1_beta1/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/dns1_beta1/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/dns1_beta1/src/cmn.rs b/gen/dns1_beta1/src/cmn.rs deleted file mode 100644 index 5d9b5ebbf8..0000000000 --- a/gen/dns1_beta1/src/cmn.rs +++ /dev/null @@ -1,643 +0,0 @@ -// COPY OF 'src/rust/api/cmn.rs' -// DO NOT EDIT -use std::io::{self, Read, Seek, Cursor, Write, SeekFrom}; -use std; -use std::fmt::{self, Display}; -use std::str::FromStr; -use std::error; -use std::thread::sleep_ms; - -use mime::{Mime, TopLevel, SubLevel, Attr, Value}; -use oauth2::{TokenType, Retry, self}; -use hyper; -use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header, - HeaderFormat}; -use hyper::http::LINE_ENDING; -use hyper::method::Method; -use hyper::status::StatusCode; - -use serde; - -/// Identifies the Hub. There is only one per library, this trait is supposed -/// to make intended use more explicit. -/// The hub allows to access all resource methods more easily. -pub trait Hub {} - -/// Identifies types for building methods of a particular resource type -pub trait MethodsBuilder {} - -/// Identifies types which represent builders for a particular resource method -pub trait CallBuilder {} - -/// Identifies types which can be inserted and deleted. -/// Types with this trait are most commonly used by clients of this API. -pub trait Resource {} - -/// Identifies types which are used in API responses. -pub trait ResponseResult {} - -/// Identifies types which are used in API requests. -pub trait RequestValue {} - -/// Identifies types which are not actually used by the API -/// This might be a bug within the google API schema. -pub trait UnusedType {} - -/// Identifies types which are only used as part of other types, which -/// usually are carrying the `Resource` trait. -pub trait Part {} - -/// Identifies types which are only used by other types internally. -/// They have no special meaning, this trait just marks them for completeness. -pub trait NestedType {} - -/// A utility to specify reader types which provide seeking capabilities too -pub trait ReadSeek: Seek + Read {} -impl<T: Seek + Read> ReadSeek for T {} - -/// A trait for all types that can convert themselves into a *parts* string -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 { - pub error: String, - pub error_description: Option<String> -} - -#[derive(Copy, Clone)] -pub struct DummyNetworkStream; - -impl Read for DummyNetworkStream { - fn read(&mut self, _: &mut [u8]) -> io::Result<usize> { - Ok(0) - } -} - -impl Write for DummyNetworkStream { - fn write(&mut self, _: &[u8]) -> io::Result<usize> { - Ok(0) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl hyper::net::NetworkStream for DummyNetworkStream { - fn peer_addr(&mut self) -> io::Result<std::net::SocketAddr> { - Ok("127.0.0.1:1337".parse().unwrap()) - } -} - - -/// A trait specifying functionality to help controlling any request performed by the API. -/// The trait has a conservative default implementation. -/// -/// It contains methods to deal with all common issues, as well with the ones related to -/// uploading media -pub trait Delegate { - - /// Called at the beginning of any API request. The delegate should store the method - /// information if he is interesting in knowing more context when further calls to it - /// are made. - /// The matching `finished()` call will always be made, no matter whether or not the API - /// request was successful. That way, the delegate may easily maintain a clean state - /// between various API calls. - fn begin(&mut self, MethodInfo) {} - - /// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems. - /// - /// 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). - /// - /// Return retry information. - fn http_error(&mut self, &hyper::HttpError) -> Retry { - Retry::Abort - } - - /// Called whenever there is the need for your applications API key after - /// the official authenticator implementation didn't provide one, for some reason. - /// If this method returns None as well, the underlying operation will fail - fn api_key(&mut self) -> Option<String> { - None - } - - /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { - None - } - - /// Called during resumable uploads to provide a URL for the impending upload. - /// It was saved after a previous call to `store_upload_url(...)`, and if not None, - /// will be used instead of asking the server for a new upload URL. - /// This is useful in case a previous resumable upload was aborted/canceled, but should now - /// be resumed. - /// The returned URL will be used exactly once - if it fails again and the delegate allows - /// to retry, we will ask the server for a new upload URL. - fn upload_url(&mut self) -> Option<String> { - None - } - - /// Called after we have retrieved a new upload URL for a resumable upload to store it - /// in case we fail or cancel. That way, we can attempt to resume the upload later, - /// see `upload_url()`. - fn store_upload_url(&mut self, url: &str) { - let _ = url; - } - - /// Called whenever a server response could not be decoded from json. - /// It's for informational purposes only, the caller will return with an error - /// accordingly. - /// - /// # Arguments - /// - /// * `json_encoded_value` - The json-encoded value which failed to decode. - /// * `json_decode_error` - The decoder error - fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &serde::json::Error) { - let _ = json_encoded_value; - let _ = json_decode_error; - } - - /// Called whenever the http request returns with a non-success status code. - /// This can involve authentication issues, or anything else that very much - /// depends on the used API method. - /// The delegate should check the status, header and decoded json error to decide - /// whether to retry or not. In the latter case, the underlying call will fail. - /// - /// 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 { - Retry::Abort - } - - /// Called prior to sending the main request of the given method. It can be used to time - /// the call or to print progress information. - /// It's also useful as you can be sure that a request will definitely be made. - fn pre_request(&mut self) { } - - /// Return the size of each chunk of a resumable upload. - /// Must be a power of two, with 1<<18 being the smallest allowed chunk size. - /// Will be called once before starting any resumable upload. - fn chunk_size(&mut self) -> u64 { - 1 << 23 - } - - /// Called before the given chunk is uploaded to the server. - /// If true is returned, the upload will be interrupted. - /// However, it may be resumable if you stored the upload URL in a previous call - /// to `store_upload_url()` - fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool { - let _ = chunk; - false - } - - /// Called before the API request method returns, in every case. It can be used to clean up - /// internal state between calls to the API. - /// This call always has a matching call to `begin(...)`. - /// - /// # Arguments - /// - /// * `is_success` - a true value indicates the operation was successful. If false, you should - /// discard all values stored during `store_upload_url`. - fn finished(&mut self, is_success: bool) { - let _ = is_success; - } -} - -/// A delegate with a conservative default implementation, which is used if no other delegate is -/// set. -#[derive(Default)] -pub struct DefaultDelegate; - -impl Delegate for DefaultDelegate {} - - -#[derive(Debug)] -pub enum Error { - /// The http connection failed - HttpError(hyper::HttpError), - - /// An attempt was made to upload a resource with size stored in field `.0` - /// even though the maximum upload size is what is stored in field `.1`. - UploadSizeLimitExceeded(u64, u64), - - /// We needed an API key for authentication, but didn't obtain one. - /// Neither through the authenticator, nor through the Delegate. - MissingAPIKey, - - /// We required a Token, but didn't get one from the Authenticator - MissingToken, - - /// The delgate instructed to cancel the operation - Cancelled, - - /// An additional, free form field clashed with one of the built-in optional ones - FieldClash(&'static str), - - /// 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), - - /// Indicates an HTTP repsonse with a non-success status code - Failure(hyper::client::Response), -} - - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Error::HttpError(ref err) => err.fmt(f), - Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) => - writeln!(f, "The media size {} exceeds the maximum allowed upload size of {}" - , resource_size, max_size), - Error::MissingAPIKey => { - 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), - 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::Failure(ref response) => - writeln!(f, "Http status indicates failure: {:?}", response), - } - } -} - -impl error::Error for Error { - fn description(&self) -> &str { - match *self { - Error::HttpError(ref err) => err.description(), - Error::JsonDecodeError(ref err) => err.description(), - _ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead" - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::HttpError(ref err) => err.cause(), - Error::JsonDecodeError(ref err) => err.cause(), - _ => None - } - } -} - -/// A universal result type used as return for all calls. -pub type Result<T> = std::result::Result<T, Error>; - -/// Contains information about an API request. -pub struct MethodInfo { - pub id: &'static str, - pub http_method: Method, -} - -const BOUNDARY: &'static str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d"; - -/// Provides a `Read` interface that converts multiple parts into the protocol -/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387). -/// **Note**: This implementation is just as rich as it needs to be to perform uploads -/// to google APIs, and might not be a fully-featured implementation. -#[derive(Default)] -pub struct MultiPartReader<'a> { - raw_parts: Vec<(Headers, &'a mut Read)>, - current_part: Option<(Cursor<Vec<u8>>, &'a mut Read)>, - last_part_boundary: Option<Cursor<Vec<u8>>>, -} - -impl<'a> MultiPartReader<'a> { - - /// Reserve memory for exactly the given amount of parts - pub fn reserve_exact(&mut self, cap: usize) { - self.raw_parts.reserve_exact(cap); - } - - /// Add a new part to the queue of parts to be read on the first `read` call. - /// - /// # Arguments - /// - /// `headers` - identifying the body of the part. It's similar to the header - /// in an ordinary single-part call, and should thus contain the - /// same information. - /// `reader` - a reader providing the part's body - /// `size` - the amount of bytes provided by the reader. It will be put onto the header as - /// content-size. - /// `mime` - It will be put onto the content type - pub fn add_part(&mut self, reader: &'a mut Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> { - let mut headers = Headers::new(); - headers.set(ContentType(mime_type)); - headers.set(ContentLength(size)); - self.raw_parts.push((headers, reader)); - self - } - - /// Returns the mime-type representing our multi-part message. - /// Use it with the ContentType header. - pub fn mime_type(&self) -> Mime { - Mime( - TopLevel::Multipart, - SubLevel::Ext("Related".to_string()), - vec![(Attr::Ext("boundary".to_string()), Value::Ext(BOUNDARY.to_string()))], - ) - } - - /// Returns true if we are totally used - fn is_depleted(&self) -> bool { - self.raw_parts.len() == 0 && self.current_part.is_none() && self.last_part_boundary.is_none() - } - - /// Returns true if we are handling our last part - fn is_last_part(&self) -> bool { - self.raw_parts.len() == 0 && self.current_part.is_some() - } -} - -impl<'a> Read for MultiPartReader<'a> { - fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { - match (self.raw_parts.len(), - self.current_part.is_none(), - self.last_part_boundary.is_none()) { - (_, _, false) => { - let br = self.last_part_boundary.as_mut().unwrap().read(buf).unwrap_or(0); - if br < buf.len() { - self.last_part_boundary = None; - } - return Ok(br) - }, - (0, true, true) => return Ok(0), - (n, true, _) if n > 0 => { - let (headers, reader) = self.raw_parts.remove(0); - let mut c = Cursor::new(Vec::<u8>::new()); - write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING, - headers, LINE_ENDING).unwrap(); - c.seek(SeekFrom::Start(0)).unwrap(); - self.current_part = Some((c, reader)); - } - _ => {}, - } - - // read headers as long as possible - let (hb, rr) = { - let &mut (ref mut c, ref mut reader) = self.current_part.as_mut().unwrap(); - let b = c.read(buf).unwrap_or(0); - (b, reader.read(&mut buf[b..])) - }; - - match rr { - Ok(bytes_read) => { - if hb < buf.len() && bytes_read == 0 { - if self.is_last_part() { - // 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())) - } - // We are depleted - this can trigger the next part to come in - self.current_part = None; - } - let mut total_bytes_read = hb + bytes_read; - while total_bytes_read < buf.len() && !self.is_depleted() { - match self.read(&mut buf[total_bytes_read ..]) { - Ok(br) => total_bytes_read += br, - Err(err) => return Err(err), - } - } - Ok(total_bytes_read) - } - Err(err) => { - // fail permanently - self.current_part = None; - self.last_part_boundary = None; - self.raw_parts.clear(); - Err(err) - } - } - } -} - -header!{ - #[doc="The `X-Upload-Content-Type` header."] - (XUploadContentType, "X-Upload-Content-Type") => [Mime] -} - -#[derive(Clone, PartialEq, Debug)] -pub struct Chunk { - pub first: u64, - pub last: u64 -} - -impl fmt::Display for Chunk { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{}-{}", self.first, self.last).ok(); - Ok(()) - } -} - -impl FromStr for Chunk { - type Err = &'static str; - - /// NOTE: only implements `%i-%i`, not `*` - fn from_str(s: &str) -> std::result::Result<Chunk, &'static str> { - let parts: Vec<&str> = s.split('-').collect(); - if parts.len() != 2 { - return Err("Expected two parts: %i-%i") - } - Ok( - Chunk { - first: match FromStr::from_str(parts[0]) { - Ok(d) => d, - _ => return Err("Couldn't parse 'first' as digit") - }, - last: match FromStr::from_str(parts[1]) { - Ok(d) => d, - _ => return Err("Couldn't parse 'last' as digit") - } - } - ) - } -} - -/// Implements the Content-Range header, for serialization only -#[derive(Clone, PartialEq, Debug)] -pub struct ContentRange { - pub range: Option<Chunk>, - pub total_length: u64, -} - -impl Header for ContentRange { - fn header_name() -> &'static str { - "Content-Range" - } - - /// We are not parsable, as parsing is done by the `Range` header - fn parse_header(_: &[Vec<u8>]) -> Option<ContentRange> { - None - } -} - - -impl HeaderFormat for ContentRange { - fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(fmt.write_str("bytes=")); - match self.range { - Some(ref c) => try!(c.fmt(fmt)), - None => try!(fmt.write_str("*")) - } - write!(fmt, "/{}", self.total_length).ok(); - Ok(()) - } -} - -#[derive(Clone, PartialEq, Debug)] -pub struct RangeResponseHeader(pub Chunk); - -impl Header for RangeResponseHeader { - fn header_name() -> &'static str { - "Range" - } - - 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="; - if s.starts_with(PREFIX) { - if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) { - return Some(RangeResponseHeader(c)) - } - } - } - } - None - } -} - -impl HeaderFormat for RangeResponseHeader { - /// No implmentation necessary, we just need to parse - fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result { - Err(fmt::Error) - } -} - -/// A utility type to perform a resumable upload from start to end. -pub struct ResumableUploadHelper<'a, A: 'a> { - pub client: &'a mut hyper::client::Client, - pub delegate: &'a mut Delegate, - pub start_at: Option<u64>, - pub auth: &'a mut A, - pub user_agent: &'a str, - pub auth_header: Authorization<oauth2::Scheme>, - pub url: &'a str, - pub reader: &'a mut ReadSeek, - pub media_type: Mime, - pub content_length: u64 -} - -impl<'a, A> ResumableUploadHelper<'a, A> - where A: oauth2::GetToken { - - fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::HttpResult<hyper::client::Response>> { - loop { - match self.client.post(self.url) - .header(UserAgent(self.user_agent.to_string())) - .header(ContentRange { range: None, total_length: self.content_length }) - .header(self.auth_header.clone()) - .send() { - Ok(r) => { - // 308 = resume-incomplete == PermanentRedirect - let headers = r.headers.clone(); - 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) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - return Err(Ok(r)) - } - }; - return Ok(h.0.last) - } - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - return Err(Err(err)) - } - } - } - } - - /// returns None if operation was cancelled by delegate, or the HttpResult. - /// It can be that we return the result just because we didn't understand the status code - - /// caller should check for status himself before assuming it's OK to use - pub fn upload(&mut self) -> Option<hyper::HttpResult<hyper::client::Response>> { - let mut start = match self.start_at { - Some(s) => s, - None => match self.query_transfer_status() { - Ok(s) => s, - Err(result) => return Some(result) - } - }; - - const MIN_CHUNK_SIZE: u64 = 1 << 18; - let chunk_size = match self.delegate.chunk_size() { - cs if cs > MIN_CHUNK_SIZE => cs, - _ => MIN_CHUNK_SIZE - }; - - self.reader.seek(SeekFrom::Start(start)).unwrap(); - loop { - let request_size = match self.content_length - start { - rs if rs > chunk_size => chunk_size, - rs => rs - }; - - let mut section_reader = self.reader.take(request_size); - let range_header = ContentRange { - range: Some(Chunk {first: start, last: start + request_size - 1}), - total_length: self.content_length - }; - start += request_size; - if self.delegate.cancel_chunk_upload(&range_header) { - return None - } - match self.client.post(self.url) - .header(range_header) - .header(ContentType(self.media_type.clone())) - .header(UserAgent(self.user_agent.to_string())) - .body(&mut section_reader) - .send() { - Ok(mut res) => { - if res.status == StatusCode::PermanentRedirect { - continue - } - 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()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - } - return Some(Ok(res)) - }, - Err(err) => { - if let Retry::After(d) = self.delegate.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - return Some(Err(err)) - } - } - } - } -} \ No newline at end of file diff --git a/gen/doubleclickbidmanager1-cli/Cargo.toml b/gen/doubleclickbidmanager1-cli/Cargo.toml index dfceba6246..2f78759e79 100644 --- a/gen/doubleclickbidmanager1-cli/Cargo.toml +++ b/gen/doubleclickbidmanager1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-doubleclickbidmanager1-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/bid-manager/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/doubleclickbidmanager1-cli/src/cmn.rs b/gen/doubleclickbidmanager1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/doubleclickbidmanager1-cli/src/cmn.rs +++ b/gen/doubleclickbidmanager1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/doubleclickbidmanager1-cli/src/main.rs b/gen/doubleclickbidmanager1-cli/src/main.rs index 6ebdf31b85..7d77d39ddd 100644 --- a/gen/doubleclickbidmanager1-cli/src/main.rs +++ b/gen/doubleclickbidmanager1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -35,6 +36,12 @@ Configuration: 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. "); mod cmn; @@ -56,10 +63,10 @@ struct Engine { impl Engine { fn _lineitems_downloadlineitems(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DownloadLineItemsRequest = Default::default(); + let mut request = api::DownloadLineItemsRequest::default(); let mut call = self.hub.lineitems().downloadlineitems(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -79,9 +86,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -91,9 +99,9 @@ impl Engine { }, "filter-ids" => { if request.filter_ids.is_none() { - request.filter_ids = Some(Default::default()); + request.filter_ids = Some(Default::default()); } - request.filter_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.filter_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request.format = Some(value.unwrap_or("").to_string()); @@ -115,8 +123,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -125,10 +132,10 @@ impl Engine { fn _lineitems_uploadlineitems(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::UploadLineItemsRequest = Default::default(); + let mut request = api::UploadLineItemsRequest::default(); let mut call = self.hub.lineitems().uploadlineitems(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -148,9 +155,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -181,8 +189,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -191,10 +198,10 @@ impl Engine { fn _queries_createquery(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Query = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -214,9 +221,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -244,19 +252,19 @@ impl Engine { }, "schedule.end-time-ms" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().end_time_ms = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().end_time_ms = Some(value.unwrap_or("").to_string()); }, "schedule.next-run-timezone-code" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().next_run_timezone_code = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().next_run_timezone_code = Some(value.unwrap_or("").to_string()); }, "schedule.frequency" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().frequency = value.unwrap_or("").to_string(); + request.schedule.as_mut().unwrap().frequency = Some(value.unwrap_or("").to_string()); }, "schedule.next-run-minute-of-day" => { request_schedule_init(&mut request); - request.schedule.as_mut().unwrap().next_run_minute_of_day = arg_from_str(value.unwrap_or("-0"), err, "schedule.next-run-minute-of-day", "integer"); + request.schedule.as_mut().unwrap().next_run_minute_of_day = Some(arg_from_str(value.unwrap_or("-0"), err, "schedule.next-run-minute-of-day", "integer")); }, "timezone-code" => { request_schedule_init(&mut request); @@ -272,19 +280,25 @@ impl Engine { }, "params.metrics" => { request_params_init(&mut request); - request.params.as_mut().unwrap().metrics.push(value.unwrap_or("").to_string()); + if request.params.as_mut().unwrap().metrics.is_none() { + request.params.as_mut().unwrap().metrics = Some(Default::default()); + } + request.params.as_mut().unwrap().metrics.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "params.type" => { request_params_init(&mut request); - request.params.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.params.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "params.group-bys" => { request_params_init(&mut request); - request.params.as_mut().unwrap().group_bys.push(value.unwrap_or("").to_string()); + if request.params.as_mut().unwrap().group_bys.is_none() { + request.params.as_mut().unwrap().group_bys = Some(Default::default()); + } + request.params.as_mut().unwrap().group_bys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "params.include-invite-data" => { request_params_init(&mut request); - request.params.as_mut().unwrap().include_invite_data = arg_from_str(value.unwrap_or("false"), err, "params.include-invite-data", "boolean"); + request.params.as_mut().unwrap().include_invite_data = Some(arg_from_str(value.unwrap_or("false"), err, "params.include-invite-data", "boolean")); }, "report-data-start-time-ms" => { request_params_init(&mut request); @@ -292,47 +306,50 @@ impl Engine { }, "metadata.google-cloud-storage-path-for-latest-report" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().google_cloud_storage_path_for_latest_report = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().google_cloud_storage_path_for_latest_report = Some(value.unwrap_or("").to_string()); }, "metadata.data-range" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().data_range = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().data_range = Some(value.unwrap_or("").to_string()); }, "metadata.format" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().format = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().format = Some(value.unwrap_or("").to_string()); }, "metadata.locale" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().locale = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().locale = Some(value.unwrap_or("").to_string()); }, "metadata.google-drive-path-for-latest-report" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().google_drive_path_for_latest_report = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().google_drive_path_for_latest_report = Some(value.unwrap_or("").to_string()); }, "metadata.send-notification" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().send_notification = arg_from_str(value.unwrap_or("false"), err, "metadata.send-notification", "boolean"); + request.metadata.as_mut().unwrap().send_notification = Some(arg_from_str(value.unwrap_or("false"), err, "metadata.send-notification", "boolean")); }, "metadata.share-email-address" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().share_email_address.push(value.unwrap_or("").to_string()); + if request.metadata.as_mut().unwrap().share_email_address.is_none() { + request.metadata.as_mut().unwrap().share_email_address = Some(Default::default()); + } + request.metadata.as_mut().unwrap().share_email_address.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "metadata.report-count" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().report_count = arg_from_str(value.unwrap_or("-0"), err, "metadata.report-count", "integer"); + request.metadata.as_mut().unwrap().report_count = Some(arg_from_str(value.unwrap_or("-0"), err, "metadata.report-count", "integer")); }, "metadata.running" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().running = arg_from_str(value.unwrap_or("false"), err, "metadata.running", "boolean"); + request.metadata.as_mut().unwrap().running = Some(arg_from_str(value.unwrap_or("false"), err, "metadata.running", "boolean")); }, "metadata.latest-report-run-time-ms" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().latest_report_run_time_ms = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().latest_report_run_time_ms = Some(value.unwrap_or("").to_string()); }, "metadata.title" => { request_metadata_init(&mut request); - request.metadata.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.metadata.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -351,8 +368,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -363,7 +379,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.queries().deletequery(&self.opt.arg_query_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -394,7 +410,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -405,7 +420,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.queries().getquery(&self.opt.arg_query_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -437,8 +452,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -449,7 +463,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.queries().listqueries(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -481,8 +495,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -491,10 +504,10 @@ impl Engine { fn _queries_runquery(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RunQueryRequest = Default::default(); + let mut request = api::RunQueryRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -514,9 +527,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -549,7 +563,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -560,7 +573,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().listreports(&self.opt.arg_query_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -592,8 +605,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -613,7 +625,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_queries { + } + else if self.opt.cmd_queries { if self.opt.cmd_createquery { call_result = self._queries_createquery(dry_run, &mut err); } else if self.opt.cmd_deletequery { @@ -627,7 +640,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_reports { if self.opt.cmd_listreports { call_result = self._reports_listreports(dry_run, &mut err); } else { @@ -653,21 +667,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "doubleclickbidmanager1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "doubleclickbidmanager1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "doubleclickbidmanager1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "doubleclickbidmanager1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::DoubleClickBidManager::new(hyper::Client::new(), auth), + hub: api::DoubleClickBidManager::new(client, auth), }; match engine._doit(true) { @@ -687,12 +717,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/doubleclickbidmanager1/Cargo.toml b/gen/doubleclickbidmanager1/Cargo.toml index 9ef3f26eb0..67344ad6f4 100644 --- a/gen/doubleclickbidmanager1/Cargo.toml +++ b/gen/doubleclickbidmanager1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-doubleclickbidmanager1" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/bid-manager/" diff --git a/gen/doubleclickbidmanager1/src/cmn.rs b/gen/doubleclickbidmanager1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/doubleclickbidmanager1/src/cmn.rs +++ b/gen/doubleclickbidmanager1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/doubleclickbidmanager1/src/lib.rs b/gen/doubleclickbidmanager1/src/lib.rs index 055cd178bd..b1e9fb7b72 100644 --- a/gen/doubleclickbidmanager1/src/lib.rs +++ b/gen/doubleclickbidmanager1/src/lib.rs @@ -341,7 +341,7 @@ impl RequestValue for DownloadLineItemsRequest {} pub struct ReportFailure { /// Error code that shows why the report was not created. #[serde(rename="errorCode")] - pub error_code: String, + pub error_code: Option<String>, } impl Part for ReportFailure {} @@ -354,18 +354,18 @@ impl Part for ReportFailure {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Parameters { /// Metrics to include as columns in your report. - pub metrics: Vec<String>, + pub metrics: Option<Vec<String>>, /// Filters used to match traffic data in your report. - pub filters: Vec<FilterPair>, + pub filters: Option<Vec<FilterPair>>, /// Report type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Data is grouped by the filters listed in this field. #[serde(rename="groupBys")] - pub group_bys: Vec<String>, + pub group_bys: Option<Vec<String>>, /// Whether to include data from Invite Media. #[serde(rename="includeInviteData")] - pub include_invite_data: bool, + pub include_invite_data: Option<bool>, } impl Part for Parameters {} @@ -379,10 +379,10 @@ impl Part for Parameters {} pub struct ReportKey { /// Query ID. #[serde(rename="queryId")] - pub query_id: String, + pub query_id: Option<String>, /// Report ID. #[serde(rename="reportId")] - pub report_id: String, + pub report_id: Option<String>, } impl Part for ReportKey {} @@ -424,9 +424,9 @@ impl RequestValue for UploadLineItemsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListQueriesResponse { /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listQueriesResponse". - pub kind: String, + pub kind: Option<String>, /// Retrieved queries. - pub queries: Vec<Query>, + pub queries: Option<Vec<Query>>, } impl ResponseResult for ListQueriesResponse {} @@ -439,16 +439,16 @@ impl ResponseResult for ListQueriesResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportMetadata { /// Report status. - pub status: ReportStatus, + pub status: Option<ReportStatus>, /// The ending time for the data that is shown in the report. #[serde(rename="reportDataEndTimeMs")] - pub report_data_end_time_ms: String, + pub report_data_end_time_ms: Option<String>, /// The path to the location in Google Cloud Storage where the report is stored. #[serde(rename="googleCloudStoragePath")] - pub google_cloud_storage_path: String, + pub google_cloud_storage_path: Option<String>, /// The starting time for the data that is shown in the report. #[serde(rename="reportDataStartTimeMs")] - pub report_data_start_time_ms: String, + pub report_data_start_time_ms: Option<String>, } impl Part for ReportMetadata {} @@ -462,15 +462,15 @@ impl Part for ReportMetadata {} pub struct QuerySchedule { /// Datetime to periodically run the query until. #[serde(rename="endTimeMs")] - pub end_time_ms: String, + pub end_time_ms: Option<String>, /// How often the query is run. - pub frequency: String, + pub frequency: Option<String>, /// Time of day at which a new report will be generated, represented as minutes past midnight. Range is 0 to 1439. Only applies to scheduled reports. #[serde(rename="nextRunMinuteOfDay")] - pub next_run_minute_of_day: i32, + pub next_run_minute_of_day: Option<i32>, /// Canonical timezone code for report generation time. Defaults to America/New_York. #[serde(rename="nextRunTimezoneCode")] - pub next_run_timezone_code: String, + pub next_run_timezone_code: Option<String>, } impl Part for QuerySchedule {} @@ -517,7 +517,7 @@ impl RequestValue for RunQueryRequest {} pub struct UploadLineItemsResponse { /// Status of upload. #[serde(rename="uploadStatus")] - pub upload_status: UploadStatus, + pub upload_status: Option<UploadStatus>, } impl ResponseResult for UploadLineItemsResponse {} @@ -531,35 +531,35 @@ impl ResponseResult for UploadLineItemsResponse {} pub struct QueryMetadata { /// The path to the location in Google Cloud Storage where the latest report is stored. #[serde(rename="googleCloudStoragePathForLatestReport")] - pub google_cloud_storage_path_for_latest_report: String, + pub google_cloud_storage_path_for_latest_report: Option<String>, /// Range of report data. #[serde(rename="dataRange")] - pub data_range: String, + pub data_range: Option<String>, /// Whether to send an email notification when a report is ready. Default to false. #[serde(rename="sendNotification")] - pub send_notification: bool, + pub send_notification: Option<bool>, /// Locale of the generated reports. Valid values are cs CZECH de GERMAN en ENGLISH es SPANISH fr FRENCH it ITALIAN ja JAPANESE ko KOREAN pl POLISH pt-BR BRAZILIAN_PORTUGUESE ru RUSSIAN tr TURKISH uk UKRAINIAN zh-CN CHINA_CHINESE zh-TW TAIWAN_CHINESE /// /// An locale string not in the list above will generate reports in English. - pub locale: String, + pub locale: Option<String>, /// The path in Google Drive for the latest report. #[serde(rename="googleDrivePathForLatestReport")] - pub google_drive_path_for_latest_report: String, + pub google_drive_path_for_latest_report: Option<String>, /// Format of the generated report. - pub format: String, + pub format: Option<String>, /// List of email addresses which are sent email notifications when the report is finished. Separate from sendNotification. #[serde(rename="shareEmailAddress")] - pub share_email_address: Vec<String>, + pub share_email_address: Option<Vec<String>>, /// Number of reports that have been generated for the query. #[serde(rename="reportCount")] - pub report_count: i32, + pub report_count: Option<i32>, /// Whether the latest report is currently running. - pub running: bool, + pub running: Option<bool>, /// The time when the latest report started to run. #[serde(rename="latestReportRunTimeMs")] - pub latest_report_run_time_ms: String, + pub latest_report_run_time_ms: Option<String>, /// Query title. It is used to name the reports generated from this query. - pub title: String, + pub title: Option<String>, } impl Part for QueryMetadata {} @@ -572,14 +572,14 @@ impl Part for QueryMetadata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportStatus { /// If the report failed, this records the cause. - pub failure: ReportFailure, + pub failure: Option<ReportFailure>, /// The state of the report. - pub state: String, + pub state: Option<String>, /// The time when this report either completed successfully or failed. #[serde(rename="finishTimeMs")] - pub finish_time_ms: String, + pub finish_time_ms: Option<String>, /// The file type of the report. - pub format: String, + pub format: Option<String>, } impl Part for ReportStatus {} @@ -597,9 +597,9 @@ impl Part for ReportStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListReportsResponse { /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listReportsResponse". - pub kind: String, + pub kind: Option<String>, /// Retrieved reports. - pub reports: Vec<Report>, + pub reports: Option<Vec<Report>>, } impl ResponseResult for ListReportsResponse {} @@ -612,20 +612,20 @@ impl ResponseResult for ListReportsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RowStatus { /// Whether the entity is persisted. - pub persisted: bool, + pub persisted: Option<bool>, /// Reasons why the entity can't be uploaded. - pub errors: Vec<String>, + pub errors: Option<Vec<String>>, /// Entity name. #[serde(rename="entityName")] - pub entity_name: String, + pub entity_name: Option<String>, /// Whether the stored entity is changed as a result of upload. - pub changed: bool, + pub changed: Option<bool>, /// Entity Id. #[serde(rename="entityId")] - pub entity_id: String, + pub entity_id: Option<String>, /// Row number. #[serde(rename="rowNumber")] - pub row_number: i32, + pub row_number: Option<i32>, } impl Part for RowStatus {} @@ -704,7 +704,7 @@ impl ResponseResult for Query {} pub struct DownloadLineItemsResponse { /// Retrieved line items in CSV format. Refer to Entity Write File Format for more information on file format. #[serde(rename="lineItems")] - pub line_items: String, + pub line_items: Option<String>, } impl ResponseResult for DownloadLineItemsResponse {} @@ -718,9 +718,9 @@ impl ResponseResult for DownloadLineItemsResponse {} pub struct FilterPair { /// Filter type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Filter value. - pub value: String, + pub value: Option<String>, } impl Part for FilterPair {} @@ -733,10 +733,10 @@ impl Part for FilterPair {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadStatus { /// Reasons why upload can't be completed. - pub errors: Vec<String>, + pub errors: Option<Vec<String>>, /// Per-row upload status. #[serde(rename="rowStatus")] - pub row_status: Vec<RowStatus>, + pub row_status: Option<Vec<RowStatus>>, } impl Part for UploadStatus {} @@ -1028,7 +1028,7 @@ impl<'a, C, A> QueryMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UploadLineItemsRequest = Default::default(); +/// let mut req = UploadLineItemsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1227,7 +1227,7 @@ impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DownloadLineItemsRequest = Default::default(); +/// let mut req = DownloadLineItemsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2023,7 +2023,7 @@ impl<'a, C, A> QueryGetqueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Query = Default::default(); +/// let mut req = Query::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2422,7 +2422,7 @@ impl<'a, C, A> QueryDeletequeryCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RunQueryRequest = Default::default(); +/// let mut req = RunQueryRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. diff --git a/gen/doubleclicksearch2-cli/Cargo.toml b/gen/doubleclicksearch2-cli/Cargo.toml index ed0e97b190..25bdaa16f5 100644 --- a/gen/doubleclicksearch2-cli/Cargo.toml +++ b/gen/doubleclicksearch2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-doubleclicksearch2-cli" version = "0.0.1+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/doubleclick-search/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/doubleclicksearch2-cli/src/cmn.rs b/gen/doubleclicksearch2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/doubleclicksearch2-cli/src/cmn.rs +++ b/gen/doubleclicksearch2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/doubleclicksearch2-cli/src/main.rs b/gen/doubleclicksearch2-cli/src/main.rs index da67def8f0..be9b9e50ab 100644 --- a/gen/doubleclicksearch2-cli/src/main.rs +++ b/gen/doubleclicksearch2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -41,6 +42,12 @@ Configuration: 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. "); mod cmn; @@ -68,7 +75,7 @@ impl Engine { let start_row: u32 = arg_from_str(&self.opt.arg_start_row, err, "<start-row>", "integer"); let mut call = self.hub.conversion().get(&self.opt.arg_agency_id, &self.opt.arg_advertiser_id, &self.opt.arg_engine_account_id, end_date, row_count, start_date, start_row); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "criterion-id" => { call = call.criterion_id(value.unwrap_or("")); @@ -112,8 +119,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -122,10 +128,10 @@ impl Engine { fn _conversion_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ConversionList = Default::default(); + let mut request = api::ConversionList::default(); let mut call = self.hub.conversion().insert(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -145,9 +151,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -172,8 +179,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -182,14 +188,14 @@ impl Engine { fn _conversion_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ConversionList = Default::default(); + let mut request = api::ConversionList::default(); 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -209,9 +215,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -236,8 +243,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -246,10 +252,10 @@ impl Engine { fn _conversion_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ConversionList = Default::default(); + let mut request = api::ConversionList::default(); let mut call = self.hub.conversion().update(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -269,9 +275,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -296,8 +303,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -306,10 +312,10 @@ impl Engine { fn _conversion_update_availability(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::UpdateAvailabilityRequest = Default::default(); + let mut request = api::UpdateAvailabilityRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -329,9 +335,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -353,8 +360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -363,10 +369,10 @@ impl Engine { fn _reports_generate(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ReportRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -386,9 +392,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -407,31 +414,31 @@ impl Engine { match &field_name.to_string()[..] { "report-scope.ad-group-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().ad_group_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().ad_group_id = Some(value.unwrap_or("").to_string()); }, "report-scope.agency-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().agency_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().agency_id = Some(value.unwrap_or("").to_string()); }, "report-scope.engine-account-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().engine_account_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().engine_account_id = Some(value.unwrap_or("").to_string()); }, "report-scope.campaign-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().campaign_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().campaign_id = Some(value.unwrap_or("").to_string()); }, "report-scope.advertiser-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().advertiser_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().advertiser_id = Some(value.unwrap_or("").to_string()); }, "report-scope.keyword-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().keyword_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().keyword_id = Some(value.unwrap_or("").to_string()); }, "report-scope.ad-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().ad_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().ad_id = Some(value.unwrap_or("").to_string()); }, "max-rows-per-file" => { request_report_scope_init(&mut request); @@ -443,19 +450,19 @@ impl Engine { }, "time-range.changed-metrics-since-timestamp" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().changed_metrics_since_timestamp = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().changed_metrics_since_timestamp = Some(value.unwrap_or("").to_string()); }, "time-range.end-date" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "time-range.changed-attributes-since-timestamp" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().changed_attributes_since_timestamp = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().changed_attributes_since_timestamp = Some(value.unwrap_or("").to_string()); }, "time-range.start-date" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "start-row" => { request_time_range_init(&mut request); @@ -502,8 +509,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -514,7 +520,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().get(&self.opt.arg_report_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -546,8 +552,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -560,7 +565,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.reports().get_file(&self.opt.arg_report_id, report_fragment); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -595,7 +600,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { } else { io::copy(&mut response, &mut ostream).unwrap(); @@ -608,10 +612,10 @@ impl Engine { fn _reports_request(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ReportRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -631,9 +635,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -652,31 +657,31 @@ impl Engine { match &field_name.to_string()[..] { "report-scope.ad-group-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().ad_group_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().ad_group_id = Some(value.unwrap_or("").to_string()); }, "report-scope.agency-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().agency_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().agency_id = Some(value.unwrap_or("").to_string()); }, "report-scope.engine-account-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().engine_account_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().engine_account_id = Some(value.unwrap_or("").to_string()); }, "report-scope.campaign-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().campaign_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().campaign_id = Some(value.unwrap_or("").to_string()); }, "report-scope.advertiser-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().advertiser_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().advertiser_id = Some(value.unwrap_or("").to_string()); }, "report-scope.keyword-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().keyword_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().keyword_id = Some(value.unwrap_or("").to_string()); }, "report-scope.ad-id" => { request_report_scope_init(&mut request); - request.report_scope.as_mut().unwrap().ad_id = value.unwrap_or("").to_string(); + request.report_scope.as_mut().unwrap().ad_id = Some(value.unwrap_or("").to_string()); }, "max-rows-per-file" => { request_report_scope_init(&mut request); @@ -688,19 +693,19 @@ impl Engine { }, "time-range.changed-metrics-since-timestamp" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().changed_metrics_since_timestamp = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().changed_metrics_since_timestamp = Some(value.unwrap_or("").to_string()); }, "time-range.end-date" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "time-range.changed-attributes-since-timestamp" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().changed_attributes_since_timestamp = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().changed_attributes_since_timestamp = Some(value.unwrap_or("").to_string()); }, "time-range.start-date" => { request_time_range_init(&mut request); - request.time_range.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.time_range.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "start-row" => { request_time_range_init(&mut request); @@ -747,8 +752,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -759,7 +763,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.saved_columns().list(&self.opt.arg_agency_id, &self.opt.arg_advertiser_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -791,8 +795,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -818,7 +821,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_reports { if self.opt.cmd_generate { call_result = self._reports_generate(dry_run, &mut err); } else if self.opt.cmd_get { @@ -830,7 +834,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_saved_columns { + } + else if self.opt.cmd_saved_columns { if self.opt.cmd_list { call_result = self._saved_columns_list(dry_run, &mut err); } else { @@ -856,21 +861,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "doubleclicksearch2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "doubleclicksearch2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "doubleclicksearch2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "doubleclicksearch2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Doubleclicksearch::new(hyper::Client::new(), auth), + hub: api::Doubleclicksearch::new(client, auth), }; match engine._doit(true) { @@ -890,12 +911,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/doubleclicksearch2/Cargo.toml b/gen/doubleclicksearch2/Cargo.toml index 09e14df66a..cc2a7ec17b 100644 --- a/gen/doubleclicksearch2/Cargo.toml +++ b/gen/doubleclicksearch2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-doubleclicksearch2" version = "0.1.5+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/doubleclick-search/" diff --git a/gen/doubleclicksearch2/src/cmn.rs b/gen/doubleclicksearch2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/doubleclicksearch2/src/cmn.rs +++ b/gen/doubleclicksearch2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/doubleclicksearch2/src/lib.rs b/gen/doubleclicksearch2/src/lib.rs index f225e90f33..dfad7d3e36 100644 --- a/gen/doubleclicksearch2/src/lib.rs +++ b/gen/doubleclicksearch2/src/lib.rs @@ -344,9 +344,9 @@ impl<'a, C, A> Doubleclicksearch<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomDimension { /// Custom dimension name. - pub name: String, + pub name: Option<String>, /// Custom dimension value. - pub value: String, + pub value: Option<String>, } impl Part for CustomDimension {} @@ -359,9 +359,9 @@ impl Part for CustomDimension {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomMetric { /// Custom metric name. - pub name: String, + pub name: Option<String>, /// Custom metric numeric value. - pub value: f64, + pub value: Option<f64>, } impl Part for CustomMetric {} @@ -375,78 +375,78 @@ impl Part for CustomMetric {} pub struct Conversion { /// Custom dimensions for the conversion, which can be used to filter data in a report. #[serde(rename="customDimension")] - pub custom_dimension: Vec<CustomDimension>, + pub custom_dimension: Option<Vec<CustomDimension>>, /// DS ad group ID. #[serde(rename="adGroupId")] - pub ad_group_id: String, + pub ad_group_id: Option<String>, /// The numeric segmentation identifier (for example, DoubleClick Search Floodlight activity ID). #[serde(rename="segmentationId")] - pub segmentation_id: String, + pub segmentation_id: Option<String>, /// Attribution model name. This field is ignored. #[serde(rename="attributionModel")] - pub attribution_model: String, + pub attribution_model: Option<String>, /// DS campaign ID. #[serde(rename="campaignId")] - pub campaign_id: String, + pub campaign_id: Option<String>, /// The revenue amount of this TRANSACTION conversion, in micros. #[serde(rename="revenueMicros")] - pub revenue_micros: String, + pub revenue_micros: Option<String>, /// DS advertiser ID. #[serde(rename="advertiserId")] - pub advertiser_id: String, + pub advertiser_id: Option<String>, /// The quantity of this conversion, in millis. #[serde(rename="quantityMillis")] - pub quantity_millis: String, + pub quantity_millis: Option<String>, /// The number of conversions, formatted in millis (conversions multiplied by 1000). This field is ignored. #[serde(rename="countMillis")] - pub count_millis: String, + pub count_millis: Option<String>, /// DS criterion (keyword) ID. #[serde(rename="criterionId")] - pub criterion_id: String, + pub criterion_id: Option<String>, /// The time at which the conversion took place, in epoch millis UTC. #[serde(rename="conversionTimestamp")] - pub conversion_timestamp: String, + pub conversion_timestamp: Option<String>, /// The advertiser-provided order id for the conversion. #[serde(rename="floodlightOrderId")] - pub floodlight_order_id: String, + pub floodlight_order_id: Option<String>, /// The segmentation type of this conversion (for example, FLOODLIGHT). #[serde(rename="segmentationType")] - pub segmentation_type: String, + pub segmentation_type: Option<String>, /// DS click ID for the conversion. #[serde(rename="clickId")] - pub click_id: String, + pub click_id: Option<String>, /// Custom metrics for the conversion. #[serde(rename="customMetric")] - pub custom_metric: Vec<CustomMetric>, + pub custom_metric: Option<Vec<CustomMetric>>, /// DS conversion ID. #[serde(rename="dsConversionId")] - pub ds_conversion_id: String, + pub ds_conversion_id: Option<String>, /// DS engine account ID. #[serde(rename="engineAccountId")] - pub engine_account_id: String, + pub engine_account_id: Option<String>, /// The time at which the conversion was last modified, in epoch millis UTC. #[serde(rename="conversionModifiedTimestamp")] - pub conversion_modified_timestamp: String, + pub conversion_modified_timestamp: Option<String>, /// The currency code for the conversion's revenue. Should be in ISO 4217 alphabetic (3-char) format. #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option<String>, /// The friendly segmentation identifier (for example, DoubleClick Search Floodlight activity name). #[serde(rename="segmentationName")] - pub segmentation_name: String, + pub segmentation_name: Option<String>, /// The state of the conversion, that is, either ACTIVE or REMOVED. Note: state DELETED is deprecated. - pub state: String, + pub state: Option<String>, /// DS ad ID. #[serde(rename="adId")] - pub ad_id: String, + pub ad_id: Option<String>, /// DS agency ID. #[serde(rename="agencyId")] - pub agency_id: String, + pub agency_id: Option<String>, /// Advertiser-provided ID for the conversion, also known as the order ID. #[serde(rename="conversionId")] - pub conversion_id: String, + pub conversion_id: Option<String>, /// The type of the conversion, that is, either ACTION or TRANSACTION. An ACTION conversion is an action by the user that has no monetarily quantifiable value, while a TRANSACTION conversion is an action that does have a monetarily quantifiable value. Examples are email list signups (ACTION) versus ecommerce purchases (TRANSACTION). #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for Conversion {} @@ -457,7 +457,7 @@ impl Part for Conversion {} /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ReportRow(HashMap<String, String>); +pub struct ReportRow(Option<HashMap<String, String>>); impl Part for ReportRow {} @@ -469,10 +469,10 @@ impl Part for ReportRow {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportFiles { /// Use this url to download the report file. - pub url: String, + pub url: Option<String>, /// The size of this report file in bytes. #[serde(rename="byteCount")] - pub byte_count: i64, + pub byte_count: Option<i64>, } impl NestedType for ReportFiles {} @@ -487,25 +487,25 @@ impl Part for ReportFiles {} pub struct ReportRequestReportScope { /// DS advertiser ID. #[serde(rename="advertiserId")] - pub advertiser_id: String, + pub advertiser_id: Option<String>, /// DS ad group ID. #[serde(rename="adGroupId")] - pub ad_group_id: String, + pub ad_group_id: Option<String>, /// DS keyword ID. #[serde(rename="keywordId")] - pub keyword_id: String, + pub keyword_id: Option<String>, /// DS ad ID. #[serde(rename="adId")] - pub ad_id: String, + pub ad_id: Option<String>, /// DS agency ID. #[serde(rename="agencyId")] - pub agency_id: String, + pub agency_id: Option<String>, /// DS engine account ID. #[serde(rename="engineAccountId")] - pub engine_account_id: String, + pub engine_account_id: Option<String>, /// DS campaign ID. #[serde(rename="campaignId")] - pub campaign_id: String, + pub campaign_id: Option<String>, } impl NestedType for ReportRequestReportScope {} @@ -519,11 +519,11 @@ impl Part for ReportRequestReportScope {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportRequestFilters { /// Column to perform the filter on. This can be a DoubleClick Search column or a saved column. - pub column: ReportApiColumnSpec, + pub column: Option<ReportApiColumnSpec>, /// Operator to use in the filter. See the filter reference for a list of available operators. - pub operator: String, + pub operator: Option<String>, /// A list of values to filter the column value against. - pub values: Vec<String>, + pub values: Option<Vec<String>>, } impl NestedType for ReportRequestFilters {} @@ -537,10 +537,10 @@ impl Part for ReportRequestFilters {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportRequestOrderBy { /// Column to perform the sort on. This can be a DoubleClick Search-defined column or a saved column. - pub column: ReportApiColumnSpec, + pub column: Option<ReportApiColumnSpec>, /// The sort direction, which is either ascending or descending. #[serde(rename="sortOrder")] - pub sort_order: String, + pub sort_order: Option<String>, } impl NestedType for ReportRequestOrderBy {} @@ -555,32 +555,32 @@ impl Part for ReportRequestOrderBy {} pub struct ReportApiColumnSpec { /// Synchronous report only. Set to true to group by this column. Defaults to false. #[serde(rename="groupByColumn")] - pub group_by_column: bool, + pub group_by_column: Option<bool>, /// Inclusive day in YYYY-MM-DD format. When provided, this overrides the overall time range of the report for this column only. Must be provided together with startDate. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// Name of a saved column to include in the report. The report must be scoped at advertiser or lower, and this saved column must already be created in the DoubleClick Search UI. #[serde(rename="savedColumnName")] - pub saved_column_name: String, + pub saved_column_name: Option<String>, /// Segments a report by a custom dimension. The report must be scoped to an advertiser or lower, and the custom dimension must already be set up in DoubleClick Search. The custom dimension name, which appears in DoubleClick Search, is case sensitive. /// If used in a conversion report, returns the value of the specified custom dimension for the given conversion, if set. This column does not segment the conversion report. #[serde(rename="customDimensionName")] - pub custom_dimension_name: String, + pub custom_dimension_name: Option<String>, /// Text used to identify this column in the report output; defaults to columnName or savedColumnName when not specified. This can be used to prevent collisions between DoubleClick Search columns and saved columns with the same name. #[serde(rename="headerText")] - pub header_text: String, + pub header_text: Option<String>, /// Name of a DoubleClick Search column to include in the report. #[serde(rename="columnName")] - pub column_name: String, + pub column_name: Option<String>, /// The platform that is used to provide data for the custom dimension. Acceptable values are "Floodlight". #[serde(rename="platformSource")] - pub platform_source: String, + pub platform_source: Option<String>, /// Inclusive date in YYYY-MM-DD format. When provided, this overrides the overall time range of the report for this column only. Must be provided together with endDate. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// Name of a custom metric to include in the report. The report must be scoped to an advertiser or lower, and the custom metric must already be set up in DoubleClick Search. The custom metric name, which appears in DoubleClick Search, is case sensitive. #[serde(rename="customMetricName")] - pub custom_metric_name: String, + pub custom_metric_name: Option<String>, } impl Part for ReportApiColumnSpec {} @@ -594,22 +594,22 @@ impl Part for ReportApiColumnSpec {} pub struct Availability { /// DS advertiser ID. #[serde(rename="advertiserId")] - pub advertiser_id: String, + pub advertiser_id: Option<String>, /// The numeric segmentation identifier (for example, DoubleClick Search Floodlight activity ID). #[serde(rename="segmentationId")] - pub segmentation_id: String, + pub segmentation_id: Option<String>, /// The segmentation type that this availability is for (its default value is FLOODLIGHT). #[serde(rename="segmentationType")] - pub segmentation_type: String, + pub segmentation_type: Option<String>, /// DS agency ID. #[serde(rename="agencyId")] - pub agency_id: String, + pub agency_id: Option<String>, /// The friendly segmentation identifier (for example, DoubleClick Search Floodlight activity name). #[serde(rename="segmentationName")] - pub segmentation_name: String, + pub segmentation_name: Option<String>, /// The time by which all conversions have been uploaded, in epoch millis UTC. #[serde(rename="availabilityTimestamp")] - pub availability_timestamp: String, + pub availability_timestamp: Option<String>, } impl Part for Availability {} @@ -687,27 +687,27 @@ impl RequestValue for ReportRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// Asynchronous report only. Contains a list of generated report files once the report has succesfully completed. - pub files: Vec<ReportFiles>, + pub files: Option<Vec<ReportFiles>>, /// Identifies this as a Report resource. Value: the fixed string doubleclicksearch#report. - pub kind: String, + pub kind: Option<String>, /// Synchronous report only. Generated report rows. - pub rows: Vec<ReportRow>, + pub rows: Option<Vec<ReportRow>>, /// The request that created the report. Optional fields not specified in the original request are filled with default values. - pub request: ReportRequest, + pub request: Option<ReportRequest>, /// Asynchronous report only. True if and only if the report has completed successfully and the report files are ready to be downloaded. #[serde(rename="isReportReady")] - pub is_report_ready: bool, + pub is_report_ready: Option<bool>, /// The number of report rows generated by the report, not including headers. #[serde(rename="rowCount")] - pub row_count: i32, + pub row_count: Option<i32>, /// If all statistics of the report are sourced from the same time zone, this would be it. Otherwise the field is unset. #[serde(rename="statisticsTimeZone")] - pub statistics_time_zone: String, + pub statistics_time_zone: Option<String>, /// The currency code of all monetary values produced in the report, including values that are set by users (e.g., keyword bid settings) and metrics (e.g., cost and revenue). The currency code of a report is determined by the statisticsCurrency field of the report request. #[serde(rename="statisticsCurrencyCode")] - pub statistics_currency_code: String, + pub statistics_currency_code: Option<String>, /// Asynchronous report only. Id of the report. - pub id: String, + pub id: Option<String>, } impl Resource for Report {} @@ -722,16 +722,16 @@ impl ResponseResult for Report {} pub struct ReportRequestTimeRange { /// Inclusive UTC timestamp in RFC format, e.g., 2013-07-16T10:16:23.555Z. See additional references on how changed metrics reports work. #[serde(rename="changedMetricsSinceTimestamp")] - pub changed_metrics_since_timestamp: String, + pub changed_metrics_since_timestamp: Option<String>, /// Inclusive date in YYYY-MM-DD format. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// Inclusive UTC timestamp in RFC format, e.g., 2013-07-16T10:16:23.555Z. See additional references on how changed attribute reports work. #[serde(rename="changedAttributesSinceTimestamp")] - pub changed_attributes_since_timestamp: String, + pub changed_attributes_since_timestamp: Option<String>, /// Inclusive date in YYYY-MM-DD format. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, } impl NestedType for ReportRequestTimeRange {} @@ -750,9 +750,9 @@ impl Part for ReportRequestTimeRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SavedColumnList { /// The saved columns being requested. - pub items: Vec<SavedColumn>, + pub items: Option<Vec<SavedColumn>>, /// Identifies this as a SavedColumnList resource. Value: the fixed string doubleclicksearch#savedColumnList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for SavedColumnList {} @@ -812,7 +812,7 @@ impl RequestValue for UpdateAvailabilityRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UpdateAvailabilityResponse { /// The availabilities being returned. - pub availabilities: Vec<Availability>, + pub availabilities: Option<Vec<Availability>>, } impl ResponseResult for UpdateAvailabilityResponse {} @@ -1207,7 +1207,7 @@ impl<'a, C, A> ReportMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ConversionList = Default::default(); +/// let mut req = ConversionList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1273,16 +1273,20 @@ impl<'a, C, A> ConversionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1538,16 +1542,20 @@ impl<'a, C, A> ConversionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1775,7 +1783,7 @@ impl<'a, C, A> ConversionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UpdateAvailabilityRequest = Default::default(); +/// let mut req = UpdateAvailabilityRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1841,16 +1849,20 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1993,7 +2005,7 @@ impl<'a, C, A> ConversionUpdateAvailabilityCall<'a, C, A> where C: BorrowMut<hyp /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ConversionList = Default::default(); +/// let mut req = ConversionList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2073,16 +2085,20 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2295,7 +2311,7 @@ impl<'a, C, A> ConversionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ConversionList = Default::default(); +/// let mut req = ConversionList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2361,16 +2377,20 @@ impl<'a, C, A> ConversionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2596,16 +2616,20 @@ impl<'a, C, A> SavedColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2840,16 +2864,20 @@ impl<'a, C, A> ReportGetFileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2989,7 +3017,7 @@ impl<'a, C, A> ReportGetFileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ReportRequest = Default::default(); +/// let mut req = ReportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3055,16 +3083,20 @@ impl<'a, C, A> ReportGenerateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3288,16 +3320,20 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3437,7 +3473,7 @@ impl<'a, C, A> ReportGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ReportRequest = Default::default(); +/// let mut req = ReportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3503,16 +3539,20 @@ impl<'a, C, A> ReportRequestCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/drive2-cli/Cargo.toml b/gen/drive2-cli/Cargo.toml deleted file mode 100644 index 9d1689d58e..0000000000 --- a/gen/drive2-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-drive2-cli" -version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with drive (protocol v2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/drive2-cli" -homepage = "https://developers.google.com/drive/" -documentation = "http://byron.github.io/google-apis-rs/google_drive2_cli" -license = "MIT" -keywords = ["drive", "google", "cli"] - -[[bin]] -name = "drive2" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-drive2] -path = "../drive2" diff --git a/gen/drive2-cli/LICENSE.md b/gen/drive2-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/drive2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/drive2-cli/mkdocs.yml b/gen/drive2-cli/mkdocs.yml deleted file mode 100644 index 37a34c2823..0000000000 --- a/gen/drive2-cli/mkdocs.yml +++ /dev/null @@ -1,75 +0,0 @@ -site_name: drive v0.0.1+20150326 -site_url: http://byron.github.io/google-apis-rs/google-drive2-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/drive2-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['about_get.md', 'About', 'Get'] -- ['apps_get.md', 'Apps', 'Get'] -- ['apps_list.md', 'Apps', 'List'] -- ['changes_get.md', 'Changes', 'Get'] -- ['changes_list.md', 'Changes', 'List'] -- ['changes_watch.md', 'Changes', 'Watch'] -- ['channels_stop.md', 'Channels', 'Stop'] -- ['children_delete.md', 'Children', 'Delete'] -- ['children_get.md', 'Children', 'Get'] -- ['children_insert.md', 'Children', 'Insert'] -- ['children_list.md', 'Children', 'List'] -- ['comments_delete.md', 'Comments', 'Delete'] -- ['comments_get.md', 'Comments', 'Get'] -- ['comments_insert.md', 'Comments', 'Insert'] -- ['comments_list.md', 'Comments', 'List'] -- ['comments_patch.md', 'Comments', 'Patch'] -- ['comments_update.md', 'Comments', 'Update'] -- ['files_copy.md', 'Files', 'Copy'] -- ['files_delete.md', 'Files', 'Delete'] -- ['files_empty-trash.md', 'Files', 'Empty Trash'] -- ['files_get.md', 'Files', 'Get'] -- ['files_insert.md', 'Files', 'Insert'] -- ['files_list.md', 'Files', 'List'] -- ['files_patch.md', 'Files', 'Patch'] -- ['files_touch.md', 'Files', 'Touch'] -- ['files_trash.md', 'Files', 'Trash'] -- ['files_untrash.md', 'Files', 'Untrash'] -- ['files_update.md', 'Files', 'Update'] -- ['files_watch.md', 'Files', 'Watch'] -- ['parents_delete.md', 'Parents', 'Delete'] -- ['parents_get.md', 'Parents', 'Get'] -- ['parents_insert.md', 'Parents', 'Insert'] -- ['parents_list.md', 'Parents', 'List'] -- ['permissions_delete.md', 'Permissions', 'Delete'] -- ['permissions_get.md', 'Permissions', 'Get'] -- ['permissions_get-id-for-email.md', 'Permissions', 'Get Id For Email'] -- ['permissions_insert.md', 'Permissions', 'Insert'] -- ['permissions_list.md', 'Permissions', 'List'] -- ['permissions_patch.md', 'Permissions', 'Patch'] -- ['permissions_update.md', 'Permissions', 'Update'] -- ['properties_delete.md', 'Properties', 'Delete'] -- ['properties_get.md', 'Properties', 'Get'] -- ['properties_insert.md', 'Properties', 'Insert'] -- ['properties_list.md', 'Properties', 'List'] -- ['properties_patch.md', 'Properties', 'Patch'] -- ['properties_update.md', 'Properties', 'Update'] -- ['realtime_get.md', 'Realtime', 'Get'] -- ['realtime_update.md', 'Realtime', 'Update'] -- ['replies_delete.md', 'Replies', 'Delete'] -- ['replies_get.md', 'Replies', 'Get'] -- ['replies_insert.md', 'Replies', 'Insert'] -- ['replies_list.md', 'Replies', 'List'] -- ['replies_patch.md', 'Replies', 'Patch'] -- ['replies_update.md', 'Replies', 'Update'] -- ['revisions_delete.md', 'Revisions', 'Delete'] -- ['revisions_get.md', 'Revisions', 'Get'] -- ['revisions_list.md', 'Revisions', 'List'] -- ['revisions_patch.md', 'Revisions', 'Patch'] -- ['revisions_update.md', 'Revisions', 'Update'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/drive2-cli/src/cmn.rs b/gen/drive2-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/drive2-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/drive2-cli/src/main.rs b/gen/drive2-cli/src/main.rs deleted file mode 100644 index f66e33278f..0000000000 --- a/gen/drive2-cli/src/main.rs +++ /dev/null @@ -1,6319 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_drive2 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Drive<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _about_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.about().get(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-change-id" => { - call = call.start_change_id(value.unwrap_or("")); - }, - "max-change-id-count" => { - call = call.max_change_id_count(arg_from_str(value.unwrap_or("-0"), err, "max-change-id-count", "int64")); - }, - "include-subscribed" => { - call = call.include_subscribed(arg_from_str(value.unwrap_or("false"), err, "include-subscribed", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _apps_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.apps().get(&self.opt.arg_app_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _apps_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.apps().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "language-code" => { - call = call.language_code(value.unwrap_or("")); - }, - "app-filter-mime-types" => { - call = call.app_filter_mime_types(value.unwrap_or("")); - }, - "app-filter-extensions" => { - call = call.app_filter_extensions(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _changes_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.changes().get(&self.opt.arg_change_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _changes_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.changes().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-change-id" => { - call = call.start_change_id(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")); - }, - "include-subscribed" => { - call = call.include_subscribed(arg_from_str(value.unwrap_or("false"), err, "include-subscribed", "boolean")); - }, - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _changes_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Channel = Default::default(); - let mut call = self.hub.changes().watch(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "start-change-id" => { - call = call.start_change_id(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")); - }, - "include-subscribed" => { - call = call.include_subscribed(arg_from_str(value.unwrap_or("false"), err, "include-subscribed", "boolean")); - }, - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _children_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.children().delete(&self.opt.arg_folder_id, &self.opt.arg_child_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _children_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.children().get(&self.opt.arg_folder_id, &self.opt.arg_child_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _children_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::ChildReference = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _children_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.children().list(&self.opt.arg_folder_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "q" => { - call = call.q(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comments_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.comments().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _comments_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.comments().get(&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); - match key { - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Comment = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::Comment) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - fn request_context_init(request: &mut api::Comment) { - if request.context.is_none() { - request.context = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "file-title" => { - request_author_init(&mut request); - request.file_title = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "context.type" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "context.value" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "created-date" => { - request_context_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "comment-id" => { - request_context_init(&mut request); - request.comment_id = Some(value.unwrap_or("").to_string()); - }, - "anchor" => { - request_context_init(&mut request); - request.anchor = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_context_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "file-id" => { - request_context_init(&mut request); - request.file_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comments_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.comments().list(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "updated-min" => { - call = call.updated_min(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")); - }, - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Comment = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::Comment) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - fn request_context_init(request: &mut api::Comment) { - if request.context.is_none() { - request.context = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "file-title" => { - request_author_init(&mut request); - request.file_title = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "context.type" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "context.value" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "created-date" => { - request_context_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "comment-id" => { - request_context_init(&mut request); - request.comment_id = Some(value.unwrap_or("").to_string()); - }, - "anchor" => { - request_context_init(&mut request); - request.anchor = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_context_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "file-id" => { - request_context_init(&mut request); - request.file_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _comments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Comment = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::Comment) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - fn request_context_init(request: &mut api::Comment) { - if request.context.is_none() { - request.context = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "status" => { - request.status = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "file-title" => { - request_author_init(&mut request); - request.file_title = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "context.type" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "context.value" => { - request_context_init(&mut request); - request.context.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "created-date" => { - request_context_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "comment-id" => { - request_context_init(&mut request); - request.comment_id = Some(value.unwrap_or("").to_string()); - }, - "anchor" => { - request_context_init(&mut request); - request.anchor = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_context_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "file-id" => { - request_context_init(&mut request); - request.file_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::default(); - 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); - 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 mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_image_media_metadata_init(request: &mut api::File) { - if request.image_media_metadata.is_none() { - request.image_media_metadata = Some(Default::default()); - } - } - - fn request_indexable_text_init(request: &mut api::File) { - if request.indexable_text.is_none() { - request.indexable_text = Some(Default::default()); - } - } - - fn request_labels_init(request: &mut api::File) { - if request.labels.is_none() { - request.labels = Some(Default::default()); - } - } - - fn request_last_modifying_user_init(request: &mut api::File) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - fn request_sharing_user_init(request: &mut api::File) { - if request.sharing_user.is_none() { - request.sharing_user = Some(Default::default()); - } - } - - fn request_thumbnail_init(request: &mut api::File) { - if request.thumbnail.is_none() { - request.thumbnail = Some(Default::default()); - } - } - - fn request_user_permission_init(request: &mut api::File) { - if request.user_permission.is_none() { - request.user_permission = Some(Default::default()); - } - } - - fn request_video_media_metadata_init(request: &mut api::File) { - if request.video_media_metadata.is_none() { - request.video_media_metadata = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "last-viewed-by-me-date" => { - request.last_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "app-data-contents" => { - request.app_data_contents = Some(arg_from_str(value.unwrap_or("false"), err, "app-data-contents", "boolean")); - }, - "thumbnail-link" => { - request.thumbnail_link = Some(value.unwrap_or("").to_string()); - }, - "labels.restricted" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "labels.restricted", "boolean"); - }, - "labels.hidden" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().hidden = arg_from_str(value.unwrap_or("false"), err, "labels.hidden", "boolean"); - }, - "labels.viewed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().viewed = arg_from_str(value.unwrap_or("false"), err, "labels.viewed", "boolean"); - }, - "labels.starred" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().starred = arg_from_str(value.unwrap_or("false"), err, "labels.starred", "boolean"); - }, - "labels.trashed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().trashed = arg_from_str(value.unwrap_or("false"), err, "labels.trashed", "boolean"); - }, - "indexable-text.text" => { - request_indexable_text_init(&mut request); - request.indexable_text.as_mut().unwrap().text = value.unwrap_or("").to_string(); - }, - "explicitly-trashed" => { - request_indexable_text_init(&mut request); - request.explicitly_trashed = Some(arg_from_str(value.unwrap_or("false"), err, "explicitly-trashed", "boolean")); - }, - "etag" => { - request_indexable_text_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_indexable_text_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "writers-can-share" => { - request_indexable_text_init(&mut request); - request.writers_can_share = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-share", "boolean")); - }, - "id" => { - request_indexable_text_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "sharing-user.picture.url" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "sharing-user.kind" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "sharing-user.display-name" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "sharing-user.permission-id" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "sharing-user.is-authenticated-user" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "sharing-user.is-authenticated-user", "boolean"); - }, - "sharing-user.email-address" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "video-media-metadata.width" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.width", "integer"); - }, - "video-media-metadata.duration-millis" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().duration_millis = value.unwrap_or("").to_string(); - }, - "video-media-metadata.height" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.height", "integer"); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "copyable" => { - request_last_modifying_user_init(&mut request); - request.copyable = Some(arg_from_str(value.unwrap_or("false"), err, "copyable", "boolean")); - }, - "folder-color-rgb" => { - request_last_modifying_user_init(&mut request); - request.folder_color_rgb = Some(value.unwrap_or("").to_string()); - }, - "owner-names" => { - request_last_modifying_user_init(&mut request); - if request.owner_names.is_none() { - request.owner_names = Some(Default::default()); - } - request.owner_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared-with-me-date" => { - request_last_modifying_user_init(&mut request); - request.shared_with_me_date = Some(value.unwrap_or("").to_string()); - }, - "web-view-link" => { - request_last_modifying_user_init(&mut request); - request.web_view_link = Some(value.unwrap_or("").to_string()); - }, - "version" => { - request_last_modifying_user_init(&mut request); - request.version = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared" => { - request_last_modifying_user_init(&mut request); - request.shared = Some(arg_from_str(value.unwrap_or("false"), err, "shared", "boolean")); - }, - "thumbnail.mime-type" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); - }, - "thumbnail.image" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().image = value.unwrap_or("").to_string(); - }, - "open-with-links" => { - request_thumbnail_init(&mut request); - if request.open_with_links.is_none() { - request.open_with_links = Some(Default::default()); - } - request.open_with_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "image-media-metadata.exposure-bias" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_bias = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-bias", "number"); - }, - "image-media-metadata.exposure-time" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_time = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-time", "number"); - }, - "image-media-metadata.max-aperture-value" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().max_aperture_value = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.max-aperture-value", "number"); - }, - "image-media-metadata.width" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.width", "integer"); - }, - "image-media-metadata.focal-length" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().focal_length = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.focal-length", "number"); - }, - "image-media-metadata.camera-make" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_make = value.unwrap_or("").to_string(); - }, - "image-media-metadata.exposure-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.color-space" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().color_space = value.unwrap_or("").to_string(); - }, - "image-media-metadata.location.latitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.latitude", "number"); - }, - "image-media-metadata.location.altitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.altitude", "number"); - }, - "image-media-metadata.location.longitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.longitude", "number"); - }, - "image-media-metadata.subject-distance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().subject_distance = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.subject-distance", "integer"); - }, - "image-media-metadata.height" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.height", "integer"); - }, - "image-media-metadata.lens" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().lens = value.unwrap_or("").to_string(); - }, - "image-media-metadata.date" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().date = value.unwrap_or("").to_string(); - }, - "image-media-metadata.iso-speed" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().iso_speed = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.iso-speed", "integer"); - }, - "image-media-metadata.metering-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().metering_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.flash-used" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().flash_used = arg_from_str(value.unwrap_or("false"), err, "image-media-metadata.flash-used", "boolean"); - }, - "image-media-metadata.aperture" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().aperture = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.aperture", "number"); - }, - "image-media-metadata.rotation" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().rotation = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.rotation", "integer"); - }, - "image-media-metadata.sensor" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().sensor = value.unwrap_or("").to_string(); - }, - "image-media-metadata.white-balance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().white_balance = value.unwrap_or("").to_string(); - }, - "image-media-metadata.camera-model" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_model = value.unwrap_or("").to_string(); - }, - "description" => { - request_image_media_metadata_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "web-content-link" => { - request_image_media_metadata_init(&mut request); - request.web_content_link = Some(value.unwrap_or("").to_string()); - }, - "editable" => { - request_image_media_metadata_init(&mut request); - request.editable = Some(arg_from_str(value.unwrap_or("false"), err, "editable", "boolean")); - }, - "embed-link" => { - request_image_media_metadata_init(&mut request); - request.embed_link = Some(value.unwrap_or("").to_string()); - }, - "marked-viewed-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.marked_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "quota-bytes-used" => { - request_image_media_metadata_init(&mut request); - request.quota_bytes_used = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_image_media_metadata_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_image_media_metadata_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_image_media_metadata_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "icon-link" => { - request_image_media_metadata_init(&mut request); - request.icon_link = Some(value.unwrap_or("").to_string()); - }, - "default-open-with-link" => { - request_image_media_metadata_init(&mut request); - request.default_open_with_link = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_image_media_metadata_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "alternate-link" => { - request_image_media_metadata_init(&mut request); - request.alternate_link = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request_image_media_metadata_init(&mut request); - request.title = Some(value.unwrap_or("").to_string()); - }, - "modified-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.modified_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_image_media_metadata_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "user-permission.with-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().with_link = Some(arg_from_str(value.unwrap_or("false"), err, "user-permission.with-link", "boolean")); - }, - "user-permission.domain" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().domain = Some(value.unwrap_or("").to_string()); - }, - "user-permission.name" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); - }, - "user-permission.kind" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "user-permission.value" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); - }, - "user-permission.id" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "user-permission.auth-key" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().auth_key = Some(value.unwrap_or("").to_string()); - }, - "user-permission.etag" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); - }, - "user-permission.email-address" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().email_address = Some(value.unwrap_or("").to_string()); - }, - "user-permission.photo-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().photo_link = Some(value.unwrap_or("").to_string()); - }, - "user-permission.role" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().role = Some(value.unwrap_or("").to_string()); - }, - "user-permission.type" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - "user-permission.additional-roles" => { - request_user_permission_init(&mut request); - if request.user_permission.as_mut().unwrap().additional_roles.is_none() { - request.user_permission.as_mut().unwrap().additional_roles = Some(Default::default()); - } - request.user_permission.as_mut().unwrap().additional_roles.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "user-permission.self-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_user_permission_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "file-extension" => { - request_user_permission_init(&mut request); - request.file_extension = Some(value.unwrap_or("").to_string()); - }, - "head-revision-id" => { - request_user_permission_init(&mut request); - request.head_revision_id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_user_permission_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_user_permission_init(&mut request); - request.modified_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().delete(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _files_empty_trash(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().empty_trash(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _files_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut download_mode = false; - let mut call = self.hub.files().get(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "update-viewed-date" => { - call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); - }, - "revision-id" => { - call = call.revision_id(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "alt" => { - if value.unwrap_or("") == "media" { - download_mode = true; - } - call = call.alt(value.unwrap_or("")); - }, - "acknowledge-abuse" => { - call = call.acknowledge_abuse(arg_from_str(value.unwrap_or("false"), err, "acknowledge-abuse", "boolean")); - }, - "fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - } else { - io::copy(&mut response, &mut ostream).unwrap(); - } - None - } - } - } - } - - fn _files_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::File = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_image_media_metadata_init(request: &mut api::File) { - if request.image_media_metadata.is_none() { - request.image_media_metadata = Some(Default::default()); - } - } - - fn request_indexable_text_init(request: &mut api::File) { - if request.indexable_text.is_none() { - request.indexable_text = Some(Default::default()); - } - } - - fn request_labels_init(request: &mut api::File) { - if request.labels.is_none() { - request.labels = Some(Default::default()); - } - } - - fn request_last_modifying_user_init(request: &mut api::File) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - fn request_sharing_user_init(request: &mut api::File) { - if request.sharing_user.is_none() { - request.sharing_user = Some(Default::default()); - } - } - - fn request_thumbnail_init(request: &mut api::File) { - if request.thumbnail.is_none() { - request.thumbnail = Some(Default::default()); - } - } - - fn request_user_permission_init(request: &mut api::File) { - if request.user_permission.is_none() { - request.user_permission = Some(Default::default()); - } - } - - fn request_video_media_metadata_init(request: &mut api::File) { - if request.video_media_metadata.is_none() { - request.video_media_metadata = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "last-viewed-by-me-date" => { - request.last_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "app-data-contents" => { - request.app_data_contents = Some(arg_from_str(value.unwrap_or("false"), err, "app-data-contents", "boolean")); - }, - "thumbnail-link" => { - request.thumbnail_link = Some(value.unwrap_or("").to_string()); - }, - "labels.restricted" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "labels.restricted", "boolean"); - }, - "labels.hidden" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().hidden = arg_from_str(value.unwrap_or("false"), err, "labels.hidden", "boolean"); - }, - "labels.viewed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().viewed = arg_from_str(value.unwrap_or("false"), err, "labels.viewed", "boolean"); - }, - "labels.starred" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().starred = arg_from_str(value.unwrap_or("false"), err, "labels.starred", "boolean"); - }, - "labels.trashed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().trashed = arg_from_str(value.unwrap_or("false"), err, "labels.trashed", "boolean"); - }, - "indexable-text.text" => { - request_indexable_text_init(&mut request); - request.indexable_text.as_mut().unwrap().text = value.unwrap_or("").to_string(); - }, - "explicitly-trashed" => { - request_indexable_text_init(&mut request); - request.explicitly_trashed = Some(arg_from_str(value.unwrap_or("false"), err, "explicitly-trashed", "boolean")); - }, - "etag" => { - request_indexable_text_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_indexable_text_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "writers-can-share" => { - request_indexable_text_init(&mut request); - request.writers_can_share = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-share", "boolean")); - }, - "id" => { - request_indexable_text_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "sharing-user.picture.url" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "sharing-user.kind" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "sharing-user.display-name" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "sharing-user.permission-id" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "sharing-user.is-authenticated-user" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "sharing-user.is-authenticated-user", "boolean"); - }, - "sharing-user.email-address" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "video-media-metadata.width" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.width", "integer"); - }, - "video-media-metadata.duration-millis" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().duration_millis = value.unwrap_or("").to_string(); - }, - "video-media-metadata.height" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.height", "integer"); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "copyable" => { - request_last_modifying_user_init(&mut request); - request.copyable = Some(arg_from_str(value.unwrap_or("false"), err, "copyable", "boolean")); - }, - "folder-color-rgb" => { - request_last_modifying_user_init(&mut request); - request.folder_color_rgb = Some(value.unwrap_or("").to_string()); - }, - "owner-names" => { - request_last_modifying_user_init(&mut request); - if request.owner_names.is_none() { - request.owner_names = Some(Default::default()); - } - request.owner_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared-with-me-date" => { - request_last_modifying_user_init(&mut request); - request.shared_with_me_date = Some(value.unwrap_or("").to_string()); - }, - "web-view-link" => { - request_last_modifying_user_init(&mut request); - request.web_view_link = Some(value.unwrap_or("").to_string()); - }, - "version" => { - request_last_modifying_user_init(&mut request); - request.version = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared" => { - request_last_modifying_user_init(&mut request); - request.shared = Some(arg_from_str(value.unwrap_or("false"), err, "shared", "boolean")); - }, - "thumbnail.mime-type" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); - }, - "thumbnail.image" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().image = value.unwrap_or("").to_string(); - }, - "open-with-links" => { - request_thumbnail_init(&mut request); - if request.open_with_links.is_none() { - request.open_with_links = Some(Default::default()); - } - request.open_with_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "image-media-metadata.exposure-bias" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_bias = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-bias", "number"); - }, - "image-media-metadata.exposure-time" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_time = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-time", "number"); - }, - "image-media-metadata.max-aperture-value" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().max_aperture_value = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.max-aperture-value", "number"); - }, - "image-media-metadata.width" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.width", "integer"); - }, - "image-media-metadata.focal-length" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().focal_length = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.focal-length", "number"); - }, - "image-media-metadata.camera-make" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_make = value.unwrap_or("").to_string(); - }, - "image-media-metadata.exposure-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.color-space" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().color_space = value.unwrap_or("").to_string(); - }, - "image-media-metadata.location.latitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.latitude", "number"); - }, - "image-media-metadata.location.altitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.altitude", "number"); - }, - "image-media-metadata.location.longitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.longitude", "number"); - }, - "image-media-metadata.subject-distance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().subject_distance = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.subject-distance", "integer"); - }, - "image-media-metadata.height" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.height", "integer"); - }, - "image-media-metadata.lens" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().lens = value.unwrap_or("").to_string(); - }, - "image-media-metadata.date" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().date = value.unwrap_or("").to_string(); - }, - "image-media-metadata.iso-speed" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().iso_speed = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.iso-speed", "integer"); - }, - "image-media-metadata.metering-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().metering_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.flash-used" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().flash_used = arg_from_str(value.unwrap_or("false"), err, "image-media-metadata.flash-used", "boolean"); - }, - "image-media-metadata.aperture" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().aperture = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.aperture", "number"); - }, - "image-media-metadata.rotation" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().rotation = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.rotation", "integer"); - }, - "image-media-metadata.sensor" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().sensor = value.unwrap_or("").to_string(); - }, - "image-media-metadata.white-balance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().white_balance = value.unwrap_or("").to_string(); - }, - "image-media-metadata.camera-model" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_model = value.unwrap_or("").to_string(); - }, - "description" => { - request_image_media_metadata_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "web-content-link" => { - request_image_media_metadata_init(&mut request); - request.web_content_link = Some(value.unwrap_or("").to_string()); - }, - "editable" => { - request_image_media_metadata_init(&mut request); - request.editable = Some(arg_from_str(value.unwrap_or("false"), err, "editable", "boolean")); - }, - "embed-link" => { - request_image_media_metadata_init(&mut request); - request.embed_link = Some(value.unwrap_or("").to_string()); - }, - "marked-viewed-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.marked_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "quota-bytes-used" => { - request_image_media_metadata_init(&mut request); - request.quota_bytes_used = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_image_media_metadata_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_image_media_metadata_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_image_media_metadata_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "icon-link" => { - request_image_media_metadata_init(&mut request); - request.icon_link = Some(value.unwrap_or("").to_string()); - }, - "default-open-with-link" => { - request_image_media_metadata_init(&mut request); - request.default_open_with_link = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_image_media_metadata_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "alternate-link" => { - request_image_media_metadata_init(&mut request); - request.alternate_link = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request_image_media_metadata_init(&mut request); - request.title = Some(value.unwrap_or("").to_string()); - }, - "modified-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.modified_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_image_media_metadata_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "user-permission.with-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().with_link = Some(arg_from_str(value.unwrap_or("false"), err, "user-permission.with-link", "boolean")); - }, - "user-permission.domain" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().domain = Some(value.unwrap_or("").to_string()); - }, - "user-permission.name" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); - }, - "user-permission.kind" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "user-permission.value" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); - }, - "user-permission.id" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "user-permission.auth-key" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().auth_key = Some(value.unwrap_or("").to_string()); - }, - "user-permission.etag" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); - }, - "user-permission.email-address" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().email_address = Some(value.unwrap_or("").to_string()); - }, - "user-permission.photo-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().photo_link = Some(value.unwrap_or("").to_string()); - }, - "user-permission.role" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().role = Some(value.unwrap_or("").to_string()); - }, - "user-permission.type" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - "user-permission.additional-roles" => { - request_user_permission_init(&mut request); - if request.user_permission.as_mut().unwrap().additional_roles.is_none() { - request.user_permission.as_mut().unwrap().additional_roles = Some(Default::default()); - } - request.user_permission.as_mut().unwrap().additional_roles.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "user-permission.self-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_user_permission_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "file-extension" => { - request_user_permission_init(&mut request); - request.file_extension = Some(value.unwrap_or("").to_string()); - }, - "head-revision-id" => { - request_user_permission_init(&mut request); - request.head_revision_id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_user_permission_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_user_permission_init(&mut request); - request.modified_date = 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" - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "q" => { - call = call.q(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(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")); - }, - "corpus" => { - call = call.corpus(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::File = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_image_media_metadata_init(request: &mut api::File) { - if request.image_media_metadata.is_none() { - request.image_media_metadata = Some(Default::default()); - } - } - - fn request_indexable_text_init(request: &mut api::File) { - if request.indexable_text.is_none() { - request.indexable_text = Some(Default::default()); - } - } - - fn request_labels_init(request: &mut api::File) { - if request.labels.is_none() { - request.labels = Some(Default::default()); - } - } - - fn request_last_modifying_user_init(request: &mut api::File) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - fn request_sharing_user_init(request: &mut api::File) { - if request.sharing_user.is_none() { - request.sharing_user = Some(Default::default()); - } - } - - fn request_thumbnail_init(request: &mut api::File) { - if request.thumbnail.is_none() { - request.thumbnail = Some(Default::default()); - } - } - - fn request_user_permission_init(request: &mut api::File) { - if request.user_permission.is_none() { - request.user_permission = Some(Default::default()); - } - } - - fn request_video_media_metadata_init(request: &mut api::File) { - if request.video_media_metadata.is_none() { - request.video_media_metadata = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "last-viewed-by-me-date" => { - request.last_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "app-data-contents" => { - request.app_data_contents = Some(arg_from_str(value.unwrap_or("false"), err, "app-data-contents", "boolean")); - }, - "thumbnail-link" => { - request.thumbnail_link = Some(value.unwrap_or("").to_string()); - }, - "labels.restricted" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "labels.restricted", "boolean"); - }, - "labels.hidden" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().hidden = arg_from_str(value.unwrap_or("false"), err, "labels.hidden", "boolean"); - }, - "labels.viewed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().viewed = arg_from_str(value.unwrap_or("false"), err, "labels.viewed", "boolean"); - }, - "labels.starred" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().starred = arg_from_str(value.unwrap_or("false"), err, "labels.starred", "boolean"); - }, - "labels.trashed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().trashed = arg_from_str(value.unwrap_or("false"), err, "labels.trashed", "boolean"); - }, - "indexable-text.text" => { - request_indexable_text_init(&mut request); - request.indexable_text.as_mut().unwrap().text = value.unwrap_or("").to_string(); - }, - "explicitly-trashed" => { - request_indexable_text_init(&mut request); - request.explicitly_trashed = Some(arg_from_str(value.unwrap_or("false"), err, "explicitly-trashed", "boolean")); - }, - "etag" => { - request_indexable_text_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_indexable_text_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "writers-can-share" => { - request_indexable_text_init(&mut request); - request.writers_can_share = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-share", "boolean")); - }, - "id" => { - request_indexable_text_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "sharing-user.picture.url" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "sharing-user.kind" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "sharing-user.display-name" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "sharing-user.permission-id" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "sharing-user.is-authenticated-user" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "sharing-user.is-authenticated-user", "boolean"); - }, - "sharing-user.email-address" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "video-media-metadata.width" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.width", "integer"); - }, - "video-media-metadata.duration-millis" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().duration_millis = value.unwrap_or("").to_string(); - }, - "video-media-metadata.height" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.height", "integer"); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "copyable" => { - request_last_modifying_user_init(&mut request); - request.copyable = Some(arg_from_str(value.unwrap_or("false"), err, "copyable", "boolean")); - }, - "folder-color-rgb" => { - request_last_modifying_user_init(&mut request); - request.folder_color_rgb = Some(value.unwrap_or("").to_string()); - }, - "owner-names" => { - request_last_modifying_user_init(&mut request); - if request.owner_names.is_none() { - request.owner_names = Some(Default::default()); - } - request.owner_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared-with-me-date" => { - request_last_modifying_user_init(&mut request); - request.shared_with_me_date = Some(value.unwrap_or("").to_string()); - }, - "web-view-link" => { - request_last_modifying_user_init(&mut request); - request.web_view_link = Some(value.unwrap_or("").to_string()); - }, - "version" => { - request_last_modifying_user_init(&mut request); - request.version = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared" => { - request_last_modifying_user_init(&mut request); - request.shared = Some(arg_from_str(value.unwrap_or("false"), err, "shared", "boolean")); - }, - "thumbnail.mime-type" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); - }, - "thumbnail.image" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().image = value.unwrap_or("").to_string(); - }, - "open-with-links" => { - request_thumbnail_init(&mut request); - if request.open_with_links.is_none() { - request.open_with_links = Some(Default::default()); - } - request.open_with_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "image-media-metadata.exposure-bias" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_bias = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-bias", "number"); - }, - "image-media-metadata.exposure-time" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_time = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-time", "number"); - }, - "image-media-metadata.max-aperture-value" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().max_aperture_value = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.max-aperture-value", "number"); - }, - "image-media-metadata.width" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.width", "integer"); - }, - "image-media-metadata.focal-length" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().focal_length = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.focal-length", "number"); - }, - "image-media-metadata.camera-make" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_make = value.unwrap_or("").to_string(); - }, - "image-media-metadata.exposure-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.color-space" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().color_space = value.unwrap_or("").to_string(); - }, - "image-media-metadata.location.latitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.latitude", "number"); - }, - "image-media-metadata.location.altitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.altitude", "number"); - }, - "image-media-metadata.location.longitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.longitude", "number"); - }, - "image-media-metadata.subject-distance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().subject_distance = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.subject-distance", "integer"); - }, - "image-media-metadata.height" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.height", "integer"); - }, - "image-media-metadata.lens" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().lens = value.unwrap_or("").to_string(); - }, - "image-media-metadata.date" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().date = value.unwrap_or("").to_string(); - }, - "image-media-metadata.iso-speed" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().iso_speed = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.iso-speed", "integer"); - }, - "image-media-metadata.metering-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().metering_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.flash-used" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().flash_used = arg_from_str(value.unwrap_or("false"), err, "image-media-metadata.flash-used", "boolean"); - }, - "image-media-metadata.aperture" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().aperture = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.aperture", "number"); - }, - "image-media-metadata.rotation" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().rotation = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.rotation", "integer"); - }, - "image-media-metadata.sensor" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().sensor = value.unwrap_or("").to_string(); - }, - "image-media-metadata.white-balance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().white_balance = value.unwrap_or("").to_string(); - }, - "image-media-metadata.camera-model" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_model = value.unwrap_or("").to_string(); - }, - "description" => { - request_image_media_metadata_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "web-content-link" => { - request_image_media_metadata_init(&mut request); - request.web_content_link = Some(value.unwrap_or("").to_string()); - }, - "editable" => { - request_image_media_metadata_init(&mut request); - request.editable = Some(arg_from_str(value.unwrap_or("false"), err, "editable", "boolean")); - }, - "embed-link" => { - request_image_media_metadata_init(&mut request); - request.embed_link = Some(value.unwrap_or("").to_string()); - }, - "marked-viewed-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.marked_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "quota-bytes-used" => { - request_image_media_metadata_init(&mut request); - request.quota_bytes_used = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_image_media_metadata_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_image_media_metadata_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_image_media_metadata_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "icon-link" => { - request_image_media_metadata_init(&mut request); - request.icon_link = Some(value.unwrap_or("").to_string()); - }, - "default-open-with-link" => { - request_image_media_metadata_init(&mut request); - request.default_open_with_link = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_image_media_metadata_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "alternate-link" => { - request_image_media_metadata_init(&mut request); - request.alternate_link = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request_image_media_metadata_init(&mut request); - request.title = Some(value.unwrap_or("").to_string()); - }, - "modified-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.modified_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_image_media_metadata_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "user-permission.with-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().with_link = Some(arg_from_str(value.unwrap_or("false"), err, "user-permission.with-link", "boolean")); - }, - "user-permission.domain" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().domain = Some(value.unwrap_or("").to_string()); - }, - "user-permission.name" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); - }, - "user-permission.kind" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "user-permission.value" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); - }, - "user-permission.id" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "user-permission.auth-key" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().auth_key = Some(value.unwrap_or("").to_string()); - }, - "user-permission.etag" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); - }, - "user-permission.email-address" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().email_address = Some(value.unwrap_or("").to_string()); - }, - "user-permission.photo-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().photo_link = Some(value.unwrap_or("").to_string()); - }, - "user-permission.role" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().role = Some(value.unwrap_or("").to_string()); - }, - "user-permission.type" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - "user-permission.additional-roles" => { - request_user_permission_init(&mut request); - if request.user_permission.as_mut().unwrap().additional_roles.is_none() { - request.user_permission.as_mut().unwrap().additional_roles = Some(Default::default()); - } - request.user_permission.as_mut().unwrap().additional_roles.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "user-permission.self-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_user_permission_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "file-extension" => { - request_user_permission_init(&mut request); - request.file_extension = Some(value.unwrap_or("").to_string()); - }, - "head-revision-id" => { - request_user_permission_init(&mut request); - request.head_revision_id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_user_permission_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_user_permission_init(&mut request); - request.modified_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_touch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().touch(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_trash(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().trash(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_untrash(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.files().untrash(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::File = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_image_media_metadata_init(request: &mut api::File) { - if request.image_media_metadata.is_none() { - request.image_media_metadata = Some(Default::default()); - } - } - - fn request_indexable_text_init(request: &mut api::File) { - if request.indexable_text.is_none() { - request.indexable_text = Some(Default::default()); - } - } - - fn request_labels_init(request: &mut api::File) { - if request.labels.is_none() { - request.labels = Some(Default::default()); - } - } - - fn request_last_modifying_user_init(request: &mut api::File) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - fn request_sharing_user_init(request: &mut api::File) { - if request.sharing_user.is_none() { - request.sharing_user = Some(Default::default()); - } - } - - fn request_thumbnail_init(request: &mut api::File) { - if request.thumbnail.is_none() { - request.thumbnail = Some(Default::default()); - } - } - - fn request_user_permission_init(request: &mut api::File) { - if request.user_permission.is_none() { - request.user_permission = Some(Default::default()); - } - } - - fn request_video_media_metadata_init(request: &mut api::File) { - if request.video_media_metadata.is_none() { - request.video_media_metadata = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "last-viewed-by-me-date" => { - request.last_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "app-data-contents" => { - request.app_data_contents = Some(arg_from_str(value.unwrap_or("false"), err, "app-data-contents", "boolean")); - }, - "thumbnail-link" => { - request.thumbnail_link = Some(value.unwrap_or("").to_string()); - }, - "labels.restricted" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "labels.restricted", "boolean"); - }, - "labels.hidden" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().hidden = arg_from_str(value.unwrap_or("false"), err, "labels.hidden", "boolean"); - }, - "labels.viewed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().viewed = arg_from_str(value.unwrap_or("false"), err, "labels.viewed", "boolean"); - }, - "labels.starred" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().starred = arg_from_str(value.unwrap_or("false"), err, "labels.starred", "boolean"); - }, - "labels.trashed" => { - request_labels_init(&mut request); - request.labels.as_mut().unwrap().trashed = arg_from_str(value.unwrap_or("false"), err, "labels.trashed", "boolean"); - }, - "indexable-text.text" => { - request_indexable_text_init(&mut request); - request.indexable_text.as_mut().unwrap().text = value.unwrap_or("").to_string(); - }, - "explicitly-trashed" => { - request_indexable_text_init(&mut request); - request.explicitly_trashed = Some(arg_from_str(value.unwrap_or("false"), err, "explicitly-trashed", "boolean")); - }, - "etag" => { - request_indexable_text_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_indexable_text_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "writers-can-share" => { - request_indexable_text_init(&mut request); - request.writers_can_share = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-share", "boolean")); - }, - "id" => { - request_indexable_text_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "sharing-user.picture.url" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "sharing-user.kind" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "sharing-user.display-name" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "sharing-user.permission-id" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "sharing-user.is-authenticated-user" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "sharing-user.is-authenticated-user", "boolean"); - }, - "sharing-user.email-address" => { - request_sharing_user_init(&mut request); - request.sharing_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "video-media-metadata.width" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.width", "integer"); - }, - "video-media-metadata.duration-millis" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().duration_millis = value.unwrap_or("").to_string(); - }, - "video-media-metadata.height" => { - request_video_media_metadata_init(&mut request); - request.video_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "video-media-metadata.height", "integer"); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "copyable" => { - request_last_modifying_user_init(&mut request); - request.copyable = Some(arg_from_str(value.unwrap_or("false"), err, "copyable", "boolean")); - }, - "folder-color-rgb" => { - request_last_modifying_user_init(&mut request); - request.folder_color_rgb = Some(value.unwrap_or("").to_string()); - }, - "owner-names" => { - request_last_modifying_user_init(&mut request); - if request.owner_names.is_none() { - request.owner_names = Some(Default::default()); - } - request.owner_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared-with-me-date" => { - request_last_modifying_user_init(&mut request); - request.shared_with_me_date = Some(value.unwrap_or("").to_string()); - }, - "web-view-link" => { - request_last_modifying_user_init(&mut request); - request.web_view_link = Some(value.unwrap_or("").to_string()); - }, - "version" => { - request_last_modifying_user_init(&mut request); - request.version = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "shared" => { - request_last_modifying_user_init(&mut request); - request.shared = Some(arg_from_str(value.unwrap_or("false"), err, "shared", "boolean")); - }, - "thumbnail.mime-type" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); - }, - "thumbnail.image" => { - request_thumbnail_init(&mut request); - request.thumbnail.as_mut().unwrap().image = value.unwrap_or("").to_string(); - }, - "open-with-links" => { - request_thumbnail_init(&mut request); - if request.open_with_links.is_none() { - request.open_with_links = Some(Default::default()); - } - request.open_with_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "image-media-metadata.exposure-bias" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_bias = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-bias", "number"); - }, - "image-media-metadata.exposure-time" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_time = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.exposure-time", "number"); - }, - "image-media-metadata.max-aperture-value" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().max_aperture_value = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.max-aperture-value", "number"); - }, - "image-media-metadata.width" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().width = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.width", "integer"); - }, - "image-media-metadata.focal-length" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().focal_length = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.focal-length", "number"); - }, - "image-media-metadata.camera-make" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_make = value.unwrap_or("").to_string(); - }, - "image-media-metadata.exposure-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().exposure_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.color-space" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().color_space = value.unwrap_or("").to_string(); - }, - "image-media-metadata.location.latitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.latitude", "number"); - }, - "image-media-metadata.location.altitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.altitude", "number"); - }, - "image-media-metadata.location.longitude" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.location.longitude", "number"); - }, - "image-media-metadata.subject-distance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().subject_distance = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.subject-distance", "integer"); - }, - "image-media-metadata.height" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().height = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.height", "integer"); - }, - "image-media-metadata.lens" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().lens = value.unwrap_or("").to_string(); - }, - "image-media-metadata.date" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().date = value.unwrap_or("").to_string(); - }, - "image-media-metadata.iso-speed" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().iso_speed = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.iso-speed", "integer"); - }, - "image-media-metadata.metering-mode" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().metering_mode = value.unwrap_or("").to_string(); - }, - "image-media-metadata.flash-used" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().flash_used = arg_from_str(value.unwrap_or("false"), err, "image-media-metadata.flash-used", "boolean"); - }, - "image-media-metadata.aperture" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().aperture = arg_from_str(value.unwrap_or("0.0"), err, "image-media-metadata.aperture", "number"); - }, - "image-media-metadata.rotation" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().rotation = arg_from_str(value.unwrap_or("-0"), err, "image-media-metadata.rotation", "integer"); - }, - "image-media-metadata.sensor" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().sensor = value.unwrap_or("").to_string(); - }, - "image-media-metadata.white-balance" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().white_balance = value.unwrap_or("").to_string(); - }, - "image-media-metadata.camera-model" => { - request_image_media_metadata_init(&mut request); - request.image_media_metadata.as_mut().unwrap().camera_model = value.unwrap_or("").to_string(); - }, - "description" => { - request_image_media_metadata_init(&mut request); - request.description = Some(value.unwrap_or("").to_string()); - }, - "web-content-link" => { - request_image_media_metadata_init(&mut request); - request.web_content_link = Some(value.unwrap_or("").to_string()); - }, - "editable" => { - request_image_media_metadata_init(&mut request); - request.editable = Some(arg_from_str(value.unwrap_or("false"), err, "editable", "boolean")); - }, - "embed-link" => { - request_image_media_metadata_init(&mut request); - request.embed_link = Some(value.unwrap_or("").to_string()); - }, - "marked-viewed-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.marked_viewed_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "quota-bytes-used" => { - request_image_media_metadata_init(&mut request); - request.quota_bytes_used = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_image_media_metadata_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_image_media_metadata_init(&mut request); - request.created_date = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_image_media_metadata_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "icon-link" => { - request_image_media_metadata_init(&mut request); - request.icon_link = Some(value.unwrap_or("").to_string()); - }, - "default-open-with-link" => { - request_image_media_metadata_init(&mut request); - request.default_open_with_link = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_image_media_metadata_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "alternate-link" => { - request_image_media_metadata_init(&mut request); - request.alternate_link = Some(value.unwrap_or("").to_string()); - }, - "title" => { - request_image_media_metadata_init(&mut request); - request.title = Some(value.unwrap_or("").to_string()); - }, - "modified-by-me-date" => { - request_image_media_metadata_init(&mut request); - request.modified_by_me_date = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_image_media_metadata_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "user-permission.with-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().with_link = Some(arg_from_str(value.unwrap_or("false"), err, "user-permission.with-link", "boolean")); - }, - "user-permission.domain" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().domain = Some(value.unwrap_or("").to_string()); - }, - "user-permission.name" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); - }, - "user-permission.kind" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "user-permission.value" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); - }, - "user-permission.id" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); - }, - "user-permission.auth-key" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().auth_key = Some(value.unwrap_or("").to_string()); - }, - "user-permission.etag" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); - }, - "user-permission.email-address" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().email_address = Some(value.unwrap_or("").to_string()); - }, - "user-permission.photo-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().photo_link = Some(value.unwrap_or("").to_string()); - }, - "user-permission.role" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().role = Some(value.unwrap_or("").to_string()); - }, - "user-permission.type" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); - }, - "user-permission.additional-roles" => { - request_user_permission_init(&mut request); - if request.user_permission.as_mut().unwrap().additional_roles.is_none() { - request.user_permission.as_mut().unwrap().additional_roles = Some(Default::default()); - } - request.user_permission.as_mut().unwrap().additional_roles.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "user-permission.self-link" => { - request_user_permission_init(&mut request); - request.user_permission.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_user_permission_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "file-extension" => { - request_user_permission_init(&mut request); - request.file_extension = Some(value.unwrap_or("").to_string()); - }, - "head-revision-id" => { - request_user_permission_init(&mut request); - request.head_revision_id = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_user_permission_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_user_permission_init(&mut request); - request.modified_date = 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" - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _files_watch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Channel = Default::default(); - let mut download_mode = false; - 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); - match key { - "update-viewed-date" => { - call = call.update_viewed_date(arg_from_str(value.unwrap_or("false"), err, "update-viewed-date", "boolean")); - }, - "revision-id" => { - call = call.revision_id(value.unwrap_or("")); - }, - "projection" => { - call = call.projection(value.unwrap_or("")); - }, - "alt" => { - if value.unwrap_or("") == "media" { - download_mode = true; - } - call = call.alt(value.unwrap_or("")); - }, - "acknowledge-abuse" => { - call = call.acknowledge_abuse(arg_from_str(value.unwrap_or("false"), err, "acknowledge-abuse", "boolean")); - }, - "fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.params.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - } else { - io::copy(&mut response, &mut ostream).unwrap(); - } - None - } - } - } - } - - fn _parents_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.parents().delete(&self.opt.arg_file_id, &self.opt.arg_parent_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _parents_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.parents().get(&self.opt.arg_file_id, &self.opt.arg_parent_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _parents_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::ParentReference = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _parents_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.parents().list(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.permissions().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _permissions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.permissions().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_get_id_for_email(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.permissions().get_id_for_email(&self.opt.arg_email); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Permission = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "with-link" => { - request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); - }, - "domain" => { - request.domain = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "auth-key" => { - request.auth_key = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email-address" => { - request.email_address = Some(value.unwrap_or("").to_string()); - }, - "photo-link" => { - request.photo_link = Some(value.unwrap_or("").to_string()); - }, - "role" => { - request.role = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "additional-roles" => { - if request.additional_roles.is_none() { - request.additional_roles = Some(Default::default()); - } - request.additional_roles.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.permissions().list(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Permission = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "with-link" => { - request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); - }, - "domain" => { - request.domain = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "auth-key" => { - request.auth_key = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email-address" => { - request.email_address = Some(value.unwrap_or("").to_string()); - }, - "photo-link" => { - request.photo_link = Some(value.unwrap_or("").to_string()); - }, - "role" => { - request.role = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "additional-roles" => { - if request.additional_roles.is_none() { - request.additional_roles = Some(Default::default()); - } - request.additional_roles.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _permissions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Permission = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "with-link" => { - request.with_link = Some(arg_from_str(value.unwrap_or("false"), err, "with-link", "boolean")); - }, - "domain" => { - request.domain = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "value" => { - request.value = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "auth-key" => { - request.auth_key = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request.etag = Some(value.unwrap_or("").to_string()); - }, - "email-address" => { - request.email_address = Some(value.unwrap_or("").to_string()); - }, - "photo-link" => { - request.photo_link = Some(value.unwrap_or("").to_string()); - }, - "role" => { - request.role = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "additional-roles" => { - if request.additional_roles.is_none() { - request.additional_roles = Some(Default::default()); - } - request.additional_roles.as_mut().unwrap().push(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _properties_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.properties().delete(&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); - match key { - "visibility" => { - call = call.visibility(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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _properties_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.properties().get(&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); - match key { - "visibility" => { - call = call.visibility(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _properties_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Property = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _properties_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.properties().list(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _properties_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Property = Default::default(); - 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); - match key { - "visibility" => { - call = call.visibility(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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _properties_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Property = Default::default(); - 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); - match key { - "visibility" => { - call = call.visibility(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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _realtime_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut download_mode = false; - let mut call = self.hub.realtime().get(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "revision" => { - call = call.revision(arg_from_str(value.unwrap_or("-0"), err, "revision", "integer")); - }, - "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); - 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) => { - println!("DEBUG: REMOVE ME {:?}", response); - if !download_mode { - } else { - io::copy(&mut response, &mut ostream).unwrap(); - } - None - } - } - } - } - - fn _realtime_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.realtime().update(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "base-revision" => { - call = call.base_revision(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" - } 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); - 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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _replies_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.replies().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _replies_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.replies().get(&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); - match key { - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _replies_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::CommentReply = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::CommentReply) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "verb" => { - request_author_init(&mut request); - request.verb = Some(value.unwrap_or("").to_string()); - }, - "reply-id" => { - request_author_init(&mut request); - request.reply_id = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_author_init(&mut request); - request.created_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _replies_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.replies().list(&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); - match key { - "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")); - }, - "include-deleted" => { - call = call.include_deleted(arg_from_str(value.unwrap_or("false"), err, "include-deleted", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _replies_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::CommentReply = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::CommentReply) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "verb" => { - request_author_init(&mut request); - request.verb = Some(value.unwrap_or("").to_string()); - }, - "reply-id" => { - request_author_init(&mut request); - request.reply_id = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_author_init(&mut request); - request.created_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _replies_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::CommentReply = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_author_init(request: &mut api::CommentReply) { - if request.author.is_none() { - request.author = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "author.picture.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "author.kind" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "author.permission-id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "author.is-authenticated-user" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "author.is-authenticated-user", "boolean"); - }, - "author.email-address" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "deleted" => { - request_author_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "html-content" => { - request_author_init(&mut request); - request.html_content = Some(value.unwrap_or("").to_string()); - }, - "content" => { - request_author_init(&mut request); - request.content = Some(value.unwrap_or("").to_string()); - }, - "verb" => { - request_author_init(&mut request); - request.verb = Some(value.unwrap_or("").to_string()); - }, - "reply-id" => { - request_author_init(&mut request); - request.reply_id = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_author_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "created-date" => { - request_author_init(&mut request); - request.created_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _revisions_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.revisions().delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _revisions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.revisions().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _revisions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.revisions().list(&self.opt.arg_file_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _revisions_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Revision = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_last_modifying_user_init(request: &mut api::Revision) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "pinned" => { - request.pinned = Some(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "publish-auto" => { - request.publish_auto = Some(arg_from_str(value.unwrap_or("false"), err, "publish-auto", "boolean")); - }, - "published-outside-domain" => { - request.published_outside_domain = Some(arg_from_str(value.unwrap_or("false"), err, "published-outside-domain", "boolean")); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "published-link" => { - request_last_modifying_user_init(&mut request); - request.published_link = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_last_modifying_user_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_last_modifying_user_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request_last_modifying_user_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_last_modifying_user_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_last_modifying_user_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_last_modifying_user_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request_last_modifying_user_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_last_modifying_user_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "published" => { - request_last_modifying_user_init(&mut request); - request.published = Some(arg_from_str(value.unwrap_or("false"), err, "published", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _revisions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Revision = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_last_modifying_user_init(request: &mut api::Revision) { - if request.last_modifying_user.is_none() { - request.last_modifying_user = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "mime-type" => { - request.mime_type = Some(value.unwrap_or("").to_string()); - }, - "pinned" => { - request.pinned = Some(arg_from_str(value.unwrap_or("false"), err, "pinned", "boolean")); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "publish-auto" => { - request.publish_auto = Some(arg_from_str(value.unwrap_or("false"), err, "publish-auto", "boolean")); - }, - "published-outside-domain" => { - request.published_outside_domain = Some(arg_from_str(value.unwrap_or("false"), err, "published-outside-domain", "boolean")); - }, - "last-modifying-user.picture.url" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().picture.url = value.unwrap_or("").to_string(); - }, - "last-modifying-user.kind" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "last-modifying-user.display-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); - }, - "last-modifying-user.permission-id" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().permission_id = value.unwrap_or("").to_string(); - }, - "last-modifying-user.is-authenticated-user" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().is_authenticated_user = arg_from_str(value.unwrap_or("false"), err, "last-modifying-user.is-authenticated-user", "boolean"); - }, - "last-modifying-user.email-address" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user.as_mut().unwrap().email_address = value.unwrap_or("").to_string(); - }, - "published-link" => { - request_last_modifying_user_init(&mut request); - request.published_link = Some(value.unwrap_or("").to_string()); - }, - "download-url" => { - request_last_modifying_user_init(&mut request); - request.download_url = Some(value.unwrap_or("").to_string()); - }, - "self-link" => { - request_last_modifying_user_init(&mut request); - request.self_link = Some(value.unwrap_or("").to_string()); - }, - "etag" => { - request_last_modifying_user_init(&mut request); - request.etag = Some(value.unwrap_or("").to_string()); - }, - "file-size" => { - request_last_modifying_user_init(&mut request); - request.file_size = Some(value.unwrap_or("").to_string()); - }, - "export-links" => { - request_last_modifying_user_init(&mut request); - if request.export_links.is_none() { - request.export_links = Some(Default::default()); - } - request.export_links.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "last-modifying-user-name" => { - request_last_modifying_user_init(&mut request); - request.last_modifying_user_name = Some(value.unwrap_or("").to_string()); - }, - "modified-date" => { - request_last_modifying_user_init(&mut request); - request.modified_date = Some(value.unwrap_or("").to_string()); - }, - "original-filename" => { - request_last_modifying_user_init(&mut request); - request.original_filename = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request_last_modifying_user_init(&mut request); - request.id = Some(value.unwrap_or("").to_string()); - }, - "md5-checksum" => { - request_last_modifying_user_init(&mut request); - request.md5_checksum = Some(value.unwrap_or("").to_string()); - }, - "published" => { - request_last_modifying_user_init(&mut request); - request.published = Some(arg_from_str(value.unwrap_or("false"), err, "published", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_about { - if self.opt.cmd_get { - call_result = self._about_get(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_apps { - if self.opt.cmd_get { - call_result = self._apps_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._apps_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_changes { - if self.opt.cmd_get { - call_result = self._changes_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._changes_list(dry_run, &mut err); - } else if self.opt.cmd_watch { - call_result = self._changes_watch(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_channels { - if self.opt.cmd_stop { - call_result = self._channels_stop(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_children { - if self.opt.cmd_delete { - call_result = self._children_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._children_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._children_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._children_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_comments { - if self.opt.cmd_delete { - call_result = self._comments_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._comments_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._comments_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._comments_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._comments_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._comments_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_files { - if self.opt.cmd_copy { - call_result = self._files_copy(dry_run, &mut err); - } else if self.opt.cmd_delete { - call_result = self._files_delete(dry_run, &mut err); - } else if self.opt.cmd_empty_trash { - call_result = self._files_empty_trash(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._files_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._files_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._files_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._files_patch(dry_run, &mut err); - } else if self.opt.cmd_touch { - call_result = self._files_touch(dry_run, &mut err); - } else if self.opt.cmd_trash { - call_result = self._files_trash(dry_run, &mut err); - } else if self.opt.cmd_untrash { - call_result = self._files_untrash(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._files_update(dry_run, &mut err); - } else if self.opt.cmd_watch { - call_result = self._files_watch(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_parents { - if self.opt.cmd_delete { - call_result = self._parents_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._parents_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._parents_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._parents_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_permissions { - if self.opt.cmd_delete { - call_result = self._permissions_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._permissions_get(dry_run, &mut err); - } else if self.opt.cmd_get_id_for_email { - call_result = self._permissions_get_id_for_email(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._permissions_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._permissions_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._permissions_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._permissions_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_properties { - if self.opt.cmd_delete { - call_result = self._properties_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._properties_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._properties_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._properties_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._properties_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._properties_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_realtime { - if self.opt.cmd_get { - call_result = self._realtime_get(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._realtime_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_replies { - if self.opt.cmd_delete { - call_result = self._replies_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._replies_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._replies_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._replies_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._replies_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._replies_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_revisions { - if self.opt.cmd_delete { - call_result = self._revisions_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._revisions_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._revisions_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._revisions_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._revisions_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "drive2-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "drive2", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Drive::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/drive2/Cargo.toml b/gen/drive2/Cargo.toml index deb285508d..483a1f010f 100644 --- a/gen/drive2/Cargo.toml +++ b/gen/drive2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-drive2" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/drive/" diff --git a/gen/drive2/README.md b/gen/drive2/README.md index 6de3ce5ebc..d62a16b915 100644 --- a/gen/drive2/README.md +++ b/gen/drive2/README.md @@ -148,7 +148,7 @@ let mut hub = Drive::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: File = Default::default(); +let mut req = File::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/drive2/src/cmn.rs b/gen/drive2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/drive2/src/cmn.rs +++ b/gen/drive2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/drive2/src/lib.rs b/gen/drive2/src/lib.rs index 1813abbdf0..8a1b200b80 100644 --- a/gen/drive2/src/lib.rs +++ b/gen/drive2/src/lib.rs @@ -149,7 +149,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: File = Default::default(); +//! let mut req = File::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -286,20 +286,23 @@ pub enum Scope { /// View your Google Drive apps AppReadonly, + /// View and manage metadata of files in your Google Drive + Metadata, + + /// View metadata for files in your Google Drive + MetadataReadonly, + /// View and manage Google Drive files that you have opened or created with this app File, /// Modify your Google Apps Script scripts' behavior Script, - /// View and manage its own configuration data in your Google Drive - Appdata, - /// View the files in your Google Drive Readonly, - /// View metadata for files in your Google Drive - MetadataReadonly, + /// View and manage its own configuration data in your Google Drive + Appdata, } impl AsRef<str> for Scope { @@ -307,11 +310,12 @@ impl AsRef<str> for Scope { match *self { Scope::Full => "https://www.googleapis.com/auth/drive", Scope::AppReadonly => "https://www.googleapis.com/auth/drive.apps.readonly", + Scope::Metadata => "https://www.googleapis.com/auth/drive.metadata", + Scope::MetadataReadonly => "https://www.googleapis.com/auth/drive.metadata.readonly", Scope::File => "https://www.googleapis.com/auth/drive.file", Scope::Script => "https://www.googleapis.com/auth/drive.scripts", - Scope::Appdata => "https://www.googleapis.com/auth/drive.appdata", Scope::Readonly => "https://www.googleapis.com/auth/drive.readonly", - Scope::MetadataReadonly => "https://www.googleapis.com/auth/drive.metadata.readonly", + Scope::Appdata => "https://www.googleapis.com/auth/drive.appdata", } } } @@ -360,7 +364,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: File = Default::default(); +/// let mut req = File::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -577,73 +581,73 @@ impl ResponseResult for Comment {} pub struct About { /// The user's language or locale code, as defined by BCP 47, with some extensions from Unicode's LDML format (http://www.unicode.org/reports/tr35/). #[serde(rename="languageCode")] - pub language_code: String, + pub language_code: Option<String>, /// The amount of storage quota used by different Google services. #[serde(rename="quotaBytesByService")] - pub quota_bytes_by_service: Vec<AboutQuotaBytesByService>, + pub quota_bytes_by_service: Option<Vec<AboutQuotaBytesByService>>, /// List of additional features enabled on this account. - pub features: Vec<AboutFeatures>, + pub features: Option<Vec<AboutFeatures>>, /// The number of quota bytes used by Google Drive. #[serde(rename="quotaBytesUsed")] - pub quota_bytes_used: String, + pub quota_bytes_used: Option<String>, /// This is always drive#about. - pub kind: String, + pub kind: Option<String>, /// Information about supported additional roles per file type. The most specific type takes precedence. #[serde(rename="additionalRoleInfo")] - pub additional_role_info: Vec<AboutAdditionalRoleInfo>, + pub additional_role_info: Option<Vec<AboutAdditionalRoleInfo>>, /// The palette of allowable folder colors as RGB hex strings. #[serde(rename="folderColorPalette")] - pub folder_color_palette: Vec<String>, + pub folder_color_palette: Option<Vec<String>>, /// The authenticated user. - pub user: User, + pub user: Option<User>, /// The type of the user's storage quota. Possible values are: /// - LIMITED /// - UNLIMITED #[serde(rename="quotaType")] - pub quota_type: String, + pub quota_type: Option<String>, /// The number of quota bytes used by all Google apps (Drive, Picasa, etc.). #[serde(rename="quotaBytesUsedAggregate")] - pub quota_bytes_used_aggregate: String, + pub quota_bytes_used_aggregate: Option<String>, /// List of max upload sizes for each file type. The most specific type takes precedence. #[serde(rename="maxUploadSizes")] - pub max_upload_sizes: Vec<AboutMaxUploadSizes>, + pub max_upload_sizes: Option<Vec<AboutMaxUploadSizes>>, /// The current user's ID as visible in the permissions collection. #[serde(rename="permissionId")] - pub permission_id: String, + pub permission_id: Option<String>, /// The name of the current user. - pub name: String, + pub name: Option<String>, /// The total number of quota bytes. #[serde(rename="quotaBytesTotal")] - pub quota_bytes_total: String, + pub quota_bytes_total: Option<String>, /// The number of remaining change ids. #[serde(rename="remainingChangeIds")] - pub remaining_change_ids: String, + pub remaining_change_ids: Option<String>, /// The ETag of the item. - pub etag: String, + pub etag: Option<String>, /// The allowable import formats. #[serde(rename="importFormats")] - pub import_formats: Vec<AboutImportFormats>, + pub import_formats: Option<Vec<AboutImportFormats>>, /// The id of the root folder. #[serde(rename="rootFolderId")] - pub root_folder_id: String, + pub root_folder_id: Option<String>, /// The largest change id. #[serde(rename="largestChangeId")] - pub largest_change_id: String, + pub largest_change_id: Option<String>, /// The number of quota bytes used by trashed items. #[serde(rename="quotaBytesUsedInTrash")] - pub quota_bytes_used_in_trash: String, + pub quota_bytes_used_in_trash: Option<String>, /// The allowable export formats. #[serde(rename="exportFormats")] - pub export_formats: Vec<AboutExportFormats>, + pub export_formats: Option<Vec<AboutExportFormats>>, /// The domain sharing policy for the current user. #[serde(rename="domainSharingPolicy")] - pub domain_sharing_policy: String, + pub domain_sharing_policy: Option<String>, /// A link back to this item. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A boolean indicating whether the authenticated app is installed by the authenticated user. #[serde(rename="isCurrentAppInstalled")] - pub is_current_app_installed: bool, + pub is_current_app_installed: Option<bool>, } impl ResponseResult for About {} @@ -657,9 +661,9 @@ impl ResponseResult for About {} pub struct FileThumbnail { /// The MIME type of the thumbnail. #[serde(rename="mimeType")] - pub mime_type: String, + pub mime_type: Option<String>, /// The URL-safe Base64 encoded bytes of the thumbnail image. It should conform to RFC 4648 section 5. - pub image: String, + pub image: Option<String>, } impl NestedType for FileThumbnail {} @@ -842,10 +846,10 @@ impl ResponseResult for File {} pub struct AboutAdditionalRoleInfo { /// The supported additional roles per primary role. #[serde(rename="roleSets")] - pub role_sets: Vec<AboutAdditionalRoleInfoRoleSets>, + pub role_sets: Option<Vec<AboutAdditionalRoleInfoRoleSets>>, /// The content type that this additional role info applies to. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for AboutAdditionalRoleInfo {} @@ -865,22 +869,22 @@ impl Part for AboutAdditionalRoleInfo {} pub struct ChangeList { /// The page token for the next page of changes. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// This is always drive#changeList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// The current largest change ID. #[serde(rename="largestChangeId")] - pub largest_change_id: String, + pub largest_change_id: Option<String>, /// The actual list of changes. - pub items: Vec<Change>, + pub items: Option<Vec<Change>>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A link to the next page of changes. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, } impl ResponseResult for ChangeList {} @@ -898,14 +902,14 @@ impl ResponseResult for ChangeList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PropertyList { /// The list of properties. - pub items: Vec<Property>, + pub items: Option<Vec<Property>>, /// This is always drive#propertyList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// The link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for PropertyList {} @@ -923,9 +927,9 @@ impl ResponseResult for PropertyList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionId { /// This is always drive#permissionId. - pub kind: String, + pub kind: Option<String>, /// The permission ID. - pub id: String, + pub id: Option<String>, } impl ResponseResult for PermissionId {} @@ -938,7 +942,7 @@ impl ResponseResult for PermissionId {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileIndexableText { /// The text to be indexed for this file. - pub text: String, + pub text: Option<String>, } impl NestedType for FileIndexableText {} @@ -953,10 +957,10 @@ impl Part for FileIndexableText {} pub struct AboutAdditionalRoleInfoRoleSets { /// A primary permission role. #[serde(rename="primaryRole")] - pub primary_role: String, + pub primary_role: Option<String>, /// The supported additional roles with the primary role. #[serde(rename="additionalRoles")] - pub additional_roles: Vec<String>, + pub additional_roles: Option<Vec<String>>, } impl NestedType for AboutAdditionalRoleInfoRoleSets {} @@ -976,17 +980,17 @@ impl Part for AboutAdditionalRoleInfoRoleSets {} pub struct CommentReplyList { /// The token to use to request the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of reply. - pub items: Vec<CommentReply>, + pub items: Option<Vec<CommentReply>>, /// This is always drive#commentReplyList. - pub kind: String, + pub kind: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A link to the next page of replies. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, } impl ResponseResult for CommentReplyList {} @@ -999,9 +1003,9 @@ impl ResponseResult for CommentReplyList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutImportFormats { /// The imported file's content type to convert from. - pub source: String, + pub source: Option<String>, /// The possible content types to convert to. - pub targets: Vec<String>, + pub targets: Option<Vec<String>>, } impl NestedType for AboutImportFormats {} @@ -1020,14 +1024,14 @@ impl Part for AboutImportFormats {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RevisionList { /// The actual list of revisions. - pub items: Vec<Revision>, + pub items: Option<Vec<Revision>>, /// This is always drive#revisionList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for RevisionList {} @@ -1041,9 +1045,9 @@ impl ResponseResult for RevisionList {} pub struct AboutMaxUploadSizes { /// The file type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The max upload size for this type. - pub size: String, + pub size: Option<String>, } impl NestedType for AboutMaxUploadSizes {} @@ -1057,15 +1061,15 @@ impl Part for AboutMaxUploadSizes {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileLabels { /// Whether viewers are prevented from downloading this file. - pub restricted: bool, + pub restricted: Option<bool>, /// Deprecated. - pub hidden: bool, + pub hidden: Option<bool>, /// Whether this file has been trashed. This label applies to all users accessing the file; however, only owners are allowed to see and untrash files. - pub trashed: bool, + pub trashed: Option<bool>, /// Whether this file is starred by the user. - pub starred: bool, + pub starred: Option<bool>, /// Whether this file has been viewed by this user. - pub viewed: bool, + pub viewed: Option<bool>, } impl NestedType for FileLabels {} @@ -1237,17 +1241,17 @@ impl ResponseResult for Revision {} pub struct CommentList { /// The token to use to request the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of comments. - pub items: Vec<Comment>, + pub items: Option<Vec<Comment>>, /// This is always drive#commentList. - pub kind: String, + pub kind: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A link to the next page of comments. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, } impl ResponseResult for CommentList {} @@ -1265,14 +1269,14 @@ impl ResponseResult for CommentList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ParentList { /// The actual list of parents. - pub items: Vec<ParentReference>, + pub items: Option<Vec<ParentReference>>, /// This is always drive#parentList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for ParentList {} @@ -1290,14 +1294,14 @@ impl ResponseResult for ParentList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionList { /// The actual list of permissions. - pub items: Vec<Permission>, + pub items: Option<Vec<Permission>>, /// This is always drive#permissionList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for PermissionList {} @@ -1311,10 +1315,10 @@ impl ResponseResult for PermissionList {} pub struct AboutQuotaBytesByService { /// The service's name, e.g. DRIVE, GMAIL, or PHOTOS. #[serde(rename="serviceName")] - pub service_name: String, + pub service_name: Option<String>, /// The storage quota bytes used by the service. #[serde(rename="bytesUsed")] - pub bytes_used: String, + pub bytes_used: Option<String>, } impl NestedType for AboutQuotaBytesByService {} @@ -1395,59 +1399,59 @@ impl ResponseResult for Permission {} pub struct FileImageMediaMetadata { /// The exposure bias of the photo (APEX value). #[serde(rename="exposureBias")] - pub exposure_bias: f32, + pub exposure_bias: Option<f32>, /// The length of the exposure, in seconds. #[serde(rename="exposureTime")] - pub exposure_time: f32, + pub exposure_time: Option<f32>, /// The smallest f-number of the lens at the focal length used to create the photo (APEX value). #[serde(rename="maxApertureValue")] - pub max_aperture_value: f32, + pub max_aperture_value: Option<f32>, /// The color space of the photo. #[serde(rename="colorSpace")] - pub color_space: String, + pub color_space: Option<String>, /// The height of the image in pixels. - pub height: i32, + pub height: Option<i32>, /// The lens used to create the photo. - pub lens: String, + pub lens: Option<String>, /// The aperture used to create the photo (f-number). - pub aperture: f32, + pub aperture: Option<f32>, /// The date and time the photo was taken (EXIF format timestamp). - pub date: String, + pub date: Option<String>, /// The rotation in clockwise degrees from the image's original orientation. - pub rotation: i32, + pub rotation: Option<i32>, /// The white balance mode used to create the photo. #[serde(rename="whiteBalance")] - pub white_balance: String, + pub white_balance: Option<String>, /// The model of the camera used to create the photo. #[serde(rename="cameraModel")] - pub camera_model: String, + pub camera_model: Option<String>, /// Whether a flash was used to create the photo. #[serde(rename="flashUsed")] - pub flash_used: bool, + pub flash_used: Option<bool>, /// The make of the camera used to create the photo. #[serde(rename="cameraMake")] - pub camera_make: String, + pub camera_make: Option<String>, /// The focal length used to create the photo, in millimeters. #[serde(rename="focalLength")] - pub focal_length: f32, + pub focal_length: Option<f32>, /// The exposure mode used to create the photo. #[serde(rename="exposureMode")] - pub exposure_mode: String, + pub exposure_mode: Option<String>, /// The distance to the subject of the photo, in meters. #[serde(rename="subjectDistance")] - pub subject_distance: i32, + pub subject_distance: Option<i32>, /// The width of the image in pixels. - pub width: i32, + pub width: Option<i32>, /// The metering mode used to create the photo. #[serde(rename="meteringMode")] - pub metering_mode: String, + pub metering_mode: Option<String>, /// Geographic location information stored in the image. - pub location: FileImageMediaMetadataLocation, + pub location: Option<FileImageMediaMetadataLocation>, /// The ISO speed used to create the photo. #[serde(rename="isoSpeed")] - pub iso_speed: i32, + pub iso_speed: Option<i32>, /// The type of sensor used to create the photo. - pub sensor: String, + pub sensor: Option<String>, } impl NestedType for FileImageMediaMetadata {} @@ -1468,70 +1472,70 @@ impl Part for FileImageMediaMetadata {} pub struct App { /// The list of secondary mime types. #[serde(rename="secondaryMimeTypes")] - pub secondary_mime_types: Vec<String>, + pub secondary_mime_types: Option<Vec<String>>, /// Whether the app is selected as the default handler for the types it supports. #[serde(rename="useByDefault")] - pub use_by_default: bool, + pub use_by_default: Option<bool>, /// Whether the app is installed. - pub installed: bool, + pub installed: Option<bool>, /// A link to the product listing for this app. #[serde(rename="productUrl")] - pub product_url: String, + pub product_url: Option<String>, /// Whether this app supports importing Google Docs. #[serde(rename="supportsImport")] - pub supports_import: bool, + pub supports_import: Option<bool>, /// Whether this app supports creating new objects. #[serde(rename="supportsCreate")] - pub supports_create: bool, + pub supports_create: Option<bool>, /// A long description of the app. #[serde(rename="longDescription")] - pub long_description: String, + pub long_description: Option<String>, /// A short description of the app. #[serde(rename="shortDescription")] - pub short_description: String, + pub short_description: Option<String>, /// The ID of the app. - pub id: String, + pub id: Option<String>, /// Whether the app has drive-wide scope. An app with drive-wide scope can access all files in the user's drive. #[serde(rename="hasDriveWideScope")] - pub has_drive_wide_scope: bool, + pub has_drive_wide_scope: Option<bool>, /// The type of object this app creates (e.g. Chart). If empty, the app name should be used instead. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, /// This is always drive#app. - pub kind: String, + pub kind: Option<String>, /// The list of primary file extensions. #[serde(rename="primaryFileExtensions")] - pub primary_file_extensions: Vec<String>, + pub primary_file_extensions: Option<Vec<String>>, /// The list of primary mime types. #[serde(rename="primaryMimeTypes")] - pub primary_mime_types: Vec<String>, + pub primary_mime_types: Option<Vec<String>>, /// The url to create a new file with this app. #[serde(rename="createUrl")] - pub create_url: String, + pub create_url: Option<String>, /// The various icons for the app. - pub icons: Vec<AppIcons>, + pub icons: Option<Vec<AppIcons>>, /// Whether this app supports creating new files when offline. #[serde(rename="supportsOfflineCreate")] - pub supports_offline_create: bool, + pub supports_offline_create: Option<bool>, /// The list of secondary file extensions. #[serde(rename="secondaryFileExtensions")] - pub secondary_file_extensions: Vec<String>, + pub secondary_file_extensions: Option<Vec<String>>, /// The name of the app. - pub name: String, + pub name: Option<String>, /// Whether the app is authorized to access data on the user's Drive. - pub authorized: bool, + pub authorized: Option<bool>, /// Whether this app supports opening more than one file. #[serde(rename="supportsMultiOpen")] - pub supports_multi_open: bool, + pub supports_multi_open: Option<bool>, /// The template url to create a new file with this app in a given folder. The template will contain {folderId} to be replaced by the folder to create the new file in. #[serde(rename="createInFolderTemplate")] - pub create_in_folder_template: String, + pub create_in_folder_template: Option<String>, /// The template url for opening files with this app. The template will contain {ids} and/or {exportIds} to be replaced by the actual file ids. See Open Files for the full documentation. #[serde(rename="openUrlTemplate")] - pub open_url_template: String, + pub open_url_template: Option<String>, /// The ID of the product listing for this app. #[serde(rename="productId")] - pub product_id: String, + pub product_id: Option<String>, } impl Resource for App {} @@ -1545,11 +1549,11 @@ impl ResponseResult for App {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileImageMediaMetadataLocation { /// The latitude stored in the image. - pub latitude: f64, + pub latitude: Option<f64>, /// The altitude stored in the image. - pub altitude: f64, + pub altitude: Option<f64>, /// The longitude stored in the image. - pub longitude: f64, + pub longitude: Option<f64>, } impl NestedType for FileImageMediaMetadataLocation {} @@ -1569,19 +1573,19 @@ impl Part for FileImageMediaMetadataLocation {} pub struct FileList { /// The page token for the next page of files. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// This is always drive#fileList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// The actual list of files. - pub items: Vec<File>, + pub items: Option<Vec<File>>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A link to the next page of files. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, } impl ResponseResult for FileList {} @@ -1600,19 +1604,19 @@ impl ResponseResult for FileList {} pub struct ChildList { /// The page token for the next page of children. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// This is always drive#childList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// The actual list of children. - pub items: Vec<ChildReference>, + pub items: Option<Vec<ChildReference>>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// A link to the next page of children. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, } impl ResponseResult for ChildList {} @@ -1669,7 +1673,7 @@ impl ResponseResult for CommentReply {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserPicture { /// A URL that points to a profile picture of this user. - pub url: String, + pub url: Option<String>, } impl NestedType for UserPicture {} @@ -1684,10 +1688,10 @@ impl Part for UserPicture {} pub struct AboutFeatures { /// The name of the feature. #[serde(rename="featureName")] - pub feature_name: String, + pub feature_name: Option<String>, /// The request limit rate for this feature, in queries per second. #[serde(rename="featureRate")] - pub feature_rate: f64, + pub feature_rate: Option<f64>, } impl NestedType for AboutFeatures {} @@ -1701,21 +1705,21 @@ impl Part for AboutFeatures {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct User { /// The user's profile picture. - pub picture: UserPicture, + pub picture: Option<UserPicture>, /// This is always drive#user. - pub kind: String, + pub kind: Option<String>, /// Whether this user is the same as the authenticated user for whom the request was made. #[serde(rename="isAuthenticatedUser")] - pub is_authenticated_user: bool, + pub is_authenticated_user: Option<bool>, /// A plain text displayable name for this user. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The email address of the user. #[serde(rename="emailAddress")] - pub email_address: String, + pub email_address: Option<String>, /// The user's ID as visible in the permissions collection. #[serde(rename="permissionId")] - pub permission_id: String, + pub permission_id: Option<String>, } impl Part for User {} @@ -1733,17 +1737,17 @@ impl Part for User {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AppList { /// The actual list of apps. - pub items: Vec<App>, + pub items: Option<Vec<App>>, /// This is always drive#appList. - pub kind: String, + pub kind: Option<String>, /// The ETag of the list. - pub etag: String, + pub etag: Option<String>, /// A link back to this list. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// List of app IDs that the user has specified to use by default. The list is in reverse-priority order (lowest to highest). #[serde(rename="defaultAppIds")] - pub default_app_ids: Vec<String>, + pub default_app_ids: Option<Vec<String>>, } impl ResponseResult for AppList {} @@ -1759,12 +1763,12 @@ pub struct AppIcons { /// - application - icon for the application /// - document - icon for a file associated with the app /// - documentShared - icon for a shared file associated with the app - pub category: String, + pub category: Option<String>, /// URL for the icon. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// Size of the icon. Represented as the maximum of the width and height. - pub size: i32, + pub size: Option<i32>, } impl NestedType for AppIcons {} @@ -1779,9 +1783,9 @@ impl Part for AppIcons {} pub struct CommentContext { /// The MIME type of the context snippet. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Data representation of the segment of the file being commented on. In the case of a text file for example, this would be the actual text that the comment is about. - pub value: String, + pub value: Option<String>, } impl NestedType for CommentContext {} @@ -1823,12 +1827,12 @@ impl ResponseResult for ChildReference {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileVideoMediaMetadata { /// The width of the video in pixels. - pub width: i32, + pub width: Option<i32>, /// The duration of the video in milliseconds. #[serde(rename="durationMillis")] - pub duration_millis: String, + pub duration_millis: Option<String>, /// The height of the video in pixels. - pub height: i32, + pub height: Option<i32>, } impl NestedType for FileVideoMediaMetadata {} @@ -1842,9 +1846,9 @@ impl Part for FileVideoMediaMetadata {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AboutExportFormats { /// The content type to convert from. - pub source: String, + pub source: Option<String>, /// The possible content types to convert to. - pub targets: Vec<String>, + pub targets: Option<Vec<String>>, } impl NestedType for AboutExportFormats {} @@ -1866,21 +1870,21 @@ impl Part for AboutExportFormats {} pub struct Change { /// The time of this modification. #[serde(rename="modificationDate")] - pub modification_date: String, + pub modification_date: Option<String>, /// This is always drive#change. - pub kind: String, + pub kind: Option<String>, /// The updated state of the file. Present if the file has not been deleted. - pub file: File, + pub file: Option<File>, /// Whether the file has been deleted. - pub deleted: bool, + pub deleted: Option<bool>, /// The ID of the change. - pub id: String, + pub id: Option<String>, /// A link back to this change. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// The ID of the file associated with this change. #[serde(rename="fileId")] - pub file_id: String, + pub file_id: Option<String>, } impl Resource for Change {} @@ -1946,7 +1950,6 @@ impl<'a, C, A> FileMethods<'a, C, A> { _update_viewed_date: Default::default(), _revision_id: Default::default(), _projection: Default::default(), - _alt: Default::default(), _acknowledge_abuse: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -2178,7 +2181,6 @@ impl<'a, C, A> FileMethods<'a, C, A> { _update_viewed_date: Default::default(), _revision_id: Default::default(), _projection: Default::default(), - _alt: Default::default(), _acknowledge_abuse: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -3604,7 +3606,7 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// Subscribe to changes on a file /// /// This method supports **media download**. To enable it, adjust the builder like this: -/// `.alt("media")`. +/// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `Channel` structure that you would usually get. The latter will be a default value. /// @@ -3633,7 +3635,7 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3642,7 +3644,6 @@ impl<'a, C, A> RevisionMethods<'a, C, A> { /// .update_viewed_date(false) /// .revision_id("labore") /// .projection("eirmod") -/// .alt("dolore") /// .acknowledge_abuse(true) /// .doit(); /// # } @@ -3656,7 +3657,6 @@ pub struct FileWatchCall<'a, C, A> _update_viewed_date: Option<bool>, _revision_id: Option<String>, _projection: Option<String>, - _alt: Option<String>, _acknowledge_abuse: Option<bool>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, @@ -3679,7 +3679,7 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau }; dlg.begin(MethodInfo { id: "drive.files.watch", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("fileId", self._file_id.to_string())); if let Some(value) = self._update_viewed_date { params.push(("updateViewedDate", value.to_string())); @@ -3690,13 +3690,10 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if let Some(value) = self._projection { params.push(("projection", value.to_string())); } - if let Some(value) = self._alt { - params.push(("alt", value.to_string())); - } if let Some(value) = self._acknowledge_abuse { params.push(("acknowledgeAbuse", value.to_string())); } - for &field in ["fileId", "updateViewedDate", "revisionId", "projection", "alt", "acknowledgeAbuse"].iter() { + for &field in ["fileId", "updateViewedDate", "revisionId", "projection", "acknowledgeAbuse"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -3766,16 +3763,20 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3870,14 +3871,7 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau self._projection = Some(new_value.to_string()); self } - /// Specifies the type of resource representation to return. The default is 'json' to return file metadata. Specifying 'media' will cause the file content to be returned. - /// - /// Sets the *alt* query property to the given value. - pub fn alt(mut self, new_value: &str) -> FileWatchCall<'a, C, A> { - self._alt = Some(new_value.to_string()); - self - } - /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. Ignored unless alt=media is specified. + /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. /// /// Sets the *acknowledge abuse* query property to the given value. pub fn acknowledge_abuse(mut self, new_value: bool) -> FileWatchCall<'a, C, A> { @@ -3910,6 +3904,7 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. pub fn param<T>(mut self, name: T, value: T) -> FileWatchCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); @@ -3963,19 +3958,19 @@ impl<'a, C, A> FileWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: File = Default::default(); +/// let mut req = File::default(); /// /// // 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) -/// .visibility("aliquyam") +/// .visibility("invidunt") /// .use_content_as_indexable_text(false) -/// .timed_text_track_name("Lorem") -/// .timed_text_language("sea") +/// .timed_text_track_name("accusam") +/// .timed_text_language("Lorem") /// .pinned(true) -/// .ocr_language("duo") -/// .ocr(true) +/// .ocr_language("et") +/// .ocr(false) /// .convert(true) /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } @@ -4080,16 +4075,20 @@ impl<'a, C, A> FileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -4472,16 +4471,20 @@ impl<'a, C, A> FileUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4621,19 +4624,19 @@ impl<'a, C, A> FileUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: File = Default::default(); +/// 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().copy(&req, "fileId") -/// .visibility("amet") -/// .timed_text_track_name("et") -/// .timed_text_language("consetetur") +/// .visibility("et") +/// .timed_text_track_name("amet") +/// .timed_text_language("et") /// .pinned(true) -/// .ocr_language("ea") -/// .ocr(false) -/// .convert(true) +/// .ocr_language("ut") +/// .ocr(true) +/// .convert(false) /// .doit(); /// # } /// ``` @@ -4748,16 +4751,20 @@ impl<'a, C, A> FileCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5040,16 +5047,20 @@ impl<'a, C, A> FileTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5243,16 +5254,20 @@ impl<'a, C, A> FileEmptyTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5373,10 +5388,10 @@ impl<'a, C, A> FileEmptyTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // Values shown here are possibly random and not representative ! /// let result = hub.files().list() /// .q("dolor") -/// .projection("et") -/// .page_token("consetetur") -/// .max_results(-52) -/// .corpus("voluptua.") +/// .projection("dolor") +/// .page_token("et") +/// .max_results(-96) +/// .corpus("amet.") /// .doit(); /// # } /// ``` @@ -5452,16 +5467,20 @@ impl<'a, C, A> FileListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5707,16 +5726,20 @@ impl<'a, C, A> FileTouchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5857,24 +5880,24 @@ impl<'a, C, A> FileTouchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: File = Default::default(); +/// let mut req = File::default(); /// /// // 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") /// .use_content_as_indexable_text(true) -/// .update_viewed_date(false) -/// .timed_text_track_name("vero") -/// .timed_text_language("diam") -/// .set_modified_date(false) -/// .remove_parents("consetetur") +/// .update_viewed_date(true) +/// .timed_text_track_name("sit") +/// .timed_text_language("vero") +/// .set_modified_date(true) +/// .remove_parents("rebum.") /// .pinned(true) -/// .ocr_language("vero") +/// .ocr_language("sadipscing") /// .ocr(false) /// .new_revision(false) /// .convert(false) -/// .add_parents("dolore") +/// .add_parents("consetetur") /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6020,16 +6043,20 @@ impl<'a, C, A> FileUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -6449,16 +6476,20 @@ impl<'a, C, A> FileDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6588,24 +6619,24 @@ impl<'a, C, A> FileDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: File = Default::default(); +/// 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") -/// .use_content_as_indexable_text(true) +/// .use_content_as_indexable_text(false) /// .update_viewed_date(true) -/// .timed_text_track_name("clita") -/// .timed_text_language("consetetur") -/// .set_modified_date(false) -/// .remove_parents("nonumy") +/// .timed_text_track_name("et") +/// .timed_text_language("clita") +/// .set_modified_date(true) +/// .remove_parents("takimata") /// .pinned(true) -/// .ocr_language("sanctus") -/// .ocr(false) -/// .new_revision(true) -/// .convert(false) -/// .add_parents("invidunt") +/// .ocr_language("kasd") +/// .ocr(true) +/// .new_revision(false) +/// .convert(true) +/// .add_parents("labore") /// .doit(); /// # } /// ``` @@ -6740,16 +6771,20 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6962,7 +6997,7 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// Gets a file's metadata by ID. /// /// This method supports **media download**. To enable it, adjust the builder like this: -/// `.alt("media")`. +/// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `File` structure that you would usually get. The latter will be a default value. /// @@ -6992,9 +7027,8 @@ impl<'a, C, A> FilePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // Values shown here are possibly random and not representative ! /// let result = hub.files().get("fileId") /// .update_viewed_date(false) -/// .revision_id("rebum.") -/// .projection("dolore") -/// .alt("nonumy") +/// .revision_id("sadipscing") +/// .projection("rebum.") /// .acknowledge_abuse(true) /// .doit(); /// # } @@ -7007,7 +7041,6 @@ pub struct FileGetCall<'a, C, A> _update_viewed_date: Option<bool>, _revision_id: Option<String>, _projection: Option<String>, - _alt: Option<String>, _acknowledge_abuse: Option<bool>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, @@ -7030,7 +7063,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth }; dlg.begin(MethodInfo { id: "drive.files.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); params.push(("fileId", self._file_id.to_string())); if let Some(value) = self._update_viewed_date { params.push(("updateViewedDate", value.to_string())); @@ -7041,13 +7074,10 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth if let Some(value) = self._projection { params.push(("projection", value.to_string())); } - if let Some(value) = self._alt { - params.push(("alt", value.to_string())); - } if let Some(value) = self._acknowledge_abuse { params.push(("acknowledgeAbuse", value.to_string())); } - for &field in ["fileId", "updateViewedDate", "revisionId", "projection", "alt", "acknowledgeAbuse"].iter() { + for &field in ["fileId", "updateViewedDate", "revisionId", "projection", "acknowledgeAbuse"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7113,16 +7143,20 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7204,14 +7238,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth self._projection = Some(new_value.to_string()); self } - /// Specifies the type of resource representation to return. The default is 'json' to return file metadata. Specifying 'media' will cause the file content to be returned. - /// - /// Sets the *alt* query property to the given value. - pub fn alt(mut self, new_value: &str) -> FileGetCall<'a, C, A> { - self._alt = Some(new_value.to_string()); - self - } - /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. Ignored unless alt=media is specified. + /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. /// /// Sets the *acknowledge abuse* query property to the given value. pub fn acknowledge_abuse(mut self, new_value: bool) -> FileGetCall<'a, C, A> { @@ -7244,6 +7271,7 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. pub fn param<T>(mut self, name: T, value: T) -> FileGetCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); @@ -7296,9 +7324,9 @@ impl<'a, C, A> FileGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.about().get() -/// .start_change_id("aliquyam") -/// .max_change_id_count(-53) -/// .include_subscribed(true) +/// .start_change_id("nonumy") +/// .max_change_id_count(-29) +/// .include_subscribed(false) /// .doit(); /// # } /// ``` @@ -7366,16 +7394,20 @@ impl<'a, C, A> AboutGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7527,7 +7559,7 @@ impl<'a, C, A> AboutGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.realtime().update("fileId") -/// .base_revision("labore") +/// .base_revision("eirmod") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -7623,16 +7655,20 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -7870,7 +7906,7 @@ impl<'a, C, A> RealtimeUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.realtime().get("fileId") -/// .revision(-16) +/// .revision(-85) /// .doit(); /// # } /// ``` @@ -7955,16 +7991,20 @@ impl<'a, C, A> RealtimeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8182,16 +8222,20 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8331,9 +8375,9 @@ impl<'a, C, A> AppGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.apps().list() -/// .language_code("aliquyam") -/// .app_filter_mime_types("eos") -/// .app_filter_extensions("tempor") +/// .language_code("ea") +/// .app_filter_mime_types("gubergren") +/// .app_filter_extensions("aliquyam") /// .doit(); /// # } /// ``` @@ -8401,16 +8445,20 @@ impl<'a, C, A> AppListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8643,16 +8691,20 @@ impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8880,16 +8932,20 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9046,7 +9102,7 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Comment = Default::default(); +/// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9138,16 +9194,20 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9300,7 +9360,7 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Comment = Default::default(); +/// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9394,16 +9454,20 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9566,7 +9630,7 @@ impl<'a, C, A> CommentPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Comment = Default::default(); +/// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9660,16 +9724,20 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9832,10 +9900,10 @@ impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.comments().list("fileId") -/// .updated_min("accusam") -/// .page_token("clita") -/// .max_results(-79) -/// .include_deleted(false) +/// .updated_min("est") +/// .page_token("amet") +/// .max_results(-23) +/// .include_deleted(true) /// .doit(); /// # } /// ``` @@ -9933,16 +10001,20 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10110,9 +10182,9 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.children().list("folderId") -/// .q("clita") -/// .page_token("invidunt") -/// .max_results(-87) +/// .q("justo") +/// .page_token("est") +/// .max_results(-63) /// .doit(); /// # } /// ``` @@ -10206,16 +10278,20 @@ impl<'a, C, A> ChildrenListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10459,16 +10535,20 @@ impl<'a, C, A> ChildrenGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10700,16 +10780,20 @@ impl<'a, C, A> ChildrenDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10849,7 +10933,7 @@ impl<'a, C, A> ChildrenDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChildReference = Default::default(); +/// let mut req = ChildReference::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10941,16 +11025,20 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11103,7 +11191,7 @@ impl<'a, C, A> ChildrenInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11168,16 +11256,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11391,16 +11483,20 @@ impl<'a, C, A> ParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11622,16 +11718,20 @@ impl<'a, C, A> ParentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11771,7 +11871,7 @@ impl<'a, C, A> ParentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ParentReference = Default::default(); +/// let mut req = ParentReference::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11863,16 +11963,20 @@ impl<'a, C, A> ParentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12108,16 +12212,20 @@ impl<'a, C, A> ParentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12267,7 +12375,7 @@ impl<'a, C, A> ParentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CommentReply = Default::default(); +/// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12363,16 +12471,20 @@ impl<'a, C, A> ReplyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12545,9 +12657,9 @@ impl<'a, C, A> ReplyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.replies().list("fileId", "commentId") -/// .page_token("invidunt") -/// .max_results(-90) -/// .include_deleted(false) +/// .page_token("Lorem") +/// .max_results(-63) +/// .include_deleted(true) /// .doit(); /// # } /// ``` @@ -12643,16 +12755,20 @@ impl<'a, C, A> ReplyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12913,16 +13029,20 @@ impl<'a, C, A> ReplyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13089,7 +13209,7 @@ impl<'a, C, A> ReplyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CommentReply = Default::default(); +/// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13183,16 +13303,20 @@ impl<'a, C, A> ReplyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13439,16 +13563,20 @@ impl<'a, C, A> ReplyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13598,7 +13726,7 @@ impl<'a, C, A> ReplyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CommentReply = Default::default(); +/// let mut req = CommentReply::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13694,16 +13822,20 @@ impl<'a, C, A> ReplyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13958,16 +14090,20 @@ impl<'a, C, A> PermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -14107,14 +14243,14 @@ impl<'a, C, A> PermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Permission = Default::default(); +/// let mut req = Permission::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.permissions().insert(&req, "fileId") /// .send_notification_emails(false) -/// .email_message("dolor") +/// .email_message("ipsum") /// .doit(); /// # } /// ``` @@ -14209,16 +14345,20 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14385,7 +14525,7 @@ impl<'a, C, A> PermissionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Permission = Default::default(); +/// let mut req = Permission::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14484,16 +14624,20 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14663,13 +14807,13 @@ impl<'a, C, A> PermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Permission = Default::default(); +/// let mut req = Permission::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.permissions().patch(&req, "fileId", "permissionId") -/// .transfer_ownership(false) +/// .transfer_ownership(true) /// .doit(); /// # } /// ``` @@ -14762,16 +14906,20 @@ impl<'a, C, A> PermissionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15022,16 +15170,20 @@ impl<'a, C, A> PermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15254,16 +15406,20 @@ impl<'a, C, A> PermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15494,16 +15650,20 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15643,17 +15803,17 @@ impl<'a, C, A> PermissionGetIdForEmailCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// 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.changes().watch(&req) -/// .start_change_id("sed") -/// .page_token("et") -/// .max_results(-55) +/// .start_change_id("vero") +/// .page_token("ut") +/// .max_results(-30) /// .include_subscribed(true) -/// .include_deleted(true) +/// .include_deleted(false) /// .doit(); /// # } /// ``` @@ -15734,16 +15894,20 @@ impl<'a, C, A> ChangeWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15921,10 +16085,10 @@ impl<'a, C, A> ChangeWatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.changes().list() -/// .start_change_id("vero") -/// .page_token("dolor") -/// .max_results(-58) -/// .include_subscribed(true) +/// .start_change_id("justo") +/// .page_token("dolore") +/// .max_results(-26) +/// .include_subscribed(false) /// .include_deleted(false) /// .doit(); /// # } @@ -16001,16 +16165,20 @@ impl<'a, C, A> ChangeListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16256,16 +16424,20 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16405,13 +16577,13 @@ impl<'a, C, A> ChangeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Property = Default::default(); +/// let mut req = Property::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.properties().patch(&req, "fileId", "propertyKey") -/// .visibility("invidunt") +/// .visibility("sed") /// .doit(); /// # } /// ``` @@ -16504,16 +16676,20 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16683,7 +16859,7 @@ impl<'a, C, A> PropertyPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().delete("fileId", "propertyKey") -/// .visibility("aliquyam") +/// .visibility("rebum.") /// .doit(); /// # } /// ``` @@ -16770,16 +16946,20 @@ impl<'a, C, A> PropertyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -16926,7 +17106,7 @@ impl<'a, C, A> PropertyDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Property = Default::default(); +/// let mut req = Property::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17018,16 +17198,20 @@ impl<'a, C, A> PropertyInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17261,16 +17445,20 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17410,13 +17598,13 @@ impl<'a, C, A> PropertyListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Property = Default::default(); +/// let mut req = Property::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.properties().update(&req, "fileId", "propertyKey") -/// .visibility("At") +/// .visibility("sea") /// .doit(); /// # } /// ``` @@ -17509,16 +17697,20 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17688,7 +17880,7 @@ impl<'a, C, A> PropertyUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.properties().get("fileId", "propertyKey") -/// .visibility("diam") +/// .visibility("sea") /// .doit(); /// # } /// ``` @@ -17776,16 +17968,20 @@ impl<'a, C, A> PropertyGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18025,16 +18221,20 @@ impl<'a, C, A> RevisionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18266,16 +18466,20 @@ impl<'a, C, A> RevisionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -18415,7 +18619,7 @@ impl<'a, C, A> RevisionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Revision = Default::default(); +/// let mut req = Revision::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -18509,16 +18713,20 @@ impl<'a, C, A> RevisionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18762,16 +18970,20 @@ impl<'a, C, A> RevisionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18911,7 +19123,7 @@ impl<'a, C, A> RevisionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Revision = Default::default(); +/// let mut req = Revision::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19005,16 +19217,20 @@ impl<'a, C, A> RevisionPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/fitness1-cli/Cargo.toml b/gen/fitness1-cli/Cargo.toml index 7ae4aa2f63..eed958e233 100644 --- a/gen/fitness1-cli/Cargo.toml +++ b/gen/fitness1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-fitness1-cli" -version = "0.0.1+20150222" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/fit/rest/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/fitness1-cli/mkdocs.yml b/gen/fitness1-cli/mkdocs.yml index c87b7d1cff..55ac96db9d 100644 --- a/gen/fitness1-cli/mkdocs.yml +++ b/gen/fitness1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fitness v0.0.1+20150222 +site_name: fitness v0.0.1+20150326 site_url: http://byron.github.io/google-apis-rs/google-fitness1-cli site_description: Write integrating applications with bcore @@ -13,6 +13,7 @@ pages: - ['users_data-sources-datasets-delete.md', 'Users', 'Data Sources Datasets Delete'] - ['users_data-sources-datasets-get.md', 'Users', 'Data Sources Datasets Get'] - ['users_data-sources-datasets-patch.md', 'Users', 'Data Sources Datasets Patch'] +- ['users_data-sources-delete.md', 'Users', 'Data Sources Delete'] - ['users_data-sources-get.md', 'Users', 'Data Sources Get'] - ['users_data-sources-list.md', 'Users', 'Data Sources List'] - ['users_data-sources-patch.md', 'Users', 'Data Sources Patch'] diff --git a/gen/fitness1-cli/src/cmn.rs b/gen/fitness1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/fitness1-cli/src/cmn.rs +++ b/gen/fitness1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/fitness1-cli/src/main.rs b/gen/fitness1-cli/src/main.rs index b344e5165a..5f00dd060f 100644 --- a/gen/fitness1-cli/src/main.rs +++ b/gen/fitness1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -22,6 +23,7 @@ Usage: 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>] @@ -42,6 +44,12 @@ Configuration: 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. "); mod cmn; @@ -63,10 +71,10 @@ 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::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -86,9 +94,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -119,43 +128,43 @@ impl Engine { }, "data-type.name" => { request_data_type_init(&mut request); - request.data_type.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.data_type.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.package-name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().package_name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().package_name = Some(value.unwrap_or("").to_string()); }, "application.version" => { request_application_init(&mut request); - request.application.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "application.name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.details-url" => { request_application_init(&mut request); - request.application.as_mut().unwrap().details_url = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().details_url = Some(value.unwrap_or("").to_string()); }, "device.model" => { request_device_init(&mut request); - request.device.as_mut().unwrap().model = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().model = Some(value.unwrap_or("").to_string()); }, "device.version" => { request_device_init(&mut request); - request.device.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "device.type" => { request_device_init(&mut request); - request.device.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "device.uid" => { request_device_init(&mut request); - request.device.as_mut().unwrap().uid = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().uid = Some(value.unwrap_or("").to_string()); }, "device.manufacturer" => { request_device_init(&mut request); - request.device.as_mut().unwrap().manufacturer = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().manufacturer = Some(value.unwrap_or("").to_string()); }, "data-stream-id" => { request_device_init(&mut request); @@ -182,8 +191,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -194,7 +202,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().data_sources_datasets_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "modified-time-millis" => { call = call.modified_time_millis(value.unwrap_or("")); @@ -231,7 +239,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -242,7 +249,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().data_sources_datasets_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -280,8 +287,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -290,10 +296,10 @@ impl Engine { fn _users_data_sources_datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Dataset = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "current-time-millis" => { call = call.current_time_millis(value.unwrap_or("")); @@ -316,9 +322,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -352,19 +359,18 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } } } - fn _users_data_sources_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + fn _users_data_sources_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut call = self.hub.users().data_sources_get(&self.opt.arg_user_id, &self.opt.arg_data_source_id); + let mut call = self.hub.users().data_sources_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -396,8 +402,50 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _users_data_sources_get(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.users().data_sources_get(&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); + 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 } } @@ -408,7 +456,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().data_sources_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "data-type-name" => { call = call.add_data_type_name(value.unwrap_or("")); @@ -443,8 +491,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -453,10 +500,10 @@ impl Engine { fn _users_data_sources_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DataSource = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -476,9 +523,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -509,43 +557,43 @@ impl Engine { }, "data-type.name" => { request_data_type_init(&mut request); - request.data_type.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.data_type.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.package-name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().package_name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().package_name = Some(value.unwrap_or("").to_string()); }, "application.version" => { request_application_init(&mut request); - request.application.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "application.name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.details-url" => { request_application_init(&mut request); - request.application.as_mut().unwrap().details_url = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().details_url = Some(value.unwrap_or("").to_string()); }, "device.model" => { request_device_init(&mut request); - request.device.as_mut().unwrap().model = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().model = Some(value.unwrap_or("").to_string()); }, "device.version" => { request_device_init(&mut request); - request.device.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "device.type" => { request_device_init(&mut request); - request.device.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "device.uid" => { request_device_init(&mut request); - request.device.as_mut().unwrap().uid = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().uid = Some(value.unwrap_or("").to_string()); }, "device.manufacturer" => { request_device_init(&mut request); - request.device.as_mut().unwrap().manufacturer = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().manufacturer = Some(value.unwrap_or("").to_string()); }, "data-stream-id" => { request_device_init(&mut request); @@ -572,8 +620,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -582,10 +629,10 @@ impl Engine { fn _users_data_sources_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DataSource = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -605,9 +652,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -638,43 +686,43 @@ impl Engine { }, "data-type.name" => { request_data_type_init(&mut request); - request.data_type.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.data_type.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.package-name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().package_name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().package_name = Some(value.unwrap_or("").to_string()); }, "application.version" => { request_application_init(&mut request); - request.application.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "application.name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.details-url" => { request_application_init(&mut request); - request.application.as_mut().unwrap().details_url = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().details_url = Some(value.unwrap_or("").to_string()); }, "device.model" => { request_device_init(&mut request); - request.device.as_mut().unwrap().model = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().model = Some(value.unwrap_or("").to_string()); }, "device.version" => { request_device_init(&mut request); - request.device.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "device.type" => { request_device_init(&mut request); - request.device.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "device.uid" => { request_device_init(&mut request); - request.device.as_mut().unwrap().uid = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().uid = Some(value.unwrap_or("").to_string()); }, "device.manufacturer" => { request_device_init(&mut request); - request.device.as_mut().unwrap().manufacturer = value.unwrap_or("").to_string(); + request.device.as_mut().unwrap().manufacturer = Some(value.unwrap_or("").to_string()); }, "data-stream-id" => { request_device_init(&mut request); @@ -701,8 +749,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -713,7 +760,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().sessions_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "current-time-millis" => { call = call.current_time_millis(value.unwrap_or("")); @@ -747,7 +794,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -758,7 +804,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().sessions_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-time" => { call = call.start_time(value.unwrap_or("")); @@ -802,8 +848,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -812,10 +857,10 @@ impl Engine { fn _users_sessions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Session = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "current-time-millis" => { call = call.current_time_millis(value.unwrap_or("")); @@ -838,9 +883,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -865,24 +911,28 @@ impl Engine { }, "application.package-name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().package_name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().package_name = Some(value.unwrap_or("").to_string()); }, "application.version" => { request_application_init(&mut request); - request.application.as_mut().unwrap().version = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().version = Some(value.unwrap_or("").to_string()); }, "application.name" => { request_application_init(&mut request); - request.application.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "application.details-url" => { request_application_init(&mut request); - request.application.as_mut().unwrap().details_url = value.unwrap_or("").to_string(); + request.application.as_mut().unwrap().details_url = Some(value.unwrap_or("").to_string()); }, "start-time-millis" => { request_application_init(&mut request); request.start_time_millis = Some(value.unwrap_or("").to_string()); }, + "active-time-millis" => { + request_application_init(&mut request); + request.active_time_millis = Some(value.unwrap_or("").to_string()); + }, "id" => { request_application_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); @@ -908,8 +958,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -930,6 +979,8 @@ impl Engine { call_result = self._users_data_sources_datasets_get(dry_run, &mut err); } else if self.opt.cmd_data_sources_datasets_patch { call_result = self._users_data_sources_datasets_patch(dry_run, &mut err); + } else if self.opt.cmd_data_sources_delete { + call_result = self._users_data_sources_delete(dry_run, &mut err); } else if self.opt.cmd_data_sources_get { call_result = self._users_data_sources_get(dry_run, &mut err); } else if self.opt.cmd_data_sources_list { @@ -967,21 +1018,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "fitness1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "fitness1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "fitness1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "fitness1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Fitness::new(hyper::Client::new(), auth), + hub: api::Fitness::new(client, auth), }; match engine._doit(true) { @@ -1001,12 +1068,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/fitness1/Cargo.toml b/gen/fitness1/Cargo.toml index 4a7f38d3c1..71bdfe1062 100644 --- a/gen/fitness1/Cargo.toml +++ b/gen/fitness1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-fitness1" -version = "0.1.5+20150222" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/fit/rest/" diff --git a/gen/fitness1/README.md b/gen/fitness1/README.md index a747e62690..bc703665b3 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+20150222*, where *20150222* 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.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*. Everything else about the *fitness* *v1* API can be found at the [official documentation site](https://developers.google.com/fit/rest/). @@ -14,7 +14,7 @@ Everything else about the *fitness* *v1* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_fitness1/struct.Fitness.html) ... * users - * [*data sources create*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceCreateCall.html), [*data sources datasets delete*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetDeleteCall.html), [*data sources datasets get*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetGetCall.html), [*data sources datasets patch*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetPatchCall.html), [*data sources get*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceGetCall.html), [*data sources list*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceListCall.html), [*data sources patch*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourcePatchCall.html), [*data sources update*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceUpdateCall.html), [*sessions delete*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionDeleteCall.html), [*sessions list*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionListCall.html) and [*sessions update*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionUpdateCall.html) + * [*data sources create*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceCreateCall.html), [*data sources datasets delete*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetDeleteCall.html), [*data sources datasets get*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetGetCall.html), [*data sources datasets patch*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDatasetPatchCall.html), [*data sources delete*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceDeleteCall.html), [*data sources get*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceGetCall.html), [*data sources list*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceListCall.html), [*data sources patch*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourcePatchCall.html), [*data sources update*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserDataSourceUpdateCall.html), [*sessions delete*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionDeleteCall.html), [*sessions list*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionListCall.html) and [*sessions update*](http://byron.github.io/google-apis-rs/google_fitness1/struct.UserSessionUpdateCall.html) @@ -51,6 +51,7 @@ let r = hub.users().data_sources_get(...).doit() let r = hub.users().data_sources_update(...).doit() let r = hub.users().data_sources_create(...).doit() let r = hub.users().data_sources_patch(...).doit() +let r = hub.users().data_sources_delete(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -96,7 +97,7 @@ let mut hub = Fitness::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: DataSource = Default::default(); +let mut req = DataSource::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/fitness1/src/cmn.rs b/gen/fitness1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/fitness1/src/cmn.rs +++ b/gen/fitness1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/fitness1/src/lib.rs b/gen/fitness1/src/lib.rs index c302949e8e..189affe5e1 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+20150222*, where *20150222* 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.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*. //! //! Everything else about the *fitness* *v1* API can be found at the //! [official documentation site](https://developers.google.com/fit/rest/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.Fitness.html) ... //! //! * users -//! * [*data sources create*](struct.UserDataSourceCreateCall.html), [*data sources datasets delete*](struct.UserDataSourceDatasetDeleteCall.html), [*data sources datasets get*](struct.UserDataSourceDatasetGetCall.html), [*data sources datasets patch*](struct.UserDataSourceDatasetPatchCall.html), [*data sources get*](struct.UserDataSourceGetCall.html), [*data sources list*](struct.UserDataSourceListCall.html), [*data sources patch*](struct.UserDataSourcePatchCall.html), [*data sources update*](struct.UserDataSourceUpdateCall.html), [*sessions delete*](struct.UserSessionDeleteCall.html), [*sessions list*](struct.UserSessionListCall.html) and [*sessions update*](struct.UserSessionUpdateCall.html) +//! * [*data sources create*](struct.UserDataSourceCreateCall.html), [*data sources datasets delete*](struct.UserDataSourceDatasetDeleteCall.html), [*data sources datasets get*](struct.UserDataSourceDatasetGetCall.html), [*data sources datasets patch*](struct.UserDataSourceDatasetPatchCall.html), [*data sources delete*](struct.UserDataSourceDeleteCall.html), [*data sources get*](struct.UserDataSourceGetCall.html), [*data sources list*](struct.UserDataSourceListCall.html), [*data sources patch*](struct.UserDataSourcePatchCall.html), [*data sources update*](struct.UserDataSourceUpdateCall.html), [*sessions delete*](struct.UserSessionDeleteCall.html), [*sessions list*](struct.UserSessionListCall.html) and [*sessions update*](struct.UserSessionUpdateCall.html) //! //! //! @@ -51,6 +51,7 @@ //! let r = hub.users().data_sources_update(...).doit() //! let r = hub.users().data_sources_create(...).doit() //! let r = hub.users().data_sources_patch(...).doit() +//! let r = hub.users().data_sources_delete(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -97,7 +98,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: DataSource = Default::default(); +//! let mut req = DataSource::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -292,7 +293,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DataSource = Default::default(); +/// let mut req = DataSource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -362,9 +363,9 @@ impl<'a, C, A> Fitness<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DataType { /// A field represents one dimension of a data type. - pub field: Vec<DataTypeField>, + pub field: Option<Vec<DataTypeField>>, /// Each data type has a unique, namespaced, name. All data types in the com.google namespace are shared as part of the platform. - pub name: String, + pub name: Option<String>, } impl Part for DataType {} @@ -380,10 +381,10 @@ impl Part for DataType {} pub struct Value { /// Floating point value. When this is set, intVal must not be set. #[serde(rename="fpVal")] - pub fp_val: f64, + pub fp_val: Option<f64>, /// Integer value. When this is set, fpVal must not be set. #[serde(rename="intVal")] - pub int_val: i32, + pub int_val: Option<i32>, } impl Part for Value {} @@ -434,7 +435,7 @@ impl ResponseResult for Dataset {} pub struct ListDataSourcesResponse { /// A previously created data source. #[serde(rename="dataSource")] - pub data_source: Vec<DataSource>, + pub data_source: Option<Vec<DataSource>>, } impl ResponseResult for ListDataSourcesResponse {} @@ -448,14 +449,14 @@ impl ResponseResult for ListDataSourcesResponse {} pub struct Application { /// Package name for this application. This is used as a unique identifier when created by Android applications, but cannot be specified by REST clients. REST clients will have their developer project number reflected into the Data Source data stream IDs, instead of the packageName. #[serde(rename="packageName")] - pub package_name: String, + pub package_name: Option<String>, /// Version of the application. You should update this field whenever the application changes in a way that affects the computation of the data. - pub version: String, + pub version: Option<String>, /// The name of this application. This is required for REST clients, but we do not enforce uniqueness of this name. It is provided as a matter of convenience for other developers who would like to identify which REST created an Application or Data Source. - pub name: String, + pub name: Option<String>, /// An optional URI that can be used to link back to the application. #[serde(rename="detailsUrl")] - pub details_url: String, + pub details_url: Option<String>, } impl Part for Application {} @@ -488,6 +489,9 @@ pub struct Session { /// A start time, in milliseconds since epoch, inclusive. #[serde(rename="startTimeMillis")] pub start_time_millis: Option<String>, + /// Session active time. While start_time_millis and end_time_millis define the full session time, the active time can be shorter and specified by active_time_millis. If the inactive time during the session is known, it should also be inserted via a com.google.activity.segment data point with a STILL activity value + #[serde(rename="activeTimeMillis")] + pub active_time_millis: Option<String>, /// A client-generated identifier that is unique across all sessions owned by this particular user. pub id: Option<String>, /// A human readable name of the session. @@ -511,12 +515,12 @@ impl ResponseResult for Session {} pub struct ListSessionsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// If includeDeleted is set to true in the request, this list will contain sessions deleted with original end times that are within the startTime and endTime frame. #[serde(rename="deletedSession")] - pub deleted_session: Vec<Session>, + pub deleted_session: Option<Vec<Session>>, /// Sessions with an end time that is between startTime and endTime of the request. - pub session: Vec<Session>, + pub session: Option<Vec<Session>>, } impl ResponseResult for ListSessionsResponse {} @@ -535,16 +539,16 @@ impl ResponseResult for ListSessionsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Device { /// End-user visible model name for the device. - pub model: String, + pub model: Option<String>, /// Version string for the device hardware/software. - pub version: String, + pub version: Option<String>, /// A constant representing the type of the device. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The serial number or other unique ID for the hardware. This field is obfuscated when read by any REST or Android client that did not create the data source. Only the data source creator will see the uid field in clear and normal form. - pub uid: String, + pub uid: Option<String>, /// Manufacturer of the product/hardware. - pub manufacturer: String, + pub manufacturer: Option<String>, } impl Part for Device {} @@ -559,11 +563,11 @@ impl Part for Device {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DataTypeField { /// no description provided - pub optional: bool, + pub optional: Option<bool>, /// Defines the name and format of data. Unlike data type names, field names are not namespaced, and only need to be unique within the data type. - pub name: String, + pub name: Option<String>, /// The different supported formats for each field in a data type. - pub format: String, + pub format: Option<String>, } impl Part for DataTypeField {} @@ -581,29 +585,29 @@ impl Part for DataTypeField {} pub struct DataPoint { /// Used for version checking during transformation; that is, a datapoint can only replace another datapoint that has an older computation time stamp. #[serde(rename="computationTimeMillis")] - pub computation_time_millis: String, + pub computation_time_millis: Option<String>, /// Indicates the last time this data point was modified. Useful only in contexts where we are listing the data changes, rather than representing the current state of the data. #[serde(rename="modifiedTimeMillis")] - pub modified_time_millis: String, + pub modified_time_millis: Option<String>, /// The start time of the interval represented by this data point, in nanoseconds since epoch. #[serde(rename="startTimeNanos")] - pub start_time_nanos: String, + pub start_time_nanos: Option<String>, /// The data type defining the format of the values in this data point. #[serde(rename="dataTypeName")] - pub data_type_name: String, + pub data_type_name: Option<String>, /// Values of each data type field for the data point. It is expected that each value corresponding to a data type field will occur in the same order that the field is listed with in the data type specified in a data source. /// /// Only one of integer and floating point fields will be populated, depending on the format enum value within data source's type field. - pub value: Vec<Value>, + pub value: Option<Vec<Value>>, /// The end time of the interval represented by this data point, in nanoseconds since epoch. #[serde(rename="endTimeNanos")] - pub end_time_nanos: String, + pub end_time_nanos: Option<String>, /// If the data point is contained in a dataset for a derived data source, this field will be populated with the data source stream ID that created the data point originally. #[serde(rename="originDataSourceId")] - pub origin_data_source_id: String, + pub origin_data_source_id: Option<String>, /// The raw timestamp from the original SensorEvent. #[serde(rename="rawTimestampNanos")] - pub raw_timestamp_nanos: String, + pub raw_timestamp_nanos: Option<String>, } impl Part for DataPoint {} @@ -624,6 +628,7 @@ impl Part for DataPoint {} /// * [data sources update users](struct.UserDataSourceUpdateCall.html) (request|response) /// * [data sources create users](struct.UserDataSourceCreateCall.html) (request|response) /// * [data sources patch users](struct.UserDataSourcePatchCall.html) (request|response) +/// * [data sources delete users](struct.UserDataSourceDeleteCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DataSource { @@ -693,7 +698,7 @@ impl ResponseResult for DataSource {} /// <MemoryStorage as Default>::default(), None); /// let mut hub = Fitness::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `data_sources_create(...)`, `data_sources_datasets_delete(...)`, `data_sources_datasets_get(...)`, `data_sources_datasets_patch(...)`, `data_sources_get(...)`, `data_sources_list(...)`, `data_sources_patch(...)`, `data_sources_update(...)`, `sessions_delete(...)`, `sessions_list(...)` and `sessions_update(...)` +/// // like `data_sources_create(...)`, `data_sources_datasets_delete(...)`, `data_sources_datasets_get(...)`, `data_sources_datasets_patch(...)`, `data_sources_delete(...)`, `data_sources_get(...)`, `data_sources_list(...)`, `data_sources_patch(...)`, `data_sources_update(...)`, `sessions_delete(...)`, `sessions_list(...)` and `sessions_update(...)` /// // to build up your call. /// let rb = hub.users(); /// # } @@ -708,6 +713,25 @@ impl<'a, C, A> MethodsBuilder for UserMethods<'a, C, A> {} impl<'a, C, A> UserMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Delete the data source if there are no datapoints associated with it + /// + /// # Arguments + /// + /// * `userId` - Retrieve a 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 delete. + pub fn data_sources_delete(&self, user_id: &str, data_source_id: &str) -> UserDataSourceDeleteCall<'a, C, A> { + UserDataSourceDeleteCall { + hub: self.hub, + _user_id: user_id.to_string(), + _data_source_id: data_source_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Returns a dataset containing all data points whose start and end times overlap with the specified range of the dataset minimum start time and maximum end time. Specifically, any data point whose start time is less than or equal to the dataset end time and whose end time is greater than or equal to the dataset start time. @@ -952,6 +976,252 @@ impl<'a, C, A> UserMethods<'a, C, A> { // CallBuilders ### // ################# +/// Delete the data source if there are no datapoints associated with it +/// +/// A builder for the *dataSources.delete* method supported by a *user* resource. +/// It is not used directly, but through a `UserMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_fitness1 as fitness1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use fitness1::Fitness; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Fitness::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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_delete("userId", "dataSourceId") +/// .doit(); +/// # } +/// ``` +pub struct UserDataSourceDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Fitness<C, A>, + _user_id: String, + _data_source_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for UserDataSourceDeleteCall<'a, C, A> {} + +impl<'a, C, A> UserDataSourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, DataSource)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "fitness.users.dataSources.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("userId", self._user_id.to_string())); + params.push(("dataSourceId", self._data_source_id.to_string())); + for &field in ["alt", "userId", "dataSourceId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ActivityWrite.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{userId}", "userId"), ("{dataSourceId}", "dataSourceId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2); + for param_name in ["userId", "dataSourceId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Retrieve a data source for the person identified. Use me to indicate the authenticated user. Only me is supported at this time. + /// + /// Sets the *user id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn user_id(mut self, new_value: &str) -> UserDataSourceDeleteCall<'a, C, A> { + self._user_id = new_value.to_string(); + self + } + /// The data stream ID of the data source to delete. + /// + /// Sets the *data source id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn data_source_id(mut self, new_value: &str) -> UserDataSourceDeleteCall<'a, C, A> { + self._data_source_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> UserDataSourceDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> UserDataSourceDeleteCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ActivityWrite`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> UserDataSourceDeleteCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Returns a dataset containing all data points whose start and end times overlap with the specified range of the dataset minimum start time and maximum end time. Specifically, any data point whose start time is less than or equal to the dataset end time and whose end time is greater than or equal to the dataset start time. /// /// A builder for the *dataSources.datasets.get* method supported by a *user* resource. @@ -979,8 +1249,8 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().data_sources_datasets_get("userId", "dataSourceId", "datasetId") -/// .page_token("justo") -/// .limit(-1) +/// .page_token("erat") +/// .limit(-35) /// .doit(); /// # } /// ``` @@ -1074,16 +1344,20 @@ impl<'a, C, A> UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1257,7 +1531,7 @@ impl<'a, C, A> UserDataSourceDatasetGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DataSource = Default::default(); +/// let mut req = DataSource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1349,16 +1623,20 @@ impl<'a, C, A> UserDataSourceCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1511,8 +1789,8 @@ impl<'a, C, A> UserDataSourceCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().data_sources_datasets_delete("userId", "dataSourceId", "datasetId") -/// .modified_time_millis("dolores") -/// .current_time_millis("gubergren") +/// .modified_time_millis("sadipscing") +/// .current_time_millis("aliquyam") /// .doit(); /// # } /// ``` @@ -1605,16 +1883,20 @@ impl<'a, C, A> UserDataSourceDatasetDeleteCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1778,13 +2060,13 @@ impl<'a, C, A> UserDataSourceDatasetDeleteCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::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_datasets_patch(&req, "userId", "dataSourceId", "datasetId") -/// .current_time_millis("no") +/// .current_time_millis("justo") /// .doit(); /// # } /// ``` @@ -1879,16 +2161,20 @@ impl<'a, C, A> UserDataSourceDatasetPatchCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2068,7 +2354,7 @@ impl<'a, C, A> UserDataSourceDatasetPatchCall<'a, C, A> where C: BorrowMut<hyper /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().sessions_delete("userId", "sessionId") -/// .current_time_millis("et") +/// .current_time_millis("diam") /// .doit(); /// # } /// ``` @@ -2155,16 +2441,20 @@ impl<'a, C, A> UserSessionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2394,16 +2684,20 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2555,7 +2849,7 @@ impl<'a, C, A> UserDataSourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DataSource = Default::default(); +/// let mut req = DataSource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2649,16 +2943,20 @@ impl<'a, C, A> UserDataSourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2821,10 +3119,10 @@ impl<'a, C, A> UserDataSourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().sessions_list("userId") -/// .start_time("duo") -/// .page_token("aliquyam") -/// .include_deleted(true) -/// .end_time("Lorem") +/// .start_time("sea") +/// .page_token("Lorem") +/// .include_deleted(false) +/// .end_time("erat") /// .doit(); /// # } /// ``` @@ -2922,16 +3220,20 @@ impl<'a, C, A> UserSessionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3099,13 +3401,13 @@ impl<'a, C, A> UserSessionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Session = Default::default(); +/// let mut req = Session::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().sessions_update(&req, "userId", "sessionId") -/// .current_time_millis("sadipscing") +/// .current_time_millis("eirmod") /// .doit(); /// # } /// ``` @@ -3198,16 +3500,20 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3379,7 +3685,7 @@ impl<'a, C, A> UserSessionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DataSource = Default::default(); +/// let mut req = DataSource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3473,16 +3779,20 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3645,7 +3955,7 @@ impl<'a, C, A> UserDataSourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.users().data_sources_list("userId") -/// .add_data_type_name("amet") +/// .add_data_type_name("labore") /// .doit(); /// # } /// ``` @@ -3735,16 +4045,20 @@ impl<'a, C, A> UserDataSourceListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/freebase1-cli/Cargo.toml b/gen/freebase1-cli/Cargo.toml index dad2d9b4c9..a0cdb38b32 100644 --- a/gen/freebase1-cli/Cargo.toml +++ b/gen/freebase1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-freebase1-cli" version = "0.0.1+20150330" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/freebase/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/freebase1-cli/src/cmn.rs b/gen/freebase1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/freebase1-cli/src/cmn.rs +++ b/gen/freebase1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/freebase1-cli/src/main.rs b/gen/freebase1-cli/src/main.rs index a1449e8a0c..45b2b97349 100644 --- a/gen/freebase1-cli/src/main.rs +++ b/gen/freebase1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -29,6 +30,12 @@ Configuration: 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. "); mod cmn; @@ -52,7 +59,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.methods().reconcile(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "prop" => { call = call.add_prop(value.unwrap_or("")); @@ -102,8 +109,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -115,7 +121,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.methods().search(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "without" => { call = call.add_without(value.unwrap_or("")); @@ -219,7 +225,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { } else { io::copy(&mut response, &mut ostream).unwrap(); @@ -263,21 +268,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "freebase1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "freebase1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "freebase1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "freebase1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Freebase::new(hyper::Client::new(), auth), + hub: api::Freebase::new(client, auth), }; match engine._doit(true) { @@ -297,12 +318,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/freebase1/Cargo.toml b/gen/freebase1/Cargo.toml index b3b4ee7355..3e2ba4cc84 100644 --- a/gen/freebase1/Cargo.toml +++ b/gen/freebase1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-freebase1" version = "0.1.5+20150330" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/freebase/" diff --git a/gen/freebase1/src/cmn.rs b/gen/freebase1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/freebase1/src/cmn.rs +++ b/gen/freebase1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/freebase1/src/lib.rs b/gen/freebase1/src/lib.rs index 93c53559eb..157966f80b 100644 --- a/gen/freebase1/src/lib.rs +++ b/gen/freebase1/src/lib.rs @@ -321,15 +321,15 @@ impl<'a, C, A> Freebase<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileCandidate { /// Language code that candidate and notable names are displayed in. - pub lang: String, + pub lang: Option<String>, /// Percentage likelihood that this candidate is the unique matching entity. Value will be between 0.0 and 1.0 - pub confidence: f32, + pub confidence: Option<f32>, /// Type or profession the candidate is notable for. - pub notable: ReconcileCandidateNotable, + pub notable: Option<ReconcileCandidateNotable>, /// Freebase MID of candidate entity. - pub mid: String, + pub mid: Option<String>, /// Freebase name of matching entity in specified language. - pub name: String, + pub name: Option<String>, } impl Part for ReconcileCandidate {} @@ -342,11 +342,11 @@ impl Part for ReconcileCandidate {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGetWarning { /// Code for identifying classes of warnings. - pub reason: String, + pub reason: Option<String>, /// Warning message to display to the user. - pub message: String, + pub message: Option<String>, /// Location of warning in the request e.g. invalid predicate. - pub location: String, + pub location: Option<String>, } impl NestedType for ReconcileGetWarning {} @@ -360,9 +360,9 @@ impl Part for ReconcileGetWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGetCosts { /// Total number of hits found. - pub hits: i32, + pub hits: Option<i32>, /// Total milliseconds spent. - pub ms: i32, + pub ms: Option<i32>, } impl NestedType for ReconcileGetCosts {} @@ -381,14 +381,14 @@ impl Part for ReconcileGetCosts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGet { /// Server costs for reconciling. - pub costs: ReconcileGetCosts, + pub costs: Option<ReconcileGetCosts>, /// If filled, then there were recoverable problems that affected the request. For example, some of the properties were ignored because they either are not valid Freebase predicates or are not indexed for reconciliation. The candidates returned should be considered valid results, with the caveat that sections of the request were ignored as specified by the warning text. - pub warning: Vec<ReconcileGetWarning>, + pub warning: Option<Vec<ReconcileGetWarning>>, /// If filled, then the listed candidates are potential matches, and such should be evaluated by a more discerning algorithm or human. The matches are ordered by confidence. - pub candidate: Vec<ReconcileCandidate>, + pub candidate: Option<Vec<ReconcileCandidate>>, /// If filled, this entity is guaranteed to match at requested confidence probability (default 99%). #[serde(rename="match")] - pub match_: ReconcileCandidate, + pub match_: Option<ReconcileCandidate>, } impl ResponseResult for ReconcileGet {} @@ -401,9 +401,9 @@ impl ResponseResult for ReconcileGet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileCandidateNotable { /// MID of notable category. - pub id: String, + pub id: Option<String>, /// Name of notable category in specified language. - pub name: String, + pub name: Option<String>, } impl NestedType for ReconcileCandidateNotable {} diff --git a/gen/freebase1_sandbox-cli/Cargo.toml b/gen/freebase1_sandbox-cli/Cargo.toml index d8e78f8732..667b3e0b02 100644 --- a/gen/freebase1_sandbox-cli/Cargo.toml +++ b/gen/freebase1_sandbox-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-freebase1_sandbox-cli" version = "0.0.1+20150330" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/freebase/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/freebase1_sandbox-cli/src/cmn.rs b/gen/freebase1_sandbox-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/freebase1_sandbox-cli/src/cmn.rs +++ b/gen/freebase1_sandbox-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/freebase1_sandbox-cli/src/main.rs b/gen/freebase1_sandbox-cli/src/main.rs index 9fb21de172..8b8138c67d 100644 --- a/gen/freebase1_sandbox-cli/src/main.rs +++ b/gen/freebase1_sandbox-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -29,6 +30,12 @@ Configuration: 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. "); mod cmn; @@ -52,7 +59,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.methods().reconcile(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "prop" => { call = call.add_prop(value.unwrap_or("")); @@ -102,8 +109,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -115,7 +121,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.methods().search(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "without" => { call = call.add_without(value.unwrap_or("")); @@ -219,7 +225,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { } else { io::copy(&mut response, &mut ostream).unwrap(); @@ -263,21 +268,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "freebase1-sandbox-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "freebase1-sandbox-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "freebase1-sandbox", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "freebase1-sandbox", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Freebase::new(hyper::Client::new(), auth), + hub: api::Freebase::new(client, auth), }; match engine._doit(true) { @@ -297,12 +318,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 74a949036e..ca67e181f5 100644 --- a/gen/freebase1_sandbox/Cargo.toml +++ b/gen/freebase1_sandbox/Cargo.toml @@ -5,7 +5,7 @@ name = "google-freebase1_sandbox" version = "0.1.5+20150330" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/freebase/" diff --git a/gen/freebase1_sandbox/src/cmn.rs b/gen/freebase1_sandbox/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/freebase1_sandbox/src/cmn.rs +++ b/gen/freebase1_sandbox/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/freebase1_sandbox/src/lib.rs b/gen/freebase1_sandbox/src/lib.rs index 3fc99143ad..d385457ccc 100644 --- a/gen/freebase1_sandbox/src/lib.rs +++ b/gen/freebase1_sandbox/src/lib.rs @@ -321,15 +321,15 @@ impl<'a, C, A> Freebase<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileCandidate { /// Language code that candidate and notable names are displayed in. - pub lang: String, + pub lang: Option<String>, /// Percentage likelihood that this candidate is the unique matching entity. Value will be between 0.0 and 1.0 - pub confidence: f32, + pub confidence: Option<f32>, /// Type or profession the candidate is notable for. - pub notable: ReconcileCandidateNotable, + pub notable: Option<ReconcileCandidateNotable>, /// Freebase MID of candidate entity. - pub mid: String, + pub mid: Option<String>, /// Freebase name of matching entity in specified language. - pub name: String, + pub name: Option<String>, } impl Part for ReconcileCandidate {} @@ -342,11 +342,11 @@ impl Part for ReconcileCandidate {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGetWarning { /// Code for identifying classes of warnings. - pub reason: String, + pub reason: Option<String>, /// Warning message to display to the user. - pub message: String, + pub message: Option<String>, /// Location of warning in the request e.g. invalid predicate. - pub location: String, + pub location: Option<String>, } impl NestedType for ReconcileGetWarning {} @@ -360,9 +360,9 @@ impl Part for ReconcileGetWarning {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGetCosts { /// Total number of hits found. - pub hits: i32, + pub hits: Option<i32>, /// Total milliseconds spent. - pub ms: i32, + pub ms: Option<i32>, } impl NestedType for ReconcileGetCosts {} @@ -381,14 +381,14 @@ impl Part for ReconcileGetCosts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileGet { /// Server costs for reconciling. - pub costs: ReconcileGetCosts, + pub costs: Option<ReconcileGetCosts>, /// If filled, then there were recoverable problems that affected the request. For example, some of the properties were ignored because they either are not valid Freebase predicates or are not indexed for reconciliation. The candidates returned should be considered valid results, with the caveat that sections of the request were ignored as specified by the warning text. - pub warning: Vec<ReconcileGetWarning>, + pub warning: Option<Vec<ReconcileGetWarning>>, /// If filled, then the listed candidates are potential matches, and such should be evaluated by a more discerning algorithm or human. The matches are ordered by confidence. - pub candidate: Vec<ReconcileCandidate>, + pub candidate: Option<Vec<ReconcileCandidate>>, /// If filled, this entity is guaranteed to match at requested confidence probability (default 99%). #[serde(rename="match")] - pub match_: ReconcileCandidate, + pub match_: Option<ReconcileCandidate>, } impl ResponseResult for ReconcileGet {} @@ -401,9 +401,9 @@ impl ResponseResult for ReconcileGet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReconcileCandidateNotable { /// MID of notable category. - pub id: String, + pub id: Option<String>, /// Name of notable category in specified language. - pub name: String, + pub name: Option<String>, } impl NestedType for ReconcileCandidateNotable {} diff --git a/gen/fusiontables2-cli/Cargo.toml b/gen/fusiontables2-cli/Cargo.toml index 702d395210..0f347f2321 100644 --- a/gen/fusiontables2-cli/Cargo.toml +++ b/gen/fusiontables2-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-fusiontables2-cli" -version = "0.0.1+20150226" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/fusiontables" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/fusiontables2-cli/mkdocs.yml b/gen/fusiontables2-cli/mkdocs.yml index 0e44ed848a..e54d5b7500 100644 --- a/gen/fusiontables2-cli/mkdocs.yml +++ b/gen/fusiontables2-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: fusiontables v0.0.1+20150226 +site_name: fusiontables v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/fusiontables2-cli/src/cmn.rs +++ b/gen/fusiontables2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/fusiontables2-cli/src/main.rs b/gen/fusiontables2-cli/src/main.rs index 8714b8d4ca..ecd401a700 100644 --- a/gen/fusiontables2-cli/src/main.rs +++ b/gen/fusiontables2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -64,6 +65,12 @@ Configuration: 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. "); mod cmn; @@ -87,7 +94,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.column().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -118,7 +125,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -129,7 +135,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.column().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -161,8 +167,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -171,10 +176,10 @@ impl Engine { fn _column_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Column = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -194,9 +199,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -215,20 +221,20 @@ impl Engine { }, "valid-values" => { if request.valid_values.is_none() { - request.valid_values = Some(Default::default()); + request.valid_values = Some(Default::default()); } - request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "base-column.table-index" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().table_index = arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer"); + request.base_column.as_mut().unwrap().table_index = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer")); }, "base-column.column-id" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().column_id = arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer"); + request.base_column.as_mut().unwrap().column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer")); }, "name" => { request_base_column_init(&mut request); @@ -275,8 +281,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -287,7 +292,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.column().list(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -325,8 +330,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -335,10 +339,10 @@ impl Engine { fn _column_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Column = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -358,9 +362,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -379,20 +384,20 @@ impl Engine { }, "valid-values" => { if request.valid_values.is_none() { - request.valid_values = Some(Default::default()); + request.valid_values = Some(Default::default()); } - request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "base-column.table-index" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().table_index = arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer"); + request.base_column.as_mut().unwrap().table_index = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer")); }, "base-column.column-id" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().column_id = arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer"); + request.base_column.as_mut().unwrap().column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer")); }, "name" => { request_base_column_init(&mut request); @@ -439,8 +444,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -449,10 +453,10 @@ impl Engine { fn _column_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Column = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -472,9 +476,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -493,20 +498,20 @@ impl Engine { }, "valid-values" => { if request.valid_values.is_none() { - request.valid_values = Some(Default::default()); + request.valid_values = Some(Default::default()); } - request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.valid_values.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "base-column.table-index" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().table_index = arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer"); + request.base_column.as_mut().unwrap().table_index = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.table-index", "integer")); }, "base-column.column-id" => { request_base_column_init(&mut request); - request.base_column.as_mut().unwrap().column_id = arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer"); + request.base_column.as_mut().unwrap().column_id = Some(arg_from_str(value.unwrap_or("-0"), err, "base-column.column-id", "integer")); }, "name" => { request_base_column_init(&mut request); @@ -553,8 +558,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -566,7 +570,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.query().sql(&self.opt.arg_sql); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "typed" => { call = call.typed(arg_from_str(value.unwrap_or("false"), err, "typed", "boolean")); @@ -607,9 +611,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -624,7 +627,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.query().sql_get(&self.opt.arg_sql); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "typed" => { call = call.typed(arg_from_str(value.unwrap_or("false"), err, "typed", "boolean")); @@ -665,9 +668,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -682,7 +684,7 @@ impl Engine { let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); let mut call = self.hub.style().delete(&self.opt.arg_table_id, style_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -713,7 +715,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -725,7 +726,7 @@ impl Engine { let style_id: i32 = arg_from_str(&self.opt.arg_style_id, err, "<style-id>", "integer"); let mut call = self.hub.style().get(&self.opt.arg_table_id, style_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -757,8 +758,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -767,10 +767,10 @@ impl Engine { fn _style_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::StyleSetting = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -790,50 +790,135 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_marker_options_icon_styler_init(request: &mut api::StyleSetting) { + request_marker_options_init(request); + if request.marker_options.as_mut().unwrap().icon_styler.is_none() { + request.marker_options.as_mut().unwrap().icon_styler = Some(Default::default()); + } + } + fn request_marker_options_init(request: &mut api::StyleSetting) { if request.marker_options.is_none() { request.marker_options = Some(Default::default()); } } + fn request_polygon_options_fill_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_fill_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_fill_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler = Some(Default::default()); + } + } + fn request_polygon_options_init(request: &mut api::StyleSetting) { if request.polygon_options.is_none() { request.polygon_options = Some(Default::default()); } } + fn request_polygon_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_weight_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + fn request_polyline_options_init(request: &mut api::StyleSetting) { if request.polyline_options.is_none() { request.polyline_options = Some(Default::default()); } } + fn request_polyline_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_color_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_weight_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "marker-options.icon-styler.gradient.max" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number"); + 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")); }, "marker-options.icon-styler.gradient.min" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number"); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number")); }, "marker-options.icon-styler.column-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.column_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-styler.kind" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.kind = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_init(&mut request); + request.marker_options.as_mut().unwrap().icon_name = Some(value.unwrap_or("").to_string()); }, "kind" => { request_marker_options_init(&mut request); @@ -844,116 +929,116 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number")); }, "polygon-options.stroke-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number")); }, "polygon-options.stroke-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer")); }, "polygon-options.stroke-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number")); }, "polygon-options.stroke-weight-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number")); }, "polygon-options.stroke-weight-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number")); }, "polygon-options.stroke-weight-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number")); }, "polygon-options.fill-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number")); }, "polygon-options.fill-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number"); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number")); }, "polyline-options.stroke-weight" => { request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer"); + request.polyline_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer")); }, "polyline-options.stroke-weight-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number")); }, "polyline-options.stroke-weight-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number")); }, "polyline-options.stroke-weight-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-weight-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-opacity" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number"); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number")); }, "polyline-options.stroke-color-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number")); }, "polyline-options.stroke-color-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number")); }, "polyline-options.stroke-color-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "table-id" => { request_polyline_options_init(&mut request); @@ -980,8 +1065,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -992,7 +1076,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.style().list(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1030,8 +1114,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1040,11 +1123,11 @@ impl Engine { fn _style_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::StyleSetting = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1064,50 +1147,135 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_marker_options_icon_styler_init(request: &mut api::StyleSetting) { + request_marker_options_init(request); + if request.marker_options.as_mut().unwrap().icon_styler.is_none() { + request.marker_options.as_mut().unwrap().icon_styler = Some(Default::default()); + } + } + fn request_marker_options_init(request: &mut api::StyleSetting) { if request.marker_options.is_none() { request.marker_options = Some(Default::default()); } } + fn request_polygon_options_fill_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_fill_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_fill_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler = Some(Default::default()); + } + } + fn request_polygon_options_init(request: &mut api::StyleSetting) { if request.polygon_options.is_none() { request.polygon_options = Some(Default::default()); } } + fn request_polygon_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_weight_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + fn request_polyline_options_init(request: &mut api::StyleSetting) { if request.polyline_options.is_none() { request.polyline_options = Some(Default::default()); } } + fn request_polyline_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_color_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_weight_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "marker-options.icon-styler.gradient.max" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number"); + 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")); }, "marker-options.icon-styler.gradient.min" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number"); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number")); }, "marker-options.icon-styler.column-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.column_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-styler.kind" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.kind = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_init(&mut request); + request.marker_options.as_mut().unwrap().icon_name = Some(value.unwrap_or("").to_string()); }, "kind" => { request_marker_options_init(&mut request); @@ -1118,116 +1286,116 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number")); }, "polygon-options.stroke-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number")); }, "polygon-options.stroke-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer")); }, "polygon-options.stroke-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number")); }, "polygon-options.stroke-weight-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number")); }, "polygon-options.stroke-weight-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number")); }, "polygon-options.stroke-weight-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number")); }, "polygon-options.fill-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number")); }, "polygon-options.fill-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number"); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number")); }, "polyline-options.stroke-weight" => { request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer"); + request.polyline_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer")); }, "polyline-options.stroke-weight-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number")); }, "polyline-options.stroke-weight-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number")); }, "polyline-options.stroke-weight-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-weight-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-opacity" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number"); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number")); }, "polyline-options.stroke-color-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number")); }, "polyline-options.stroke-color-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number")); }, "polyline-options.stroke-color-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "table-id" => { request_polyline_options_init(&mut request); @@ -1254,8 +1422,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1264,11 +1431,11 @@ impl Engine { fn _style_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::StyleSetting = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1288,50 +1455,135 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_marker_options_icon_styler_init(request: &mut api::StyleSetting) { + request_marker_options_init(request); + if request.marker_options.as_mut().unwrap().icon_styler.is_none() { + request.marker_options.as_mut().unwrap().icon_styler = Some(Default::default()); + } + } + fn request_marker_options_init(request: &mut api::StyleSetting) { if request.marker_options.is_none() { request.marker_options = Some(Default::default()); } } + fn request_polygon_options_fill_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_fill_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_fill_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().fill_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().fill_color_styler = Some(Default::default()); + } + } + fn request_polygon_options_init(request: &mut api::StyleSetting) { if request.polygon_options.is_none() { request.polygon_options = Some(Default::default()); } } + fn request_polygon_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_color_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polygon_options_stroke_weight_styler_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polygon_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polygon_options_init(request); + if request.polygon_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polygon_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + fn request_polyline_options_init(request: &mut api::StyleSetting) { if request.polyline_options.is_none() { request.polyline_options = Some(Default::default()); } } + fn request_polyline_options_stroke_color_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_color_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_color_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_color_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_color_styler = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_gradient_init(request: &mut api::StyleSetting) { + request_polyline_options_stroke_weight_styler_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient = Some(Default::default()); + } + } + + fn request_polyline_options_stroke_weight_styler_init(request: &mut api::StyleSetting) { + request_polyline_options_init(request); + if request.polyline_options.as_mut().unwrap().stroke_weight_styler.is_none() { + request.polyline_options.as_mut().unwrap().stroke_weight_styler = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "marker-options.icon-styler.gradient.max" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.max", "number"); + 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")); }, "marker-options.icon-styler.gradient.min" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number"); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "marker-options.icon-styler.gradient.min", "number")); }, "marker-options.icon-styler.column-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.column_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-styler.kind" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_styler.kind = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_gradient_init(&mut request); + request.marker_options.as_mut().unwrap().icon_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "marker-options.icon-name" => { - request_marker_options_init(&mut request); - request.marker_options.as_mut().unwrap().icon_name = value.unwrap_or("").to_string(); + request_marker_options_icon_styler_init(&mut request); + request.marker_options.as_mut().unwrap().icon_name = Some(value.unwrap_or("").to_string()); }, "kind" => { request_marker_options_init(&mut request); @@ -1342,116 +1594,116 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.max", "number")); }, "polygon-options.stroke-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number"); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-color-styler.gradient.min", "number")); }, "polygon-options.stroke-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polygon-options.stroke-weight", "integer")); }, "polygon-options.stroke-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number"); + request_polygon_options_stroke_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-opacity", "number")); }, "polygon-options.stroke-weight-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.max", "number")); }, "polygon-options.stroke-weight-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number"); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.stroke-weight-styler.gradient.min", "number")); }, "polygon-options.stroke-weight-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-weight-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_stroke_weight_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.gradient.max" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.max", "number")); }, "polygon-options.fill-color-styler.gradient.min" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number"); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-color-styler.gradient.min", "number")); }, "polygon-options.fill-color-styler.column-name" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.column_name = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color-styler.kind" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color_styler.kind = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_gradient_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.stroke-color" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polygon-options.fill-opacity" => { - request_polygon_options_init(&mut request); - request.polygon_options.as_mut().unwrap().fill_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number"); + request_polygon_options_fill_color_styler_init(&mut request); + request.polygon_options.as_mut().unwrap().fill_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polygon-options.fill-opacity", "number")); }, "polyline-options.stroke-weight" => { request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight = arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer"); + request.polyline_options.as_mut().unwrap().stroke_weight = Some(arg_from_str(value.unwrap_or("-0"), err, "polyline-options.stroke-weight", "integer")); }, "polyline-options.stroke-weight-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.max", "number")); }, "polyline-options.stroke-weight-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number"); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-weight-styler.gradient.min", "number")); }, "polyline-options.stroke-weight-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-weight-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_weight_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_weight_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color = value.unwrap_or("").to_string(); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-opacity" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_opacity = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number"); + request_polyline_options_stroke_weight_styler_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_opacity = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-opacity", "number")); }, "polyline-options.stroke-color-styler.gradient.max" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.max = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().max = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.max", "number")); }, "polyline-options.stroke-color-styler.gradient.min" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.gradient.min = arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number"); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().gradient.as_mut().unwrap().min = Some(arg_from_str(value.unwrap_or("0.0"), err, "polyline-options.stroke-color-styler.gradient.min", "number")); }, "polyline-options.stroke-color-styler.column-name" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.column_name = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().column_name = Some(value.unwrap_or("").to_string()); }, "polyline-options.stroke-color-styler.kind" => { - request_polyline_options_init(&mut request); - request.polyline_options.as_mut().unwrap().stroke_color_styler.kind = value.unwrap_or("").to_string(); + request_polyline_options_stroke_color_styler_gradient_init(&mut request); + request.polyline_options.as_mut().unwrap().stroke_color_styler.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "table-id" => { request_polyline_options_init(&mut request); @@ -1478,8 +1730,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1490,7 +1741,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().copy(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "copy-presentation" => { call = call.copy_presentation(arg_from_str(value.unwrap_or("false"), err, "copy-presentation", "boolean")); @@ -1525,8 +1776,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1537,7 +1787,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().delete(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1568,7 +1818,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1579,7 +1828,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().get(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1611,8 +1860,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1623,7 +1871,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().import_rows(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-line" => { call = call.start_line(arg_from_str(value.unwrap_or("-0"), err, "start-line", "integer")); @@ -1680,8 +1928,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1692,7 +1939,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().import_table(&self.opt.arg_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "encoding" => { call = call.encoding(value.unwrap_or("")); @@ -1740,8 +1987,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1750,10 +1996,10 @@ impl Engine { fn _table_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1773,9 +2019,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1800,9 +2047,9 @@ impl Engine { }, "base-table-ids" => { if request.base_table_ids.is_none() { - request.base_table_ids = Some(Default::default()); + request.base_table_ids = Some(Default::default()); } - request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-properties-json" => { request.table_properties_json = Some(value.unwrap_or("").to_string()); @@ -1836,8 +2083,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1848,7 +2094,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1886,8 +2132,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1896,10 +2141,10 @@ impl Engine { fn _table_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + 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); + 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")); @@ -1922,9 +2167,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1949,9 +2195,9 @@ impl Engine { }, "base-table-ids" => { if request.base_table_ids.is_none() { - request.base_table_ids = Some(Default::default()); + request.base_table_ids = Some(Default::default()); } - request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-properties-json" => { request.table_properties_json = Some(value.unwrap_or("").to_string()); @@ -1985,8 +2231,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1997,7 +2242,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.table().replace_rows(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-line" => { call = call.start_line(arg_from_str(value.unwrap_or("-0"), err, "start-line", "integer")); @@ -2054,8 +2299,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2064,10 +2308,10 @@ impl Engine { fn _table_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + 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); + 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")); @@ -2090,9 +2334,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2117,9 +2362,9 @@ impl Engine { }, "base-table-ids" => { if request.base_table_ids.is_none() { - request.base_table_ids = Some(Default::default()); + request.base_table_ids = Some(Default::default()); } - request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.base_table_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-properties-json" => { request.table_properties_json = Some(value.unwrap_or("").to_string()); @@ -2153,8 +2398,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2165,7 +2409,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.task().delete(&self.opt.arg_table_id, &self.opt.arg_task_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2196,7 +2440,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2207,7 +2450,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.task().get(&self.opt.arg_table_id, &self.opt.arg_task_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2239,8 +2482,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2251,7 +2493,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.task().list(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -2292,8 +2534,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2305,7 +2546,7 @@ impl Engine { let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); let mut call = self.hub.template().delete(&self.opt.arg_table_id, template_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2336,7 +2577,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2348,7 +2588,7 @@ impl Engine { let template_id: i32 = arg_from_str(&self.opt.arg_template_id, err, "<template-id>", "integer"); let mut call = self.hub.template().get(&self.opt.arg_table_id, template_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2380,8 +2620,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2390,10 +2629,10 @@ impl Engine { fn _template_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Template = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2413,9 +2652,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2431,9 +2671,9 @@ impl Engine { }, "automatic-column-names" => { if request.automatic_column_names.is_none() { - request.automatic_column_names = Some(Default::default()); + request.automatic_column_names = Some(Default::default()); } - request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-id" => { request.table_id = Some(value.unwrap_or("").to_string()); @@ -2458,8 +2698,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2470,7 +2709,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.template().list(&self.opt.arg_table_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2508,8 +2747,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2518,11 +2756,11 @@ impl Engine { fn _template_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Template = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2542,9 +2780,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2560,9 +2799,9 @@ impl Engine { }, "automatic-column-names" => { if request.automatic_column_names.is_none() { - request.automatic_column_names = Some(Default::default()); + request.automatic_column_names = Some(Default::default()); } - request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-id" => { request.table_id = Some(value.unwrap_or("").to_string()); @@ -2587,8 +2826,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2597,11 +2835,11 @@ impl Engine { fn _template_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Template = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2621,9 +2859,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2639,9 +2878,9 @@ impl Engine { }, "automatic-column-names" => { if request.automatic_column_names.is_none() { - request.automatic_column_names = Some(Default::default()); + request.automatic_column_names = Some(Default::default()); } - request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.automatic_column_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "table-id" => { request.table_id = Some(value.unwrap_or("").to_string()); @@ -2666,8 +2905,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2695,7 +2933,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_query { + } + else if self.opt.cmd_query { if self.opt.cmd_sql { call_result = self._query_sql(dry_run, &mut err); } else if self.opt.cmd_sql_get { @@ -2703,7 +2942,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_style { + } + else if self.opt.cmd_style { if self.opt.cmd_delete { call_result = self._style_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2719,7 +2959,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_table { + } + else if self.opt.cmd_table { if self.opt.cmd_copy { call_result = self._table_copy(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -2743,7 +2984,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_task { + } + else if self.opt.cmd_task { if self.opt.cmd_delete { call_result = self._task_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2753,7 +2995,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_template { + } + else if self.opt.cmd_template { if self.opt.cmd_delete { call_result = self._template_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2789,21 +3032,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "fusiontables2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "fusiontables2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "fusiontables2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "fusiontables2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Fusiontables::new(hyper::Client::new(), auth), + hub: api::Fusiontables::new(client, auth), }; match engine._doit(true) { @@ -2823,12 +3082,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/fusiontables2/Cargo.toml b/gen/fusiontables2/Cargo.toml index 89156f8085..6e64b99896 100644 --- a/gen/fusiontables2/Cargo.toml +++ b/gen/fusiontables2/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-fusiontables2" -version = "0.1.5+20150226" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/fusiontables" diff --git a/gen/fusiontables2/README.md b/gen/fusiontables2/README.md index c5a0daa9a0..0f664a1cdf 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+20150226*, where *20150226* 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.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*. Everything else about the *fusiontables* *v2* API can be found at the [official documentation site](https://developers.google.com/fusiontables). diff --git a/gen/fusiontables2/src/cmn.rs b/gen/fusiontables2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/fusiontables2/src/cmn.rs +++ b/gen/fusiontables2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/fusiontables2/src/lib.rs b/gen/fusiontables2/src/lib.rs index ea65d9a0fd..fccc60786d 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+20150226*, where *20150226* 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.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*. //! //! Everything else about the *fusiontables* *v2* API can be found at the //! [official documentation site](https://developers.google.com/fusiontables). @@ -384,17 +384,17 @@ impl<'a, C, A> Fusiontables<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Task { /// false while the table is busy with some other task. true if this background task is currently running. - pub started: bool, + pub started: Option<bool>, /// Task percentage completion. - pub progress: String, + pub progress: Option<String>, /// Type of the resource. This is always "fusiontables#task". - pub kind: String, + pub kind: Option<String>, /// Type of background task. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Identifier for the task. #[serde(rename="taskId")] - pub task_id: String, + pub task_id: Option<String>, } impl ResponseResult for Task {} @@ -463,17 +463,17 @@ impl ResponseResult for Column {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Bucket { /// Opacity of the color: 0.0 (transparent) to 1.0 (opaque). - pub opacity: f64, + pub opacity: Option<f64>, /// Width of a line (in pixels). - pub weight: i32, + pub weight: Option<i32>, /// Minimum value in the selected column for a row to be styled according to the bucket color, opacity, icon, or weight. - pub min: f64, + pub min: Option<f64>, /// Color of line or the interior of a polygon in #RRGGBB format. - pub color: String, + pub color: Option<String>, /// Maximum value in the selected column for a row to be styled according to the bucket color, opacity, icon, or weight. - pub max: f64, + pub max: Option<f64>, /// Icon name used for a point. - pub icon: String, + pub icon: Option<String>, } impl Part for Bucket {} @@ -486,14 +486,14 @@ impl Part for Bucket {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StyleFunction { /// Gradient function that interpolates a range of colors based on column value. - pub gradient: StyleFunctionGradient, + pub gradient: Option<StyleFunctionGradient>, /// Name of the column whose value is used in the style. #[serde(rename="columnName")] - pub column_name: String, + pub column_name: Option<String>, /// Bucket function that assigns a style based on the range a column value falls into. - pub buckets: Vec<Bucket>, + pub buckets: Option<Vec<Bucket>>, /// Stylers can be one of three kinds: "fusiontables#fromColumn if the column value is to be used as is, i.e., the column values can have colors in #RRGGBBAA format or integer line widths or icon names; fusiontables#gradient if the styling of the row is to be based on applying the gradient function on the column value; or fusiontables#buckets if the styling is to based on the bucket into which the the column value falls. - pub kind: String, + pub kind: Option<String>, } impl Part for StyleFunction {} @@ -512,14 +512,14 @@ impl Part for StyleFunction {} pub struct TaskList { /// Token used to access the next page of this result. No token is displayed if there are no more pages left. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of all requested tasks. - pub items: Vec<Task>, + pub items: Option<Vec<Task>>, /// Type of the resource. This is always "fusiontables#taskList". - pub kind: String, + pub kind: Option<String>, /// Total number of tasks for the table. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for TaskList {} @@ -532,11 +532,11 @@ impl ResponseResult for TaskList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StyleFunctionGradient { /// Higher-end of the interpolation range: rows with this value will be assigned to colors[n-1]. - pub max: f64, + pub max: Option<f64>, /// Array with two or more colors. - pub colors: Vec<StyleFunctionGradientColors>, + pub colors: Option<Vec<StyleFunctionGradientColors>>, /// Lower-end of the interpolation range: rows with this value will be assigned to colors[0]. - pub min: f64, + pub min: Option<f64>, } impl NestedType for StyleFunctionGradient {} @@ -586,10 +586,10 @@ impl ResponseResult for Template {} pub struct ColumnBaseColumn { /// Offset to the entry in the list of base tables in the table definition. #[serde(rename="tableIndex")] - pub table_index: i32, + pub table_index: Option<i32>, /// The id of the column in the base table from which this column is derived. #[serde(rename="columnId")] - pub column_id: i32, + pub column_id: Option<i32>, } impl NestedType for ColumnBaseColumn {} @@ -609,14 +609,14 @@ impl Part for ColumnBaseColumn {} pub struct ColumnList { /// Token used to access the next page of this result. No token is displayed if there are no more pages left. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of all requested columns. - pub items: Vec<Column>, + pub items: Option<Vec<Column>>, /// The kind of item this is. For a column list, this is always fusiontables#columnList. - pub kind: String, + pub kind: Option<String>, /// Total number of columns for the table. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for ColumnList {} @@ -635,9 +635,9 @@ impl ResponseResult for ColumnList {} pub struct Import { /// The number of rows received from the import request. #[serde(rename="numRowsReceived")] - pub num_rows_received: String, + pub num_rows_received: Option<String>, /// The kind of item this is. For an import, this is always fusiontables#import. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Import {} @@ -651,19 +651,19 @@ impl ResponseResult for Import {} pub struct LineStyle { /// Width of the line in pixels. #[serde(rename="strokeWeight")] - pub stroke_weight: i32, + pub stroke_weight: Option<i32>, /// Column-value or bucket styler that is used to determine the width of the line. #[serde(rename="strokeWeightStyler")] - pub stroke_weight_styler: StyleFunction, + pub stroke_weight_styler: Option<StyleFunction>, /// Color of the line in #RRGGBB format. #[serde(rename="strokeColor")] - pub stroke_color: String, + pub stroke_color: Option<String>, /// Opacity of the line : 0.0 (transparent) to 1.0 (opaque). #[serde(rename="strokeOpacity")] - pub stroke_opacity: f64, + pub stroke_opacity: Option<f64>, /// Column-value, gradient or buckets styler that is used to determine the line color and opacity. #[serde(rename="strokeColorStyler")] - pub stroke_color_styler: StyleFunction, + pub stroke_color_styler: Option<StyleFunction>, } impl Part for LineStyle {} @@ -677,28 +677,28 @@ impl Part for LineStyle {} pub struct PolygonStyle { /// Column-value, gradient or buckets styler that is used to determine the border color and opacity. #[serde(rename="strokeColorStyler")] - pub stroke_color_styler: StyleFunction, + pub stroke_color_styler: Option<StyleFunction>, /// Width of the polyon border in pixels. #[serde(rename="strokeWeight")] - pub stroke_weight: i32, + pub stroke_weight: Option<i32>, /// Opacity of the polygon border: 0.0 (transparent) to 1.0 (opaque). #[serde(rename="strokeOpacity")] - pub stroke_opacity: f64, + pub stroke_opacity: Option<f64>, /// Column-value or bucket styler that is used to determine the width of the polygon border. #[serde(rename="strokeWeightStyler")] - pub stroke_weight_styler: StyleFunction, + pub stroke_weight_styler: Option<StyleFunction>, /// Column-value, gradient, or bucket styler that is used to determine the interior color and opacity of the polygon. #[serde(rename="fillColorStyler")] - pub fill_color_styler: StyleFunction, + pub fill_color_styler: Option<StyleFunction>, /// Color of the interior of the polygon in #RRGGBB format. #[serde(rename="fillColor")] - pub fill_color: String, + pub fill_color: Option<String>, /// Color of the polygon border in #RRGGBB format. #[serde(rename="strokeColor")] - pub stroke_color: String, + pub stroke_color: Option<String>, /// Opacity of the interior of the polygon: 0.0 (transparent) to 1.0 (opaque). #[serde(rename="fillOpacity")] - pub fill_opacity: f64, + pub fill_opacity: Option<f64>, } impl Part for PolygonStyle {} @@ -717,14 +717,14 @@ impl Part for PolygonStyle {} pub struct StyleSettingList { /// Token used to access the next page of this result. No token is displayed if there are no more styles left. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// All requested style settings. - pub items: Vec<StyleSetting>, + pub items: Option<Vec<StyleSetting>>, /// The kind of item this is. For a style list, this is always fusiontables#styleSettingList . - pub kind: String, + pub kind: Option<String>, /// Total number of styles for the table. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for StyleSettingList {} @@ -743,11 +743,11 @@ impl ResponseResult for StyleSettingList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Sqlresponse { /// The kind of item this is. For responses to SQL queries, this is always fusiontables#sqlresponse. - pub kind: String, + pub kind: Option<String>, /// The rows in the table. For each cell we print out whatever cell value (e.g., numeric, string) exists. Thus it is important that each cell contains only one value. - pub rows: Vec<Vec<String>>, + pub rows: Option<Vec<Vec<String>>>, /// Columns in the table. - pub columns: Vec<String>, + pub columns: Option<Vec<String>>, } impl ResponseResult for Sqlresponse {} @@ -761,10 +761,10 @@ impl ResponseResult for Sqlresponse {} pub struct PointStyle { /// Column or a bucket value from which the icon name is to be determined. #[serde(rename="iconStyler")] - pub icon_styler: StyleFunction, + pub icon_styler: Option<StyleFunction>, /// Name of the icon. Use values defined in http://www.google.com/fusiontables/DataSource?dsrcid=308519 #[serde(rename="iconName")] - pub icon_name: String, + pub icon_name: Option<String>, } impl Part for PointStyle {} @@ -822,11 +822,11 @@ impl ResponseResult for StyleSetting {} pub struct TableList { /// Token used to access the next page of this result. No token is displayed if there are no more pages left. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of all requested tables. - pub items: Vec<Table>, + pub items: Option<Vec<Table>>, /// The kind of item this is. For table list, this is always fusiontables#tableList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for TableList {} @@ -845,14 +845,14 @@ impl ResponseResult for TableList {} pub struct TemplateList { /// Token used to access the next page of this result. No token is displayed if there are no more pages left. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of all requested templates. - pub items: Vec<Template>, + pub items: Option<Vec<Template>>, /// The kind of item this is. For a template list, this is always fusiontables#templateList . - pub kind: String, + pub kind: Option<String>, /// Total number of templates for the table. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for TemplateList {} @@ -920,9 +920,9 @@ impl ResponseResult for Table {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StyleFunctionGradientColors { /// Color in #RRGGBB format. - pub color: String, + pub color: Option<String>, /// Opacity of the color: 0.0 (transparent) to 1.0 (opaque). - pub opacity: f64, + pub opacity: Option<f64>, } impl NestedType for StyleFunctionGradientColors {} @@ -1960,16 +1960,20 @@ impl<'a, C, A> StyleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2123,7 +2127,7 @@ impl<'a, C, A> StyleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: StyleSetting = Default::default(); +/// let mut req = StyleSetting::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2217,16 +2221,20 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2389,7 +2397,7 @@ impl<'a, C, A> StyleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: StyleSetting = Default::default(); +/// let mut req = StyleSetting::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2481,16 +2489,20 @@ impl<'a, C, A> StyleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2726,16 +2738,20 @@ impl<'a, C, A> StyleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2967,16 +2983,20 @@ impl<'a, C, A> StyleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3116,7 +3136,7 @@ impl<'a, C, A> StyleDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: StyleSetting = Default::default(); +/// let mut req = StyleSetting::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3210,16 +3230,20 @@ impl<'a, C, A> StylePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3478,16 +3502,20 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3730,16 +3758,20 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3962,16 +3994,20 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4121,7 +4157,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Column = Default::default(); +/// let mut req = Column::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4213,16 +4249,20 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4375,7 +4415,7 @@ impl<'a, C, A> ColumnInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Column = Default::default(); +/// let mut req = Column::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4469,16 +4509,20 @@ impl<'a, C, A> ColumnUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4732,16 +4776,20 @@ impl<'a, C, A> ColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4895,7 +4943,7 @@ impl<'a, C, A> ColumnListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Column = Default::default(); +/// let mut req = Column::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4989,16 +5037,20 @@ impl<'a, C, A> ColumnPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5243,16 +5295,20 @@ impl<'a, C, A> ColumnDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5475,16 +5531,20 @@ impl<'a, C, A> ColumnGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5634,7 +5694,7 @@ impl<'a, C, A> ColumnGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Template = Default::default(); +/// let mut req = Template::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5728,16 +5788,20 @@ impl<'a, C, A> TemplateUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5991,16 +6055,20 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6236,16 +6304,20 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6385,7 +6457,7 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Template = Default::default(); +/// let mut req = Template::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6477,16 +6549,20 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6639,7 +6715,7 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Template = Default::default(); +/// let mut req = Template::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6733,16 +6809,20 @@ impl<'a, C, A> TemplatePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6988,16 +7068,20 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7238,16 +7322,20 @@ impl<'a, C, A> QuerySqlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7499,16 +7587,20 @@ impl<'a, C, A> QuerySqlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7669,7 +7761,7 @@ impl<'a, C, A> QuerySqlCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7766,16 +7858,20 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8053,16 +8149,20 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -8335,7 +8435,7 @@ impl<'a, C, A> TableReplaceRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8432,16 +8532,20 @@ impl<'a, C, A> TableUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8681,16 +8785,20 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8820,7 +8928,7 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8886,16 +8994,20 @@ impl<'a, C, A> TableInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9119,16 +9231,20 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9333,16 +9449,20 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9604,16 +9724,20 @@ impl<'a, C, A> TableImportRowCall<'a, C, A> where C: BorrowMut<hyper::Client>, A let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -9965,16 +10089,20 @@ impl<'a, C, A> TableImportTableCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -10312,16 +10440,20 @@ impl<'a, C, A> TableCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) diff --git a/gen/games1-cli/Cargo.toml b/gen/games1-cli/Cargo.toml deleted file mode 100644 index 4b59cd7ade..0000000000 --- a/gen/games1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-games1-cli" -version = "0.0.1+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with Games (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/games1-cli" -homepage = "https://developers.google.com/games/services/" -documentation = "http://byron.github.io/google-apis-rs/google_games1_cli" -license = "MIT" -keywords = ["games", "google", "cli"] - -[[bin]] -name = "games1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-games1] -path = "../games1" diff --git a/gen/games1-cli/LICENSE.md b/gen/games1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/games1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/games1-cli/README.md b/gen/games1-cli/README.md deleted file mode 100644 index f03dc20a84..0000000000 --- a/gen/games1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO GAMES:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/games1-cli/mkdocs.yml b/gen/games1-cli/mkdocs.yml deleted file mode 100644 index 163358d6fb..0000000000 --- a/gen/games1-cli/mkdocs.yml +++ /dev/null @@ -1,68 +0,0 @@ -site_name: Games v0.0.1+20150325 -site_url: http://byron.github.io/google-apis-rs/google-games1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/games1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['achievement-definitions_list.md', 'Achievement Definitions', 'List'] -- ['achievements_increment.md', 'Achievements', 'Increment'] -- ['achievements_list.md', 'Achievements', 'List'] -- ['achievements_reveal.md', 'Achievements', 'Reveal'] -- ['achievements_set-steps-at-least.md', 'Achievements', 'Set Steps At Least'] -- ['achievements_unlock.md', 'Achievements', 'Unlock'] -- ['achievements_update-multiple.md', 'Achievements', 'Update Multiple'] -- ['applications_get.md', 'Applications', 'Get'] -- ['applications_played.md', 'Applications', 'Played'] -- ['events_list-by-player.md', 'Events', 'List By Player'] -- ['events_list-definitions.md', 'Events', 'List Definitions'] -- ['events_record.md', 'Events', 'Record'] -- ['leaderboards_get.md', 'Leaderboards', 'Get'] -- ['leaderboards_list.md', 'Leaderboards', 'List'] -- ['metagame_get-metagame-config.md', 'Metagame', 'Get Metagame Config'] -- ['metagame_list-categories-by-player.md', 'Metagame', 'List Categories By Player'] -- ['players_get.md', 'Players', 'Get'] -- ['players_list.md', 'Players', 'List'] -- ['pushtokens_remove.md', 'Pushtokens', 'Remove'] -- ['pushtokens_update.md', 'Pushtokens', 'Update'] -- ['quest-milestones_claim.md', 'Quest Milestones', 'Claim'] -- ['quests_accept.md', 'Quests', 'Accept'] -- ['quests_list.md', 'Quests', 'List'] -- ['revisions_check.md', 'Revisions', 'Check'] -- ['rooms_create.md', 'Rooms', 'Create'] -- ['rooms_decline.md', 'Rooms', 'Decline'] -- ['rooms_dismiss.md', 'Rooms', 'Dismiss'] -- ['rooms_get.md', 'Rooms', 'Get'] -- ['rooms_join.md', 'Rooms', 'Join'] -- ['rooms_leave.md', 'Rooms', 'Leave'] -- ['rooms_list.md', 'Rooms', 'List'] -- ['rooms_report-status.md', 'Rooms', 'Report Status'] -- ['scores_get.md', 'Scores', 'Get'] -- ['scores_list.md', 'Scores', 'List'] -- ['scores_list-window.md', 'Scores', 'List Window'] -- ['scores_submit.md', 'Scores', 'Submit'] -- ['scores_submit-multiple.md', 'Scores', 'Submit Multiple'] -- ['snapshots_get.md', 'Snapshots', 'Get'] -- ['snapshots_list.md', 'Snapshots', 'List'] -- ['turn-based-matches_cancel.md', 'Turn Based Matches', 'Cancel'] -- ['turn-based-matches_create.md', 'Turn Based Matches', 'Create'] -- ['turn-based-matches_decline.md', 'Turn Based Matches', 'Decline'] -- ['turn-based-matches_dismiss.md', 'Turn Based Matches', 'Dismiss'] -- ['turn-based-matches_finish.md', 'Turn Based Matches', 'Finish'] -- ['turn-based-matches_get.md', 'Turn Based Matches', 'Get'] -- ['turn-based-matches_join.md', 'Turn Based Matches', 'Join'] -- ['turn-based-matches_leave.md', 'Turn Based Matches', 'Leave'] -- ['turn-based-matches_leave-turn.md', 'Turn Based Matches', 'Leave Turn'] -- ['turn-based-matches_list.md', 'Turn Based Matches', 'List'] -- ['turn-based-matches_rematch.md', 'Turn Based Matches', 'Rematch'] -- ['turn-based-matches_sync.md', 'Turn Based Matches', 'Sync'] -- ['turn-based-matches_take-turn.md', 'Turn Based Matches', 'Take Turn'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/games1-cli/src/cmn.rs b/gen/games1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/games1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/games1-cli/src/main.rs b/gen/games1-cli/src/main.rs deleted file mode 100644 index 4e2d390504..0000000000 --- a/gen/games1-cli/src/main.rs +++ /dev/null @@ -1,3366 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_games1 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Games<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _achievement_definitions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.achievement_definitions().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_increment(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let steps_to_increment: i32 = arg_from_str(&self.opt.arg_steps_to_increment, err, "<steps-to-increment>", "integer"); - let mut call = self.hub.achievements().increment(&self.opt.arg_achievement_id, steps_to_increment); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "request-id" => { - call = call.request_id(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.achievements().list(&self.opt.arg_player_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "state" => { - call = call.state(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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_reveal(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.achievements().reveal(&self.opt.arg_achievement_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_set_steps_at_least(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let steps: i32 = arg_from_str(&self.opt.arg_steps, err, "<steps>", "integer"); - let mut call = self.hub.achievements().set_steps_at_least(&self.opt.arg_achievement_id, steps); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_unlock(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.achievements().unlock(&self.opt.arg_achievement_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _achievements_update_multiple(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::AchievementUpdateMultipleRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _applications_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.applications().get(&self.opt.arg_application_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "platform-type" => { - call = call.platform_type(value.unwrap_or("")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _applications_played(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.applications().played(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _events_list_by_player(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.events().list_by_player(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _events_list_definitions(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.events().list_definitions(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _events_record(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::EventRecordRequest = Default::default(); - let mut call = self.hub.events().record(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _leaderboards_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.leaderboards().get(&self.opt.arg_leaderboard_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _leaderboards_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.leaderboards().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _metagame_get_metagame_config(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.metagame().get_metagame_config(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _metagame_list_categories_by_player(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.metagame().list_categories_by_player(&self.opt.arg_player_id, &self.opt.arg_collection); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _players_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.players().get(&self.opt.arg_player_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _players_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.players().list(&self.opt.arg_collection); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _pushtokens_remove(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::PushTokenId = Default::default(); - let mut call = self.hub.pushtokens().remove(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "ios.apns-environment" => { - request_ios_init(&mut request); - request.ios.as_mut().unwrap().apns_environment = 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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _pushtokens_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::PushToken = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_id_init(request: &mut api::PushToken) { - if request.id.is_none() { - request.id = Some(Default::default()); - } - } - - fn request_id_ios_init(request: &mut api::PushToken) { - request_id_init(request); - if request.id.as_mut().unwrap().ios.is_none() { - request.id.as_mut().unwrap().ios = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "client-revision" => { - request.client_revision = Some(value.unwrap_or("").to_string()); - }, - "id.kind" => { - request_id_init(&mut request); - request.id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "id.ios.apns-device-token" => { - request_id_ios_init(&mut request); - request.id.as_mut().unwrap().ios.as_mut().unwrap().apns_device_token = value.unwrap_or("").to_string(); - }, - "id.ios.apns-environment" => { - request_id_ios_init(&mut request); - request.id.as_mut().unwrap().ios.as_mut().unwrap().apns_environment = value.unwrap_or("").to_string(); - }, - "language" => { - request_id_init(&mut request); - 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); - match match protocol { - "standard-request" => call.doit(), - _ => unreachable!(), - } { - Err(api_err) => Some(api_err), - Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _quest_milestones_claim(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.quest_milestones().claim(&self.opt.arg_quest_id, &self.opt.arg_milestone_id, &self.opt.arg_request_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _quests_accept(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.quests().accept(&self.opt.arg_quest_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _quests_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.quests().list(&self.opt.arg_player_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _revisions_check(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.revisions().check(&self.opt.arg_client_revision); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::RoomCreateRequest = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_auto_matching_criteria_init(request: &mut api::RoomCreateRequest) { - if request.auto_matching_criteria.is_none() { - request.auto_matching_criteria = Some(Default::default()); - } - } - - fn request_client_address_init(request: &mut api::RoomCreateRequest) { - if request.client_address.is_none() { - request.client_address = Some(Default::default()); - } - } - - fn request_network_diagnostics_init(request: &mut api::RoomCreateRequest) { - if request.network_diagnostics.is_none() { - request.network_diagnostics = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "auto-matching-criteria.kind" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "auto-matching-criteria.min-auto-matching-players" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().min_auto_matching_players = arg_from_str(value.unwrap_or("-0"), err, "auto-matching-criteria.min-auto-matching-players", "integer"); - }, - "auto-matching-criteria.exclusive-bitmask" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().exclusive_bitmask = value.unwrap_or("").to_string(); - }, - "auto-matching-criteria.max-auto-matching-players" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().max_auto_matching_players = arg_from_str(value.unwrap_or("-0"), err, "auto-matching-criteria.max-auto-matching-players", "integer"); - }, - "invited-player-ids" => { - request_auto_matching_criteria_init(&mut request); - if request.invited_player_ids.is_none() { - request.invited_player_ids = Some(Default::default()); - } - request.invited_player_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "variant" => { - request_auto_matching_criteria_init(&mut request); - request.variant = Some(arg_from_str(value.unwrap_or("-0"), err, "variant", "integer")); - }, - "capabilities" => { - request_auto_matching_criteria_init(&mut request); - if request.capabilities.is_none() { - request.capabilities = Some(Default::default()); - } - request.capabilities.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "network-diagnostics.kind" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "network-diagnostics.ios-network-type" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().ios_network_type = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.ios-network-type", "integer"); - }, - "network-diagnostics.network-operator-code" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().network_operator_code = value.unwrap_or("").to_string(); - }, - "network-diagnostics.android-network-subtype" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().android_network_subtype = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.android-network-subtype", "integer"); - }, - "network-diagnostics.network-operator-name" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().network_operator_name = value.unwrap_or("").to_string(); - }, - "network-diagnostics.registration-latency-millis" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().registration_latency_millis = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.registration-latency-millis", "integer"); - }, - "network-diagnostics.android-network-type" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().android_network_type = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.android-network-type", "integer"); - }, - "client-address.kind" => { - request_client_address_init(&mut request); - request.client_address.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "client-address.xmpp-address" => { - request_client_address_init(&mut request); - request.client_address.as_mut().unwrap().xmpp_address = value.unwrap_or("").to_string(); - }, - "request-id" => { - request_client_address_init(&mut request); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_decline(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.rooms().decline(&self.opt.arg_room_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_dismiss(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.rooms().dismiss(&self.opt.arg_room_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _rooms_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.rooms().get(&self.opt.arg_room_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_join(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::RoomJoinRequest = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_client_address_init(request: &mut api::RoomJoinRequest) { - if request.client_address.is_none() { - request.client_address = Some(Default::default()); - } - } - - fn request_network_diagnostics_init(request: &mut api::RoomJoinRequest) { - if request.network_diagnostics.is_none() { - request.network_diagnostics = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "network-diagnostics.kind" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "network-diagnostics.ios-network-type" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().ios_network_type = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.ios-network-type", "integer"); - }, - "network-diagnostics.network-operator-code" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().network_operator_code = value.unwrap_or("").to_string(); - }, - "network-diagnostics.android-network-subtype" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().android_network_subtype = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.android-network-subtype", "integer"); - }, - "network-diagnostics.network-operator-name" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().network_operator_name = value.unwrap_or("").to_string(); - }, - "network-diagnostics.registration-latency-millis" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().registration_latency_millis = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.registration-latency-millis", "integer"); - }, - "network-diagnostics.android-network-type" => { - request_network_diagnostics_init(&mut request); - request.network_diagnostics.as_mut().unwrap().android_network_type = arg_from_str(value.unwrap_or("-0"), err, "network-diagnostics.android-network-type", "integer"); - }, - "client-address.kind" => { - request_client_address_init(&mut request); - request.client_address.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "client-address.xmpp-address" => { - request_client_address_init(&mut request); - request.client_address.as_mut().unwrap().xmpp_address = value.unwrap_or("").to_string(); - }, - "kind" => { - request_client_address_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "capabilities" => { - request_client_address_init(&mut request); - if request.capabilities.is_none() { - request.capabilities = Some(Default::default()); - } - request.capabilities.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - 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()[..] { - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "reason" => { - request.reason = Some(value.unwrap_or("").to_string()); - }, - "leave-diagnostics.kind" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "leave-diagnostics.sockets-used" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().sockets_used = arg_from_str(value.unwrap_or("false"), err, "leave-diagnostics.sockets-used", "boolean"); - }, - "leave-diagnostics.ios-network-type" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().ios_network_type = arg_from_str(value.unwrap_or("-0"), err, "leave-diagnostics.ios-network-type", "integer"); - }, - "leave-diagnostics.network-operator-code" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().network_operator_code = value.unwrap_or("").to_string(); - }, - "leave-diagnostics.android-network-subtype" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().android_network_subtype = arg_from_str(value.unwrap_or("-0"), err, "leave-diagnostics.android-network-subtype", "integer"); - }, - "leave-diagnostics.network-operator-name" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().network_operator_name = value.unwrap_or("").to_string(); - }, - "leave-diagnostics.android-network-type" => { - request_leave_diagnostics_init(&mut request); - request.leave_diagnostics.as_mut().unwrap().android_network_type = 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()))); - } - } - } - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.rooms().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _rooms_report_status(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::RoomP2PStatuses = Default::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _scores_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.scores().get(&self.opt.arg_player_id, &self.opt.arg_leaderboard_id, &self.opt.arg_time_span); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "language" => { - call = call.language(value.unwrap_or("")); - }, - "include-rank-type" => { - call = call.include_rank_type(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _scores_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.scores().list(&self.opt.arg_leaderboard_id, &self.opt.arg_collection, &self.opt.arg_time_span); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _scores_list_window(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.scores().list_window(&self.opt.arg_leaderboard_id, &self.opt.arg_collection, &self.opt.arg_time_span); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "return-top-if-absent" => { - call = call.return_top_if_absent(arg_from_str(value.unwrap_or("false"), err, "return-top-if-absent", "boolean")); - }, - "results-above" => { - call = call.results_above(arg_from_str(value.unwrap_or("-0"), err, "results-above", "integer")); - }, - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _scores_submit(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.scores().submit(&self.opt.arg_leaderboard_id, &self.opt.arg_score); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "score-tag" => { - call = call.score_tag(value.unwrap_or("")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _scores_submit_multiple(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::PlayerScoreSubmissionList = Default::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _snapshots_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.snapshots().get(&self.opt.arg_snapshot_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _snapshots_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.snapshots().list(&self.opt.arg_player_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_cancel(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().cancel(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _turn_based_matches_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::TurnBasedMatchCreateRequest = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - 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()[..] { - "invited-player-ids" => { - if request.invited_player_ids.is_none() { - request.invited_player_ids = Some(Default::default()); - } - request.invited_player_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "auto-matching-criteria.kind" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().kind = value.unwrap_or("").to_string(); - }, - "auto-matching-criteria.min-auto-matching-players" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().min_auto_matching_players = arg_from_str(value.unwrap_or("-0"), err, "auto-matching-criteria.min-auto-matching-players", "integer"); - }, - "auto-matching-criteria.exclusive-bitmask" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().exclusive_bitmask = value.unwrap_or("").to_string(); - }, - "auto-matching-criteria.max-auto-matching-players" => { - request_auto_matching_criteria_init(&mut request); - request.auto_matching_criteria.as_mut().unwrap().max_auto_matching_players = arg_from_str(value.unwrap_or("-0"), err, "auto-matching-criteria.max-auto-matching-players", "integer"); - }, - "variant" => { - request_auto_matching_criteria_init(&mut request); - request.variant = Some(arg_from_str(value.unwrap_or("-0"), err, "variant", "integer")); - }, - "request-id" => { - request_auto_matching_criteria_init(&mut request); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_decline(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().decline(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_dismiss(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().dismiss(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _turn_based_matches_finish(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::TurnBasedMatchResults = Default::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "data.data" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().data = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().get(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "language" => { - call = call.language(value.unwrap_or("")); - }, - "include-match-data" => { - call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_join(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().join(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_leave(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().leave(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_leave_turn(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let match_version: i32 = arg_from_str(&self.opt.arg_match_version, err, "<match-version>", "integer"); - let mut call = self.hub.turn_based_matches().leave_turn(&self.opt.arg_match_id, match_version); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "pending-participant-id" => { - call = call.pending_participant_id(value.unwrap_or("")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "max-completed-matches" => { - call = call.max_completed_matches(arg_from_str(value.unwrap_or("-0"), err, "max-completed-matches", "integer")); - }, - "language" => { - call = call.language(value.unwrap_or("")); - }, - "include-match-data" => { - call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_rematch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().rematch(&self.opt.arg_match_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "request-id" => { - call = call.request_id(value.unwrap_or("")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_sync(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.turn_based_matches().sync(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "max-completed-matches" => { - call = call.max_completed_matches(arg_from_str(value.unwrap_or("-0"), err, "max-completed-matches", "integer")); - }, - "language" => { - call = call.language(value.unwrap_or("")); - }, - "include-match-data" => { - call = call.include_match_data(arg_from_str(value.unwrap_or("false"), err, "include-match-data", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _turn_based_matches_take_turn(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::TurnBasedMatchTurn = Default::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "data.data" => { - request_data_init(&mut request); - request.data.as_mut().unwrap().data = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_achievement_definitions { - if self.opt.cmd_list { - call_result = self._achievement_definitions_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_achievements { - if self.opt.cmd_increment { - call_result = self._achievements_increment(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._achievements_list(dry_run, &mut err); - } else if self.opt.cmd_reveal { - call_result = self._achievements_reveal(dry_run, &mut err); - } else if self.opt.cmd_set_steps_at_least { - call_result = self._achievements_set_steps_at_least(dry_run, &mut err); - } else if self.opt.cmd_unlock { - call_result = self._achievements_unlock(dry_run, &mut err); - } else if self.opt.cmd_update_multiple { - call_result = self._achievements_update_multiple(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_applications { - if self.opt.cmd_get { - call_result = self._applications_get(dry_run, &mut err); - } else if self.opt.cmd_played { - call_result = self._applications_played(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_events { - if self.opt.cmd_list_by_player { - call_result = self._events_list_by_player(dry_run, &mut err); - } else if self.opt.cmd_list_definitions { - call_result = self._events_list_definitions(dry_run, &mut err); - } else if self.opt.cmd_record { - call_result = self._events_record(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_leaderboards { - if self.opt.cmd_get { - call_result = self._leaderboards_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._leaderboards_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_metagame { - if self.opt.cmd_get_metagame_config { - call_result = self._metagame_get_metagame_config(dry_run, &mut err); - } else if self.opt.cmd_list_categories_by_player { - call_result = self._metagame_list_categories_by_player(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_players { - if self.opt.cmd_get { - call_result = self._players_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._players_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_pushtokens { - if self.opt.cmd_remove { - call_result = self._pushtokens_remove(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._pushtokens_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_quest_milestones { - if self.opt.cmd_claim { - call_result = self._quest_milestones_claim(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_quests { - if self.opt.cmd_accept { - call_result = self._quests_accept(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._quests_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_revisions { - if self.opt.cmd_check { - call_result = self._revisions_check(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_rooms { - if self.opt.cmd_create { - call_result = self._rooms_create(dry_run, &mut err); - } else if self.opt.cmd_decline { - call_result = self._rooms_decline(dry_run, &mut err); - } else if self.opt.cmd_dismiss { - call_result = self._rooms_dismiss(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._rooms_get(dry_run, &mut err); - } else if self.opt.cmd_join { - call_result = self._rooms_join(dry_run, &mut err); - } else if self.opt.cmd_leave { - call_result = self._rooms_leave(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._rooms_list(dry_run, &mut err); - } else if self.opt.cmd_report_status { - call_result = self._rooms_report_status(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_scores { - if self.opt.cmd_get { - call_result = self._scores_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._scores_list(dry_run, &mut err); - } else if self.opt.cmd_list_window { - call_result = self._scores_list_window(dry_run, &mut err); - } else if self.opt.cmd_submit { - call_result = self._scores_submit(dry_run, &mut err); - } else if self.opt.cmd_submit_multiple { - call_result = self._scores_submit_multiple(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_snapshots { - if self.opt.cmd_get { - call_result = self._snapshots_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._snapshots_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_turn_based_matches { - if self.opt.cmd_cancel { - call_result = self._turn_based_matches_cancel(dry_run, &mut err); - } else if self.opt.cmd_create { - call_result = self._turn_based_matches_create(dry_run, &mut err); - } else if self.opt.cmd_decline { - call_result = self._turn_based_matches_decline(dry_run, &mut err); - } else if self.opt.cmd_dismiss { - call_result = self._turn_based_matches_dismiss(dry_run, &mut err); - } else if self.opt.cmd_finish { - call_result = self._turn_based_matches_finish(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._turn_based_matches_get(dry_run, &mut err); - } else if self.opt.cmd_join { - call_result = self._turn_based_matches_join(dry_run, &mut err); - } else if self.opt.cmd_leave { - call_result = self._turn_based_matches_leave(dry_run, &mut err); - } else if self.opt.cmd_leave_turn { - call_result = self._turn_based_matches_leave_turn(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._turn_based_matches_list(dry_run, &mut err); - } else if self.opt.cmd_rematch { - call_result = self._turn_based_matches_rematch(dry_run, &mut err); - } else if self.opt.cmd_sync { - call_result = self._turn_based_matches_sync(dry_run, &mut err); - } else if self.opt.cmd_take_turn { - call_result = self._turn_based_matches_take_turn(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "games1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "games1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Games::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/games1/Cargo.toml b/gen/games1/Cargo.toml index 536262b0e5..9909ccecab 100644 --- a/gen/games1/Cargo.toml +++ b/gen/games1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-games1" -version = "0.1.5+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/games/services/" diff --git a/gen/games1/README.md b/gen/games1/README.md index 97c837a6c1..2a17bc66d0 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+20150325*, where *20150325* 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.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*. Everything else about the *Games* *v1* API can be found at the [official documentation site](https://developers.google.com/games/services/). diff --git a/gen/games1/src/cmn.rs b/gen/games1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/games1/src/cmn.rs +++ b/gen/games1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/games1/src/lib.rs b/gen/games1/src/lib.rs index 92b133b7a0..90d7567422 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+20150325*, where *20150325* 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.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*. //! //! Everything else about the *Games* *v1* API can be found at the //! [official documentation site](https://developers.google.com/games/services/). @@ -416,12 +416,12 @@ impl<'a, C, A> Games<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Category { /// The category name. - pub category: String, + pub category: Option<String>, /// Experience points earned in this category. #[serde(rename="experiencePoints")] - pub experience_points: String, + pub experience_points: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#category. - pub kind: String, + pub kind: Option<String>, } impl Part for Category {} @@ -440,11 +440,11 @@ impl Part for Category {} pub struct PlayerListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The players. - pub items: Vec<Player>, + pub items: Option<Vec<Player>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for PlayerListResponse {} @@ -457,22 +457,22 @@ impl ResponseResult for PlayerListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlayerScore { /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerScore. - pub kind: String, + pub kind: Option<String>, /// The numerical value for this player score. - pub score: String, + pub score: Option<String>, /// The formatted score for this player score. #[serde(rename="formattedScore")] - pub formatted_score: String, + pub formatted_score: Option<String>, /// Additional information about this score. Values will contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. #[serde(rename="scoreTag")] - pub score_tag: String, + pub score_tag: Option<String>, /// The time span for this player score. /// Possible values are: /// - "ALL_TIME" - The score is an all-time score. /// - "WEEKLY" - The score is a weekly score. /// - "DAILY" - The score is a daily score. #[serde(rename="timeSpan")] - pub time_span: String, + pub time_span: Option<String>, } impl Part for PlayerScore {} @@ -485,34 +485,34 @@ impl Part for PlayerScore {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Instance { /// Uniquely identifies the type of this resource. Value is always the fixed string games#instance. - pub kind: String, + pub kind: Option<String>, /// URI which shows where a user can acquire this instance. #[serde(rename="acquisitionUri")] - pub acquisition_uri: String, + pub acquisition_uri: Option<String>, /// Localized display name. - pub name: String, + pub name: Option<String>, /// Flag to show if this game instance supports turn based play. #[serde(rename="turnBasedPlay")] - pub turn_based_play: bool, + pub turn_based_play: Option<bool>, /// Platform dependent details for Web. #[serde(rename="webInstance")] - pub web_instance: InstanceWebDetails, + pub web_instance: Option<InstanceWebDetails>, /// Platform dependent details for Android. #[serde(rename="androidInstance")] - pub android_instance: InstanceAndroidDetails, + pub android_instance: Option<InstanceAndroidDetails>, /// Platform dependent details for iOS. #[serde(rename="iosInstance")] - pub ios_instance: InstanceIosDetails, + pub ios_instance: Option<InstanceIosDetails>, /// The platform type. /// Possible values are: /// - "ANDROID" - Instance is for Android. /// - "IOS" - Instance is for iOS /// - "WEB_APP" - Instance is for Web App. #[serde(rename="platformType")] - pub platform_type: String, + pub platform_type: Option<String>, /// Flag to show if this game instance supports realtime play. #[serde(rename="realtimePlay")] - pub realtime_play: bool, + pub realtime_play: Option<bool>, } impl Part for Instance {} @@ -589,9 +589,9 @@ impl Resource for AchievementDefinition {} pub struct AchievementUnlockResponse { /// Whether this achievement was newly unlocked (that is, whether the unlock request for the achievement was the first for the player). #[serde(rename="newlyUnlocked")] - pub newly_unlocked: bool, + pub newly_unlocked: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementUnlockResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AchievementUnlockResponse {} @@ -604,16 +604,16 @@ impl ResponseResult for AchievementUnlockResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RoomAutoMatchingCriteria { /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomAutoMatchingCriteria. - pub kind: String, + pub kind: Option<String>, /// The minimum number of players that should be added to the room by auto-matching. #[serde(rename="minAutoMatchingPlayers")] - pub min_auto_matching_players: i32, + pub min_auto_matching_players: Option<i32>, /// A bitmask indicating when auto-matches are valid. When ANDed with other exclusive bitmasks, the result must be zero. Can be used to support exclusive roles within a game. #[serde(rename="exclusiveBitmask")] - pub exclusive_bitmask: String, + pub exclusive_bitmask: Option<String>, /// The maximum number of players that should be added to the room by auto-matching. #[serde(rename="maxAutoMatchingPlayers")] - pub max_auto_matching_players: i32, + pub max_auto_matching_players: Option<i32>, } impl Part for RoomAutoMatchingCriteria {} @@ -627,12 +627,12 @@ impl Part for RoomAutoMatchingCriteria {} pub struct EventUpdateRequest { /// The ID of the event being modified in this update. #[serde(rename="definitionId")] - pub definition_id: String, + pub definition_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventUpdateRequest. - pub kind: String, + pub kind: Option<String>, /// The number of times this event occurred in this time period. #[serde(rename="updateCount")] - pub update_count: i64, + pub update_count: Option<i64>, } impl Part for EventUpdateRequest {} @@ -651,11 +651,11 @@ impl Part for EventUpdateRequest {} pub struct TurnBasedMatchList { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matches. - pub items: Vec<TurnBasedMatch>, + pub items: Option<Vec<TurnBasedMatch>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for TurnBasedMatchList {} @@ -673,10 +673,10 @@ impl ResponseResult for TurnBasedMatchList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AchievementUpdateMultipleResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementUpdateListResponse. - pub kind: String, + pub kind: Option<String>, /// The updated state of the achievements. #[serde(rename="updatedAchievements")] - pub updated_achievements: Vec<AchievementUpdateResponse>, + pub updated_achievements: Option<Vec<AchievementUpdateResponse>>, } impl ResponseResult for AchievementUpdateMultipleResponse {} @@ -689,10 +689,10 @@ impl ResponseResult for AchievementUpdateMultipleResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventChild { /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventChild. - pub kind: String, + pub kind: Option<String>, /// The ID of the child event. #[serde(rename="childId")] - pub child_id: String, + pub child_id: Option<String>, } impl Part for EventChild {} @@ -706,15 +706,15 @@ impl Part for EventChild {} pub struct EventRecordFailure { /// The ID of the event that was not updated. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventRecordFailure. - pub kind: String, + pub kind: Option<String>, /// The cause for the update failure. /// Possible values are: /// - "NOT_FOUND" - An attempt was made to set an event that was not defined. /// - "INVALID_UPDATE_VALUE" - An attempt was made to increment an event by a non-positive value. #[serde(rename="failureCause")] - pub failure_cause: String, + pub failure_cause: Option<String>, } impl Part for EventRecordFailure {} @@ -728,25 +728,25 @@ impl Part for EventRecordFailure {} pub struct AchievementUpdateResponse { /// The current steps recorded for this achievement if it is incremental. #[serde(rename="currentSteps")] - pub current_steps: i32, + pub current_steps: Option<i32>, /// Whether this achievement was newly unlocked (that is, whether the unlock request for the achievement was the first for the player). #[serde(rename="newlyUnlocked")] - pub newly_unlocked: bool, + pub newly_unlocked: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementUpdateResponse. - pub kind: String, + pub kind: Option<String>, /// The achievement this update is was applied to. #[serde(rename="achievementId")] - pub achievement_id: String, + pub achievement_id: Option<String>, /// Whether the requested updates actually affected the achievement. #[serde(rename="updateOccurred")] - pub update_occurred: bool, + pub update_occurred: Option<bool>, /// The current state of the achievement. /// Possible values are: /// - "HIDDEN" - Achievement is hidden. /// - "REVEALED" - Achievement is revealed. /// - "UNLOCKED" - Achievement is unlocked. #[serde(rename="currentState")] - pub current_state: String, + pub current_state: Option<String>, } impl Part for AchievementUpdateResponse {} @@ -759,13 +759,13 @@ impl Part for AchievementUpdateResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RoomModification { /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomModification. - pub kind: String, + pub kind: Option<String>, /// The timestamp at which they modified the room, in milliseconds since the epoch in UTC. #[serde(rename="modifiedTimestampMillis")] - pub modified_timestamp_millis: String, + pub modified_timestamp_millis: Option<String>, /// The ID of the participant that modified the room. #[serde(rename="participantId")] - pub participant_id: String, + pub participant_id: Option<String>, } impl Part for RoomModification {} @@ -784,11 +784,11 @@ impl Part for RoomModification {} pub struct EventDefinitionListResponse { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The event definitions. - pub items: Vec<EventDefinition>, + pub items: Option<Vec<EventDefinition>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventDefinitionListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for EventDefinitionListResponse {} @@ -806,26 +806,26 @@ impl ResponseResult for EventDefinitionListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlayerScoreResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerScoreResponse. - pub kind: String, + pub kind: Option<String>, /// The time spans where the submitted score is better than the existing score for that time span. /// Possible values are: /// - "ALL_TIME" - The score is an all-time score. /// - "WEEKLY" - The score is a weekly score. /// - "DAILY" - The score is a daily score. #[serde(rename="beatenScoreTimeSpans")] - pub beaten_score_time_spans: Vec<String>, + pub beaten_score_time_spans: Option<Vec<String>>, /// Additional information about this score. Values will contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. #[serde(rename="scoreTag")] - pub score_tag: String, + pub score_tag: Option<String>, /// The scores in time spans that have not been beaten. As an example, the submitted score may be better than the player's DAILY score, but not better than the player's scores for the WEEKLY or ALL_TIME time spans. #[serde(rename="unbeatenScores")] - pub unbeaten_scores: Vec<PlayerScore>, + pub unbeaten_scores: Option<Vec<PlayerScore>>, /// The leaderboard ID that this score was submitted to. #[serde(rename="leaderboardId")] - pub leaderboard_id: String, + pub leaderboard_id: Option<String>, /// The formatted value of the submitted score. #[serde(rename="formattedScore")] - pub formatted_score: String, + pub formatted_score: Option<String>, } impl ResponseResult for PlayerScoreResponse {} @@ -838,15 +838,15 @@ impl ResponseResult for PlayerScoreResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImageAsset { /// The URL of the asset. - pub url: String, + pub url: Option<String>, /// The width of the asset. - pub width: i32, + pub width: Option<i32>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#imageAsset. - pub kind: String, + pub kind: Option<String>, /// The name of the asset. - pub name: String, + pub name: Option<String>, /// The height of the asset. - pub height: i32, + pub height: Option<i32>, } impl Part for ImageAsset {} @@ -885,12 +885,12 @@ impl RequestValue for RoomP2PStatuses {} pub struct AchievementIncrementResponse { /// The current steps recorded for this incremental achievement. #[serde(rename="currentSteps")] - pub current_steps: i32, + pub current_steps: Option<i32>, /// Whether the the current steps for the achievement has reached the number of steps required to unlock. #[serde(rename="newlyUnlocked")] - pub newly_unlocked: bool, + pub newly_unlocked: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementIncrementResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AchievementIncrementResponse {} @@ -909,14 +909,14 @@ impl ResponseResult for AchievementIncrementResponse {} pub struct TurnBasedMatchSync { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matches. - pub items: Vec<TurnBasedMatch>, + pub items: Option<Vec<TurnBasedMatch>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchSync. - pub kind: String, + pub kind: Option<String>, /// True if there were more matches available to fetch at the time the response was generated (which were not returned due to page size limits.) #[serde(rename="moreAvailable")] - pub more_available: bool, + pub more_available: Option<bool>, } impl ResponseResult for TurnBasedMatchSync {} @@ -964,39 +964,39 @@ impl RequestValue for TurnBasedMatchCreateRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Quest { /// The description of the quest. - pub description: String, + pub description: Option<String>, /// The banner image URL for the quest. #[serde(rename="bannerUrl")] - pub banner_url: String, + pub banner_url: Option<String>, /// The timestamp at which the quest was last updated by the user in milliseconds since the epoch in UTC. Only present if the player has accepted the quest. #[serde(rename="lastUpdatedTimestampMillis")] - pub last_updated_timestamp_millis: String, + pub last_updated_timestamp_millis: Option<String>, /// The timestamp at which the user accepted the quest in milliseconds since the epoch in UTC. Only present if the player has accepted the quest. #[serde(rename="acceptedTimestampMillis")] - pub accepted_timestamp_millis: String, + pub accepted_timestamp_millis: Option<String>, /// The icon image URL for the quest. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// The timestamp at which the user should be notified that the quest will end soon in milliseconds since the epoch in UTC. #[serde(rename="notifyTimestampMillis")] - pub notify_timestamp_millis: String, + pub notify_timestamp_millis: Option<String>, /// The ID of the application this quest is part of. #[serde(rename="applicationId")] - pub application_id: String, + pub application_id: Option<String>, /// The ID of the quest. - pub id: String, + pub id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#quest. - pub kind: String, + pub kind: Option<String>, /// The quest milestones. - pub milestones: Vec<QuestMilestone>, + pub milestones: Option<Vec<QuestMilestone>>, /// The name of the quest. - pub name: String, + pub name: Option<String>, /// The timestamp at which the quest becomes active in milliseconds since the epoch in UTC. #[serde(rename="startTimestampMillis")] - pub start_timestamp_millis: String, + pub start_timestamp_millis: Option<String>, /// The timestamp at which the quest ceases to be active in milliseconds since the epoch in UTC. #[serde(rename="endTimestampMillis")] - pub end_timestamp_millis: String, + pub end_timestamp_millis: Option<String>, /// The state of the quest. /// Possible values are: /// - "UPCOMING": The quest is upcoming. The user can see the quest, but cannot accept it until it is open. @@ -1006,13 +1006,13 @@ pub struct Quest { /// - "FAILED": The quest was attempted but was not completed before the deadline expired. /// - "EXPIRED": The quest has expired and was not accepted. /// - "DELETED": The quest should be deleted from the local database. - pub state: String, + pub state: Option<String>, /// Indicates whether the banner image being returned is a default image, or is game-provided. #[serde(rename="isDefaultBannerUrl")] - pub is_default_banner_url: bool, + pub is_default_banner_url: Option<bool>, /// Indicates whether the icon image being returned is a default image, or is game-provided. #[serde(rename="isDefaultIconUrl")] - pub is_default_icon_url: bool, + pub is_default_icon_url: Option<bool>, } impl Resource for Quest {} @@ -1026,15 +1026,15 @@ impl ResponseResult for Quest {} #[derive(Default, Clone, Debug, Serialize)] pub struct AggregateStats { /// The number of messages sent between a pair of peers. - pub count: String, + pub count: Option<String>, /// The maximum amount. - pub max: String, + pub max: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#aggregateStats. - pub kind: String, + pub kind: Option<String>, /// The total number of bytes sent for messages between a pair of peers. - pub sum: String, + pub sum: Option<String>, /// The minimum amount. - pub min: String, + pub min: Option<String>, } impl Part for AggregateStats {} @@ -1053,12 +1053,12 @@ impl Part for AggregateStats {} pub struct AchievementSetStepsAtLeastResponse { /// The current steps recorded for this incremental achievement. #[serde(rename="currentSteps")] - pub current_steps: i32, + pub current_steps: Option<i32>, /// Whether the the current steps for the achievement has reached the number of steps required to unlock. #[serde(rename="newlyUnlocked")] - pub newly_unlocked: bool, + pub newly_unlocked: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementSetStepsAtLeastResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AchievementSetStepsAtLeastResponse {} @@ -1076,13 +1076,13 @@ impl ResponseResult for AchievementSetStepsAtLeastResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetagameConfig { /// Uniquely identifies the type of this resource. Value is always the fixed string games#metagameConfig. - pub kind: String, + pub kind: Option<String>, /// Current version of the metagame configuration data. When this data is updated, the version number will be increased by one. #[serde(rename="currentVersion")] - pub current_version: i32, + pub current_version: Option<i32>, /// The list of player levels. #[serde(rename="playerLevels")] - pub player_levels: Vec<PlayerLevel>, + pub player_levels: Option<Vec<PlayerLevel>>, } impl ResponseResult for MetagameConfig {} @@ -1101,11 +1101,11 @@ impl ResponseResult for MetagameConfig {} pub struct AchievementDefinitionsListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The achievement definitions. - pub items: Vec<AchievementDefinition>, + pub items: Option<Vec<AchievementDefinition>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementDefinitionsListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AchievementDefinitionsListResponse {} @@ -1119,18 +1119,18 @@ impl ResponseResult for AchievementDefinitionsListResponse {} pub struct PeerSessionDiagnostics { /// Unreliable channel diagnostics. #[serde(rename="unreliableChannel")] - pub unreliable_channel: PeerChannelDiagnostics, + pub unreliable_channel: Option<PeerChannelDiagnostics>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#peerSessionDiagnostics. - pub kind: String, + pub kind: Option<String>, /// Reliable channel diagnostics. #[serde(rename="reliableChannel")] - pub reliable_channel: PeerChannelDiagnostics, + pub reliable_channel: Option<PeerChannelDiagnostics>, /// Connected time in milliseconds. #[serde(rename="connectedTimestampMillis")] - pub connected_timestamp_millis: String, + pub connected_timestamp_millis: Option<String>, /// The participant ID of the peer. #[serde(rename="participantId")] - pub participant_id: String, + pub participant_id: Option<String>, } impl Part for PeerSessionDiagnostics {} @@ -1143,9 +1143,9 @@ impl Part for PeerSessionDiagnostics {} #[derive(Default, Clone, Debug, Serialize)] pub struct TurnBasedMatchDataRequest { /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchDataRequest. - pub kind: String, + pub kind: Option<String>, /// The byte representation of the data (limited to 128 kB), as a Base64-encoded string with the URL_SAFE encoding option. - pub data: String, + pub data: Option<String>, } impl Part for TurnBasedMatchDataRequest {} @@ -1158,13 +1158,13 @@ impl Part for TurnBasedMatchDataRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventPeriodRange { /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventPeriodRange. - pub kind: String, + pub kind: Option<String>, /// The time when this update period begins, in millis, since 1970 UTC (Unix Epoch). #[serde(rename="periodStartMillis")] - pub period_start_millis: String, + pub period_start_millis: Option<String>, /// The time when this update period ends, in millis, since 1970 UTC (Unix Epoch). #[serde(rename="periodEndMillis")] - pub period_end_millis: String, + pub period_end_millis: Option<String>, } impl Part for EventPeriodRange {} @@ -1177,12 +1177,12 @@ impl Part for EventPeriodRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ParticipantResult { /// Uniquely identifies the type of this resource. Value is always the fixed string games#participantResult. - pub kind: String, + pub kind: Option<String>, /// The placement or ranking of the participant in the match results; a number from one to the number of participants in the match. Multiple participants may have the same placing value in case of a type. - pub placing: i32, + pub placing: Option<i32>, /// The ID of the participant. #[serde(rename="participantId")] - pub participant_id: String, + pub participant_id: Option<String>, /// The result of the participant for this match. /// Possible values are: /// - "MATCH_RESULT_WIN" - The participant won the match. @@ -1191,7 +1191,7 @@ pub struct ParticipantResult { /// - "MATCH_RESULT_NONE" - There was no winner for the match (nobody wins or loses this kind of game.) /// - "MATCH_RESULT_DISCONNECT" - The participant disconnected / left during the match. /// - "MATCH_RESULT_DISAGREED" - Different clients reported different results for this participant. - pub result: String, + pub result: Option<String>, } impl Part for ParticipantResult {} @@ -1204,25 +1204,25 @@ impl Part for ParticipantResult {} #[derive(Default, Clone, Debug, Serialize)] pub struct NetworkDiagnostics { /// Uniquely identifies the type of this resource. Value is always the fixed string games#networkDiagnostics. - pub kind: String, + pub kind: Option<String>, /// The name of the carrier of the client's network connection. On Android: http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperatorName() On iOS: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html#//apple_ref/occ/instp/CTCarrier/carrierName #[serde(rename="networkOperatorName")] - pub network_operator_name: String, + pub network_operator_name: Option<String>, /// The amount of time in milliseconds it took for the client to establish a connection with the XMPP server. #[serde(rename="registrationLatencyMillis")] - pub registration_latency_millis: i32, + pub registration_latency_millis: Option<i32>, /// iOS network type as defined in Reachability.h. #[serde(rename="iosNetworkType")] - pub ios_network_type: i32, + pub ios_network_type: Option<i32>, /// The MCC+MNC code for the client's network connection. On Android: http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperator() On iOS, see: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html #[serde(rename="networkOperatorCode")] - pub network_operator_code: String, + pub network_operator_code: Option<String>, /// The Android network subtype. #[serde(rename="androidNetworkSubtype")] - pub android_network_subtype: i32, + pub android_network_subtype: Option<i32>, /// The Android network type. #[serde(rename="androidNetworkType")] - pub android_network_type: i32, + pub android_network_type: Option<i32>, } impl Part for NetworkDiagnostics {} @@ -1255,9 +1255,9 @@ impl RequestValue for PushTokenId {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventBatchRecordFailure { /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventBatchRecordFailure. - pub kind: String, + pub kind: Option<String>, /// The time range which was rejected; empty for a request-wide failure. - pub range: EventPeriodRange, + pub range: Option<EventPeriodRange>, /// The cause for the update failure. /// Possible values are: /// - "TOO_LARGE": A batch request was issued with more events than are allowed in a single batch. @@ -1267,7 +1267,7 @@ pub struct EventBatchRecordFailure { /// - "ALREADY_UPDATED": An attempt was made to record a batch of data which was already seen. /// - "RECORD_RATE_HIGH": An attempt was made to record data faster than the server will apply updates. #[serde(rename="failureCause")] - pub failure_cause: String, + pub failure_cause: Option<String>, } impl Part for EventBatchRecordFailure {} @@ -1280,10 +1280,10 @@ impl Part for EventBatchRecordFailure {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RoomClientAddress { /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomClientAddress. - pub kind: String, + pub kind: Option<String>, /// The XMPP address of the client on the Google Games XMPP network. #[serde(rename="xmppAddress")] - pub xmpp_address: String, + pub xmpp_address: Option<String>, } impl Part for RoomClientAddress {} @@ -1297,18 +1297,18 @@ impl Part for RoomClientAddress {} pub struct PlayerExperienceInfo { /// The current number of experience points for the player. #[serde(rename="currentExperiencePoints")] - pub current_experience_points: String, + pub current_experience_points: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerExperienceInfo. - pub kind: String, + pub kind: Option<String>, /// The timestamp when the player was leveled up, in millis since Unix epoch UTC. #[serde(rename="lastLevelUpTimestampMillis")] - pub last_level_up_timestamp_millis: String, + pub last_level_up_timestamp_millis: Option<String>, /// The next level of the player. If the current level is the maximum level, this should be same as the current level. #[serde(rename="nextLevel")] - pub next_level: PlayerLevel, + pub next_level: Option<PlayerLevel>, /// The current level of the player. #[serde(rename="currentLevel")] - pub current_level: PlayerLevel, + pub current_level: Option<PlayerLevel>, } impl Part for PlayerExperienceInfo {} @@ -1328,20 +1328,20 @@ impl Part for PlayerExperienceInfo {} pub struct LeaderboardScores { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboardScores. - pub kind: String, + pub kind: Option<String>, /// The pagination token for the previous page of results. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// The total number of scores in the leaderboard. #[serde(rename="numScores")] - pub num_scores: String, + pub num_scores: Option<String>, /// The scores in the leaderboard. - pub items: Vec<LeaderboardEntry>, + pub items: Option<Vec<LeaderboardEntry>>, /// The score of the requesting player on the leaderboard. The player's score may appear both here and in the list of scores above. If you are viewing a public leaderboard and the player is not sharing their gameplay information publicly, the scoreRank and formattedScoreRank values will not be present. #[serde(rename="playerScore")] - pub player_score: LeaderboardEntry, + pub player_score: Option<LeaderboardEntry>, } impl ResponseResult for LeaderboardScores {} @@ -1355,26 +1355,26 @@ impl ResponseResult for LeaderboardScores {} pub struct RoomParticipant { /// True if this participant was auto-matched with the requesting player. #[serde(rename="autoMatched")] - pub auto_matched: bool, + pub auto_matched: Option<bool>, /// The status of the participant with respect to the room. /// Possible values are: /// - "PARTICIPANT_INVITED" - The participant has been invited to join the room, but has not yet responded. /// - "PARTICIPANT_JOINED" - The participant has joined the room (either after creating it or accepting an invitation.) /// - "PARTICIPANT_DECLINED" - The participant declined an invitation to join the room. /// - "PARTICIPANT_LEFT" - The participant joined the room and then left it. - pub status: String, + pub status: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomParticipant. - pub kind: String, + pub kind: Option<String>, /// Information about a player that has been anonymously auto-matched against the requesting player. (Either player or autoMatchedPlayer will be set.) #[serde(rename="autoMatchedPlayer")] - pub auto_matched_player: AnonymousPlayer, + pub auto_matched_player: Option<AnonymousPlayer>, /// Client address for the participant. #[serde(rename="clientAddress")] - pub client_address: RoomClientAddress, + pub client_address: Option<RoomClientAddress>, /// The capabilities which can be used when communicating with this participant. - pub capabilities: Vec<String>, + pub capabilities: Option<Vec<String>>, /// Information about the player. Not populated if this player was anonymously auto-matched against the requesting player. (Either player or autoMatchedPlayer will be set.) - pub player: Player, + pub player: Option<Player>, /// The reason the participant left the room; populated if the participant status is PARTICIPANT_LEFT. /// Possible values are: /// - "PLAYER_LEFT" - The player explicitly chose to leave the room. @@ -1385,11 +1385,11 @@ pub struct RoomParticipant { /// - "TIMEOUT" - The client timed out while waiting for players to join and connect. /// - "PRESENCE_FAILURE" - The client's XMPP connection ended abruptly. #[serde(rename="leaveReason")] - pub leave_reason: String, + pub leave_reason: Option<String>, /// True if this participant is in the fully connected set of peers in the room. - pub connected: bool, + pub connected: Option<bool>, /// An identifier for the participant in the scope of the room. Cannot be used to identify a player across rooms or in other contexts. - pub id: String, + pub id: Option<String>, } impl Part for RoomParticipant {} @@ -1408,36 +1408,36 @@ impl Part for RoomParticipant {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Snapshot { /// Uniquely identifies the type of this resource. Value is always the fixed string games#snapshot. - pub kind: String, + pub kind: Option<String>, /// The description of this snapshot. - pub description: String, + pub description: Option<String>, /// The title of this snapshot. - pub title: String, + pub title: Option<String>, /// The cover image of this snapshot. May be absent if there is no image. #[serde(rename="coverImage")] - pub cover_image: SnapshotImage, + pub cover_image: Option<SnapshotImage>, /// The timestamp (in millis since Unix epoch) of the last modification to this snapshot. #[serde(rename="lastModifiedMillis")] - pub last_modified_millis: String, + pub last_modified_millis: Option<String>, /// The ID of the snapshot. - pub id: String, + pub id: Option<String>, /// The ID of the file underlying this snapshot in the Drive API. Only present if the snapshot is a view on a Drive file and the file is owned by the caller. #[serde(rename="driveId")] - pub drive_id: String, + pub drive_id: Option<String>, /// The duration associated with this snapshot, in millis. #[serde(rename="durationMillis")] - pub duration_millis: String, + pub duration_millis: Option<String>, /// The unique name provided when the snapshot was created. #[serde(rename="uniqueName")] - pub unique_name: String, + pub unique_name: Option<String>, /// The type of this snapshot. /// Possible values are: /// - "SAVE_GAME" - A snapshot representing a save game. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The progress value (64-bit integer set by developer) associated with this snapshot. #[serde(rename="progressValue")] - pub progress_value: String, + pub progress_value: Option<String>, } impl Resource for Snapshot {} @@ -1494,9 +1494,9 @@ impl RequestValue for RoomLeaveRequest {} pub struct PlayerScoreListResponse { /// The score submissions statuses. #[serde(rename="submittedScores")] - pub submitted_scores: Vec<PlayerScoreResponse>, + pub submitted_scores: Option<Vec<PlayerScoreResponse>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerScoreListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for PlayerScoreListResponse {} @@ -1509,28 +1509,28 @@ impl ResponseResult for PlayerScoreListResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct RoomLeaveDiagnostics { /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomLeaveDiagnostics. - pub kind: String, + pub kind: Option<String>, /// Whether or not sockets were used. #[serde(rename="socketsUsed")] - pub sockets_used: bool, + pub sockets_used: Option<bool>, /// iOS network type as defined in Reachability.h. #[serde(rename="iosNetworkType")] - pub ios_network_type: i32, + pub ios_network_type: Option<i32>, /// The MCC+MNC code for the client's network connection. On Android: http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperator() On iOS, see: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html #[serde(rename="networkOperatorCode")] - pub network_operator_code: String, + pub network_operator_code: Option<String>, /// Diagnostics about all peer sessions. #[serde(rename="peerSession")] - pub peer_session: Vec<PeerSessionDiagnostics>, + pub peer_session: Option<Vec<PeerSessionDiagnostics>>, /// Android network subtype. http://developer.android.com/reference/android/net/NetworkInfo.html#getSubtype() #[serde(rename="androidNetworkSubtype")] - pub android_network_subtype: i32, + pub android_network_subtype: Option<i32>, /// The name of the carrier of the client's network connection. On Android: http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkOperatorName() On iOS: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html#//apple_ref/occ/instp/CTCarrier/carrierName #[serde(rename="networkOperatorName")] - pub network_operator_name: String, + pub network_operator_name: Option<String>, /// Android network type. http://developer.android.com/reference/android/net/NetworkInfo.html#getType() #[serde(rename="androidNetworkType")] - pub android_network_type: i32, + pub android_network_type: Option<i32>, } impl Part for RoomLeaveDiagnostics {} @@ -1580,12 +1580,12 @@ impl Resource for QuestMilestone {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TurnBasedMatchRematch { /// The newly created match; a rematch of the old match with the same participants. - pub rematch: TurnBasedMatch, + pub rematch: Option<TurnBasedMatch>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchRematch. - pub kind: String, + pub kind: Option<String>, /// The old match that the rematch was created from; will be updated such that the rematchId field will point at the new match. #[serde(rename="previousMatch")] - pub previous_match: TurnBasedMatch, + pub previous_match: Option<TurnBasedMatch>, } impl ResponseResult for TurnBasedMatchRematch {} @@ -1604,13 +1604,13 @@ impl ResponseResult for TurnBasedMatchRematch {} pub struct PlayerLeaderboardScoreListResponse { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The leaderboard scores. - pub items: Vec<PlayerLeaderboardScore>, + pub items: Option<Vec<PlayerLeaderboardScore>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerLeaderboardScoreListResponse. - pub kind: String, + pub kind: Option<String>, /// The Player resources for the owner of this score. - pub player: Player, + pub player: Option<Player>, } impl ResponseResult for PlayerLeaderboardScoreListResponse {} @@ -1629,36 +1629,36 @@ impl ResponseResult for PlayerLeaderboardScoreListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Application { /// The category of the application. - pub category: ApplicationCategory, + pub category: Option<ApplicationCategory>, /// A hint to the client UI for what color to use as an app-themed color. The color is given as an RGB triplet (e.g. "E0E0E0"). #[serde(rename="themeColor")] - pub theme_color: String, + pub theme_color: Option<String>, /// The description of the application. - pub description: String, + pub description: Option<String>, /// The author of the application. - pub author: String, + pub author: Option<String>, /// The last updated timestamp of the application. #[serde(rename="lastUpdatedTimestamp")] - pub last_updated_timestamp: String, + pub last_updated_timestamp: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#application. - pub kind: String, + pub kind: Option<String>, /// The instances of the application. - pub instances: Vec<Instance>, + pub instances: Option<Vec<Instance>>, /// A list of features that have been enabled for the application. /// Possible values are: /// - "SNAPSHOTS" - Snapshots has been enabled #[serde(rename="enabledFeatures")] - pub enabled_features: Vec<String>, + pub enabled_features: Option<Vec<String>>, /// The number of achievements visible to the currently authenticated player. - pub achievement_count: i32, + pub achievement_count: Option<i32>, /// The number of leaderboards visible to the currently authenticated player. - pub leaderboard_count: i32, + pub leaderboard_count: Option<i32>, /// The assets of the application. - pub assets: Vec<ImageAsset>, + pub assets: Option<Vec<ImageAsset>>, /// The ID of the application. - pub id: String, + pub id: Option<String>, /// The name of the application. - pub name: String, + pub name: Option<String>, } impl Resource for Application {} @@ -1673,12 +1673,12 @@ impl ResponseResult for Application {} pub struct Played { /// True if the player was auto-matched with the currently authenticated user. #[serde(rename="autoMatched")] - pub auto_matched: bool, + pub auto_matched: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#played. - pub kind: String, + pub kind: Option<String>, /// The last time the player played the game in milliseconds since the epoch in UTC. #[serde(rename="timeMillis")] - pub time_millis: String, + pub time_millis: Option<String>, } impl Part for Played {} @@ -1692,11 +1692,11 @@ impl Part for Played {} pub struct QuestContribution { /// The formatted value of the contribution as a string. Format depends on the configuration for the associated event definition in the Play Games Developer Console. #[serde(rename="formattedValue")] - pub formatted_value: String, + pub formatted_value: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#questContribution. - pub kind: String, + pub kind: Option<String>, /// The value of the contribution. - pub value: String, + pub value: Option<String>, } impl Part for QuestContribution {} @@ -1710,20 +1710,20 @@ impl Part for QuestContribution {} pub struct QuestCriterion { /// The ID of the event the criterion corresponds to. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The total number of times the associated event must be incremented for the player to complete this quest. #[serde(rename="completionContribution")] - pub completion_contribution: QuestContribution, + pub completion_contribution: Option<QuestContribution>, /// The value of the event associated with this quest at the time that the quest was accepted. This value may change if event increments that took place before the start of quest are uploaded after the quest starts. /// There will be no initialPlayerProgress until the player has accepted the quest. #[serde(rename="initialPlayerProgress")] - pub initial_player_progress: QuestContribution, + pub initial_player_progress: Option<QuestContribution>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#questCriterion. - pub kind: String, + pub kind: Option<String>, /// The number of increments the player has made toward the completion count event increments required to complete the quest. This value will not exceed the completion contribution. /// There will be no currentContribution until the player has accepted the quest. #[serde(rename="currentContribution")] - pub current_contribution: QuestContribution, + pub current_contribution: Option<QuestContribution>, } impl Part for QuestCriterion {} @@ -1742,11 +1742,11 @@ impl Part for QuestCriterion {} pub struct RoomList { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The rooms. - pub items: Vec<Room>, + pub items: Option<Vec<Room>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for RoomList {} @@ -1760,14 +1760,14 @@ impl ResponseResult for RoomList {} pub struct PlayerLevel { /// The maximum experience points for this level. #[serde(rename="maxExperiencePoints")] - pub max_experience_points: String, + pub max_experience_points: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerLevel. - pub kind: String, + pub kind: Option<String>, /// The minimum experience points for this level. #[serde(rename="minExperiencePoints")] - pub min_experience_points: String, + pub min_experience_points: Option<String>, /// The level for the user. - pub level: i32, + pub level: Option<i32>, } impl Part for PlayerLevel {} @@ -1780,10 +1780,10 @@ impl Part for PlayerLevel {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RoomAutoMatchStatus { /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomAutoMatchStatus. - pub kind: String, + pub kind: Option<String>, /// An estimate for the amount of time (in seconds) that auto-matching is expected to take to complete. #[serde(rename="waitEstimateSeconds")] - pub wait_estimate_seconds: i32, + pub wait_estimate_seconds: Option<i32>, } impl Part for RoomAutoMatchStatus {} @@ -1796,12 +1796,12 @@ impl Part for RoomAutoMatchStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TurnBasedMatchData { /// The byte representation of the data (limited to 128 kB), as a Base64-encoded string with the URL_SAFE encoding option. - pub data: String, + pub data: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchData. - pub kind: String, + pub kind: Option<String>, /// True if this match has data available but it wasn't returned in a list response; fetching the match individually will retrieve this data. #[serde(rename="dataAvailable")] - pub data_available: bool, + pub data_available: Option<bool>, } impl Part for TurnBasedMatchData {} @@ -1815,27 +1815,27 @@ impl Part for TurnBasedMatchData {} pub struct EventDefinition { /// Indicates whether the icon image being returned is a default image, or is game-provided. #[serde(rename="isDefaultImageUrl")] - pub is_default_image_url: bool, + pub is_default_image_url: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventDefinition. - pub kind: String, + pub kind: Option<String>, /// The name to display for the event. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// Description of what this event represents. - pub description: String, + pub description: Option<String>, /// The base URL for the image that represents the event. #[serde(rename="imageUrl")] - pub image_url: String, + pub image_url: Option<String>, /// The visibility of event being tracked in this definition. /// Possible values are: /// - "REVEALED": This event should be visible to all users. /// - "HIDDEN": This event should only be shown to users that have recorded this event at least once. - pub visibility: String, + pub visibility: Option<String>, /// A list of events that are a child of this event. #[serde(rename="childEvents")] - pub child_events: Vec<EventChild>, + pub child_events: Option<Vec<EventChild>>, /// The ID of the event. - pub id: String, + pub id: Option<String>, } impl Part for EventDefinition {} @@ -1849,24 +1849,24 @@ impl Part for EventDefinition {} pub struct InstanceIosDetails { /// Indicates that this instance is the default for new installations on iPhone devices. #[serde(rename="preferredForIphone")] - pub preferred_for_iphone: bool, + pub preferred_for_iphone: Option<bool>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#instanceIosDetails. - pub kind: String, + pub kind: Option<String>, /// Flag to indicate if this instance supports iPhone. #[serde(rename="supportIphone")] - pub support_iphone: bool, + pub support_iphone: Option<bool>, /// Indicates that this instance is the default for new installations on iPad devices. #[serde(rename="preferredForIpad")] - pub preferred_for_ipad: bool, + pub preferred_for_ipad: Option<bool>, /// iTunes App ID. #[serde(rename="itunesAppId")] - pub itunes_app_id: String, + pub itunes_app_id: Option<String>, /// Bundle identifier. #[serde(rename="bundleIdentifier")] - pub bundle_identifier: String, + pub bundle_identifier: Option<String>, /// Flag to indicate if this instance supports iPad. #[serde(rename="supportIpad")] - pub support_ipad: bool, + pub support_ipad: Option<bool>, } impl Part for InstanceIosDetails {} @@ -1879,15 +1879,15 @@ impl Part for InstanceIosDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstanceAndroidDetails { /// Uniquely identifies the type of this resource. Value is always the fixed string games#instanceAndroidDetails. - pub kind: String, + pub kind: Option<String>, /// Flag indicating whether the anti-piracy check is enabled. #[serde(rename="enablePiracyCheck")] - pub enable_piracy_check: bool, + pub enable_piracy_check: Option<bool>, /// Android package name which maps to Google Play URL. #[serde(rename="packageName")] - pub package_name: String, + pub package_name: Option<String>, /// Indicates that this instance is the default for new installations. - pub preferred: bool, + pub preferred: Option<bool>, } impl Part for InstanceAndroidDetails {} @@ -1905,13 +1905,13 @@ impl Part for InstanceAndroidDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AchievementRevealResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementRevealResponse. - pub kind: String, + pub kind: Option<String>, /// The current state of the achievement for which a reveal was attempted. This might be UNLOCKED if the achievement was already unlocked. /// Possible values are: /// - "REVEALED" - Achievement is revealed. /// - "UNLOCKED" - Achievement is unlocked. #[serde(rename="currentState")] - pub current_state: String, + pub current_state: Option<String>, } impl ResponseResult for AchievementRevealResponse {} @@ -1942,39 +1942,39 @@ pub struct Room { /// - "ROOM_CONNECTING" - Players have joined and are connecting to each other (either before or after auto-matching). /// - "ROOM_ACTIVE" - All players have joined and connected to each other. /// - "ROOM_DELETED" - The room should no longer be shown on the client. Returned in sync calls when a player joins a room (as a tombstone), or for rooms where all joined participants have left. - pub status: String, + pub status: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#room. - pub kind: String, + pub kind: Option<String>, /// Criteria for auto-matching players into this room. #[serde(rename="autoMatchingCriteria")] - pub auto_matching_criteria: RoomAutoMatchingCriteria, + pub auto_matching_criteria: Option<RoomAutoMatchingCriteria>, /// Details about the room creation. #[serde(rename="creationDetails")] - pub creation_details: RoomModification, + pub creation_details: Option<RoomModification>, /// This short description is generated by our servers and worded relative to the player requesting the room. It is intended to be displayed when the room is shown in a list (that is, an invitation to a room.) - pub description: String, + pub description: Option<String>, /// The version of the room status: an increasing counter, used by the client to ignore out-of-order updates to room status. #[serde(rename="roomStatusVersion")] - pub room_status_version: i32, + pub room_status_version: Option<i32>, /// Auto-matching status for this room. Not set if the room is not currently in the auto-matching queue. #[serde(rename="autoMatchingStatus")] - pub auto_matching_status: RoomAutoMatchStatus, + pub auto_matching_status: Option<RoomAutoMatchStatus>, /// Details about the last update to the room. #[serde(rename="lastUpdateDetails")] - pub last_update_details: RoomModification, + pub last_update_details: Option<RoomModification>, /// The variant / mode of the application being played; can be any integer value, or left blank. - pub variant: i32, + pub variant: Option<i32>, /// The participants involved in the room, along with their statuses. Includes participants who have left or declined invitations. - pub participants: Vec<RoomParticipant>, + pub participants: Option<Vec<RoomParticipant>>, /// Globally unique ID for a room. #[serde(rename="roomId")] - pub room_id: String, + pub room_id: Option<String>, /// The ID of the application being played. #[serde(rename="applicationId")] - pub application_id: String, + pub application_id: Option<String>, /// The ID of the participant that invited the user to the room. Not set if the user was not invited to the room. #[serde(rename="inviterId")] - pub inviter_id: String, + pub inviter_id: Option<String>, } impl Resource for Room {} @@ -1988,34 +1988,34 @@ impl ResponseResult for Room {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LeaderboardEntry { /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboardEntry. - pub kind: String, + pub kind: Option<String>, /// The numerical value of this score. #[serde(rename="scoreValue")] - pub score_value: String, + pub score_value: Option<String>, /// Additional information about the score. Values must contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. #[serde(rename="scoreTag")] - pub score_tag: String, + pub score_tag: Option<String>, /// The time span of this high score. /// Possible values are: /// - "ALL_TIME" - The score is an all-time high score. /// - "WEEKLY" - The score is a weekly high score. /// - "DAILY" - The score is a daily high score. #[serde(rename="timeSpan")] - pub time_span: String, + pub time_span: Option<String>, /// The localized string for the numerical value of this score. #[serde(rename="formattedScore")] - pub formatted_score: String, + pub formatted_score: Option<String>, /// The player who holds this score. - pub player: Player, + pub player: Option<Player>, /// The localized string for the rank of this score for this leaderboard. #[serde(rename="formattedScoreRank")] - pub formatted_score_rank: String, + pub formatted_score_rank: Option<String>, /// The rank of this score for this leaderboard. #[serde(rename="scoreRank")] - pub score_rank: String, + pub score_rank: Option<String>, /// The timestamp at which this score was recorded, in milliseconds since the epoch in UTC. #[serde(rename="writeTimestampMillis")] - pub write_timestamp_millis: String, + pub write_timestamp_millis: Option<String>, } impl Part for LeaderboardEntry {} @@ -2028,16 +2028,16 @@ impl Part for LeaderboardEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TurnBasedAutoMatchingCriteria { /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedAutoMatchingCriteria. - pub kind: String, + pub kind: Option<String>, /// The minimum number of players that should be added to the match by auto-matching. #[serde(rename="minAutoMatchingPlayers")] - pub min_auto_matching_players: i32, + pub min_auto_matching_players: Option<i32>, /// A bitmask indicating when auto-matches are valid. When ANDed with other exclusive bitmasks, the result must be zero. Can be used to support exclusive roles within a game. #[serde(rename="exclusiveBitmask")] - pub exclusive_bitmask: String, + pub exclusive_bitmask: Option<String>, /// The maximum number of players that should be added to the match by auto-matching. #[serde(rename="maxAutoMatchingPlayers")] - pub max_auto_matching_players: i32, + pub max_auto_matching_players: Option<i32>, } impl Part for TurnBasedAutoMatchingCriteria {} @@ -2093,11 +2093,11 @@ impl RequestValue for RoomCreateRequest {} pub struct QuestListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The quests. - pub items: Vec<Quest>, + pub items: Option<Vec<Quest>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#questListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for QuestListResponse {} @@ -2116,11 +2116,11 @@ impl ResponseResult for QuestListResponse {} pub struct PlayerEventListResponse { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The player events. - pub items: Vec<PlayerEvent>, + pub items: Option<Vec<PlayerEvent>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerEventListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for PlayerEventListResponse {} @@ -2133,12 +2133,12 @@ impl ResponseResult for PlayerEventListResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct GamesAchievementIncrement { /// Uniquely identifies the type of this resource. Value is always the fixed string games#GamesAchievementIncrement. - pub kind: String, + pub kind: Option<String>, /// The number of steps to be incremented. - pub steps: i32, + pub steps: Option<i32>, /// The requestId associated with an increment to an achievement. #[serde(rename="requestId")] - pub request_id: String, + pub request_id: Option<String>, } impl Part for GamesAchievementIncrement {} @@ -2151,13 +2151,13 @@ impl Part for GamesAchievementIncrement {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TurnBasedMatchModification { /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchModification. - pub kind: String, + pub kind: Option<String>, /// The timestamp at which they modified the match, in milliseconds since the epoch in UTC. #[serde(rename="modifiedTimestampMillis")] - pub modified_timestamp_millis: String, + pub modified_timestamp_millis: Option<String>, /// The ID of the participant that modified the match. #[serde(rename="participantId")] - pub participant_id: String, + pub participant_id: Option<String>, } impl Part for TurnBasedMatchModification {} @@ -2176,11 +2176,11 @@ impl Part for TurnBasedMatchModification {} pub struct PlayerAchievementListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The achievements. - pub items: Vec<PlayerAchievement>, + pub items: Option<Vec<PlayerAchievement>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerAchievementListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for PlayerAchievementListResponse {} @@ -2221,33 +2221,33 @@ impl Resource for PushToken {} pub struct PlayerLeaderboardScore { /// The timestamp at which this score was recorded, in milliseconds since the epoch in UTC. #[serde(rename="writeTimestamp")] - pub write_timestamp: String, + pub write_timestamp: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerLeaderboardScore. - pub kind: String, + pub kind: Option<String>, /// The public rank of the score in this leaderboard. This object will not be present if the user is not sharing their scores publicly. #[serde(rename="publicRank")] - pub public_rank: LeaderboardScoreRank, + pub public_rank: Option<LeaderboardScoreRank>, /// Additional information about the score. Values must contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. #[serde(rename="scoreTag")] - pub score_tag: String, + pub score_tag: Option<String>, /// The time span of this score. /// Possible values are: /// - "ALL_TIME" - The score is an all-time score. /// - "WEEKLY" - The score is a weekly score. /// - "DAILY" - The score is a daily score. #[serde(rename="timeSpan")] - pub time_span: String, + pub time_span: Option<String>, /// The formatted value of this score. #[serde(rename="scoreString")] - pub score_string: String, + pub score_string: Option<String>, /// The ID of the leaderboard this score is in. - pub leaderboard_id: String, + pub leaderboard_id: Option<String>, /// The numerical value of this score. #[serde(rename="scoreValue")] - pub score_value: String, + pub score_value: Option<String>, /// The social rank of the score in this leaderboard. #[serde(rename="socialRank")] - pub social_rank: LeaderboardScoreRank, + pub social_rank: Option<LeaderboardScoreRank>, } impl Part for PlayerLeaderboardScore {} @@ -2280,15 +2280,15 @@ impl RequestValue for PlayerScoreSubmissionList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SnapshotImage { /// The URL of the image. This URL may be invalidated at any time and should not be cached. - pub url: String, + pub url: Option<String>, /// The width of the image. - pub width: i32, + pub width: Option<i32>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#snapshotImage. - pub kind: String, + pub kind: Option<String>, /// The MIME type of the image. - pub mime_type: String, + pub mime_type: Option<String>, /// The height of the image. - pub height: i32, + pub height: Option<i32>, } impl Part for SnapshotImage {} @@ -2301,13 +2301,13 @@ impl Part for SnapshotImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnonymousPlayer { /// Uniquely identifies the type of this resource. Value is always the fixed string games#anonymousPlayer. - pub kind: String, + pub kind: Option<String>, /// The base URL for the image to display for the anonymous player. #[serde(rename="avatarImageUrl")] - pub avatar_image_url: String, + pub avatar_image_url: Option<String>, /// The name to display for the anonymous player. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, } impl Part for AnonymousPlayer {} @@ -2321,27 +2321,27 @@ impl Part for AnonymousPlayer {} pub struct PeerChannelDiagnostics { /// Number of bytes received. #[serde(rename="bytesReceived")] - pub bytes_received: AggregateStats, + pub bytes_received: Option<AggregateStats>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#peerChannelDiagnostics. - pub kind: String, + pub kind: Option<String>, /// Number of bytes sent. #[serde(rename="bytesSent")] - pub bytes_sent: AggregateStats, + pub bytes_sent: Option<AggregateStats>, /// Number of send failures. #[serde(rename="numSendFailures")] - pub num_send_failures: i32, + pub num_send_failures: Option<i32>, /// Number of messages lost. #[serde(rename="numMessagesLost")] - pub num_messages_lost: i32, + pub num_messages_lost: Option<i32>, /// Number of messages received. #[serde(rename="numMessagesReceived")] - pub num_messages_received: i32, + pub num_messages_received: Option<i32>, /// Number of messages sent. #[serde(rename="numMessagesSent")] - pub num_messages_sent: i32, + pub num_messages_sent: Option<i32>, /// Roundtrip latency stats in milliseconds. #[serde(rename="roundtripLatencyMillis")] - pub roundtrip_latency_millis: AggregateStats, + pub roundtrip_latency_millis: Option<AggregateStats>, } impl Part for PeerChannelDiagnostics {} @@ -2391,20 +2391,20 @@ pub struct RoomStatus { /// - "ROOM_CONNECTING" - Players have joined are connecting to each other (either before or after auto-matching). /// - "ROOM_ACTIVE" - All players have joined and connected to each other. /// - "ROOM_DELETED" - All joined players have left. - pub status: String, + pub status: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomStatus. - pub kind: String, + pub kind: Option<String>, /// The version of the status for the room: an increasing counter, used by the client to ignore out-of-order updates to room status. #[serde(rename="statusVersion")] - pub status_version: i32, + pub status_version: Option<i32>, /// Globally unique ID for a room. #[serde(rename="roomId")] - pub room_id: String, + pub room_id: Option<String>, /// Auto-matching status for this room. Not set if the room is not currently in the automatching queue. #[serde(rename="autoMatchingStatus")] - pub auto_matching_status: RoomAutoMatchStatus, + pub auto_matching_status: Option<RoomAutoMatchStatus>, /// The participants involved in the room, along with their statuses. Includes participants who have left or declined invitations. - pub participants: Vec<RoomParticipant>, + pub participants: Option<Vec<RoomParticipant>>, } impl ResponseResult for RoomStatus {} @@ -2417,9 +2417,9 @@ impl ResponseResult for RoomStatus {} #[derive(Default, Clone, Debug, Serialize)] pub struct PushTokenIdIos { /// Device token supplied by an iOS system call to register for remote notifications. Encode this field as web-safe base64. - pub apns_device_token: String, + pub apns_device_token: Option<String>, /// Indicates whether this token should be used for the production or sandbox APNS server. - pub apns_environment: String, + pub apns_environment: Option<String>, } impl NestedType for PushTokenIdIos {} @@ -2440,21 +2440,21 @@ impl Part for PushTokenIdIos {} pub struct Leaderboard { /// The icon for the leaderboard. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboard. - pub kind: String, + pub kind: Option<String>, /// The name of the leaderboard. - pub name: String, + pub name: Option<String>, /// The leaderboard ID. - pub id: String, + pub id: Option<String>, /// Indicates whether the icon image being returned is a default image, or is game-provided. #[serde(rename="isIconUrlDefault")] - pub is_icon_url_default: bool, + pub is_icon_url_default: Option<bool>, /// How scores are ordered. /// Possible values are: /// - "LARGER_IS_BETTER" - Larger values are better; scores are sorted in descending order. /// - "SMALLER_IS_BETTER" - Smaller values are better; scores are sorted in ascending order. - pub order: String, + pub order: Option<String>, } impl Resource for Leaderboard {} @@ -2469,7 +2469,7 @@ impl ResponseResult for Leaderboard {} pub struct TurnBasedMatchParticipant { /// True if this participant was auto-matched with the requesting player. #[serde(rename="autoMatched")] - pub auto_matched: bool, + pub auto_matched: Option<bool>, /// The status of the participant with respect to the match. /// Possible values are: /// - "PARTICIPANT_NOT_INVITED_YET" - The participant is slated to be invited to the match, but the invitation has not been sent; the invite will be sent when it becomes their turn. @@ -2479,16 +2479,16 @@ pub struct TurnBasedMatchParticipant { /// - "PARTICIPANT_LEFT" - The participant joined the match and then left it. /// - "PARTICIPANT_FINISHED" - The participant finished playing in the match. /// - "PARTICIPANT_UNRESPONSIVE" - The participant did not take their turn in the allotted time. - pub status: String, + pub status: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatchParticipant. - pub kind: String, + pub kind: Option<String>, /// Information about a player that has been anonymously auto-matched against the requesting player. (Either player or autoMatchedPlayer will be set.) #[serde(rename="autoMatchedPlayer")] - pub auto_matched_player: AnonymousPlayer, + pub auto_matched_player: Option<AnonymousPlayer>, /// Information about the player. Not populated if this player was anonymously auto-matched against the requesting player. (Either player or autoMatchedPlayer will be set.) - pub player: Player, + pub player: Option<Player>, /// An identifier for the participant in the scope of the match. Cannot be used to identify a player across matches or in other contexts. - pub id: String, + pub id: Option<String>, } impl Part for TurnBasedMatchParticipant {} @@ -2502,17 +2502,17 @@ impl Part for TurnBasedMatchParticipant {} pub struct LeaderboardScoreRank { /// The number of scores in the leaderboard. #[serde(rename="numScores")] - pub num_scores: String, + pub num_scores: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboardScoreRank. - pub kind: String, + pub kind: Option<String>, /// The rank in the leaderboard as a string. #[serde(rename="formattedRank")] - pub formatted_rank: String, + pub formatted_rank: Option<String>, /// The rank in the leaderboard. - pub rank: String, + pub rank: Option<String>, /// The number of scores in the leaderboard as a string. #[serde(rename="formattedNumScores")] - pub formatted_num_scores: String, + pub formatted_num_scores: Option<String>, } impl Part for LeaderboardScoreRank {} @@ -2526,10 +2526,10 @@ impl Part for LeaderboardScoreRank {} pub struct PlayerName { /// The given name of this player. In some places, this is known as the first name. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The family name of this player. In some places, this is known as the last name. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, } impl NestedType for PlayerName {} @@ -2548,23 +2548,23 @@ pub struct PlayerAchievement { /// - "REVEALED" - Achievement is revealed. /// - "UNLOCKED" - Achievement is unlocked. #[serde(rename="achievementState")] - pub achievement_state: String, + pub achievement_state: Option<String>, /// The current steps for an incremental achievement. #[serde(rename="currentSteps")] - pub current_steps: i32, + pub current_steps: Option<i32>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerAchievement. - pub kind: String, + pub kind: Option<String>, /// Experience points earned for the achievement. This field is absent for achievements that have not yet been unlocked and 0 for achievements that have been unlocked by testers but that are unpublished. #[serde(rename="experiencePoints")] - pub experience_points: String, + pub experience_points: Option<String>, /// The current steps for an incremental achievement as a string. #[serde(rename="formattedCurrentStepsString")] - pub formatted_current_steps_string: String, + pub formatted_current_steps_string: Option<String>, /// The timestamp of the last modification to this achievement's state. #[serde(rename="lastUpdatedTimestamp")] - pub last_updated_timestamp: String, + pub last_updated_timestamp: Option<String>, /// The ID of the achievement. - pub id: String, + pub id: Option<String>, } impl Part for PlayerAchievement {} @@ -2580,26 +2580,26 @@ pub struct RoomP2PStatus { /// Possible values are: /// - "CONNECTION_ESTABLISHED" - The client established a P2P connection with the peer. /// - "CONNECTION_FAILED" - The client failed to establish directed presence with the peer. - pub status: String, + pub status: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#roomP2PStatus. - pub kind: String, + pub kind: Option<String>, /// The ID of the participant. #[serde(rename="participantId")] - pub participant_id: String, + pub participant_id: Option<String>, /// The error code in event of a failure. /// Possible values are: /// - "P2P_FAILED" - The client failed to establish a P2P connection with the peer. /// - "PRESENCE_FAILED" - The client failed to register to receive P2P connections. /// - "RELAY_SERVER_FAILED" - The client received an error when trying to use the relay server to establish a P2P connection with the peer. - pub error: String, + pub error: Option<String>, /// More detailed diagnostic message returned in event of a failure. - pub error_reason: String, + pub error_reason: Option<String>, /// The amount of time in milliseconds it took to send packets back and forth on the unreliable channel with this peer. #[serde(rename="unreliableRoundtripLatencyMillis")] - pub unreliable_roundtrip_latency_millis: i32, + pub unreliable_roundtrip_latency_millis: Option<i32>, /// The amount of time in milliseconds it took to establish connections with this peer. #[serde(rename="connectionSetupLatencyMillis")] - pub connection_setup_latency_millis: i32, + pub connection_setup_latency_millis: Option<i32>, } impl Part for RoomP2PStatus {} @@ -2612,12 +2612,12 @@ impl Part for RoomP2PStatus {} #[derive(Default, Clone, Debug, Serialize)] pub struct EventPeriodUpdate { /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventPeriodUpdate. - pub kind: String, + pub kind: Option<String>, /// The time period being covered by this update. #[serde(rename="timePeriod")] - pub time_period: EventPeriodRange, + pub time_period: Option<EventPeriodRange>, /// The updates being made for this time period. - pub updates: Vec<EventUpdateRequest>, + pub updates: Option<Vec<EventUpdateRequest>>, } impl Part for EventPeriodUpdate {} @@ -2656,11 +2656,11 @@ impl RequestValue for AchievementUpdateMultipleRequest {} pub struct SnapshotListResponse { /// Token corresponding to the next page of results. If there are no more results, the token is omitted. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The snapshots. - pub items: Vec<Snapshot>, + pub items: Option<Vec<Snapshot>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#snapshotListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for SnapshotListResponse {} @@ -2673,11 +2673,11 @@ impl ResponseResult for SnapshotListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ApplicationCategory { /// Uniquely identifies the type of this resource. Value is always the fixed string games#applicationCategory. - pub kind: String, + pub kind: Option<String>, /// The primary category. - pub primary: String, + pub primary: Option<String>, /// The secondary category. - pub secondary: String, + pub secondary: Option<String>, } impl Part for ApplicationCategory {} @@ -2690,17 +2690,17 @@ impl Part for ApplicationCategory {} #[derive(Default, Clone, Debug, Serialize)] pub struct ScoreSubmission { /// Uniquely identifies the type of this resource. Value is always the fixed string games#scoreSubmission. - pub kind: String, + pub kind: Option<String>, /// The leaderboard this score is being submitted to. #[serde(rename="leaderboardId")] - pub leaderboard_id: String, + pub leaderboard_id: Option<String>, /// The new score being submitted. - pub score: String, + pub score: Option<String>, /// Additional information about this score. Values will contain no more than 64 URI-safe characters as defined by section 2.3 of RFC 3986. #[serde(rename="scoreTag")] - pub score_tag: String, + pub score_tag: Option<String>, /// Signature Values will contain URI-safe characters as defined by section 2.3 of RFC 3986. - pub signature: String, + pub signature: Option<String>, } impl Part for ScoreSubmission {} @@ -2785,45 +2785,45 @@ pub struct TurnBasedMatch { /// - "MATCH_CANCELED" - The match was canceled. /// - "MATCH_EXPIRED" - The match expired due to inactivity. /// - "MATCH_DELETED" - The match should no longer be shown on the client. Returned only for tombstones for matches when sync is called. - pub status: String, + pub status: Option<String>, /// Criteria for auto-matching players into this match. #[serde(rename="autoMatchingCriteria")] - pub auto_matching_criteria: TurnBasedAutoMatchingCriteria, + pub auto_matching_criteria: Option<TurnBasedAutoMatchingCriteria>, /// The ID of the participant that invited the user to the match. Not set if the user was not invited to the match. #[serde(rename="inviterId")] - pub inviter_id: String, + pub inviter_id: Option<String>, /// The version of this match: an increasing counter, used to avoid out-of-date updates to the match. #[serde(rename="matchVersion")] - pub match_version: i32, + pub match_version: Option<i32>, /// The variant / mode of the application being played; can be any integer value, or left blank. - pub variant: i32, + pub variant: Option<i32>, /// Globally unique ID for a turn-based match. #[serde(rename="matchId")] - pub match_id: String, + pub match_id: Option<String>, /// The ID of a rematch of this match. Only set for completed matches that have been rematched. #[serde(rename="rematchId")] - pub rematch_id: String, + pub rematch_id: Option<String>, /// The results reported for this match. - pub results: Vec<ParticipantResult>, + pub results: Option<Vec<ParticipantResult>>, /// The number of the match in a chain of rematches. Will be set to 1 for the first match and incremented by 1 for each rematch. #[serde(rename="matchNumber")] - pub match_number: i32, + pub match_number: Option<i32>, /// The data / game state for the previous match; set for the first turn of rematches only. #[serde(rename="previousMatchData")] - pub previous_match_data: TurnBasedMatchData, + pub previous_match_data: Option<TurnBasedMatchData>, /// The ID of the application being played. #[serde(rename="applicationId")] - pub application_id: String, + pub application_id: Option<String>, /// This short description is generated by our servers based on turn state and is localized and worded relative to the player requesting the match. It is intended to be displayed when the match is shown in a list. - pub description: String, + pub description: Option<String>, /// The ID of another participant in the match that can be used when describing the participants the user is playing with. #[serde(rename="withParticipantId")] - pub with_participant_id: String, + pub with_participant_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#turnBasedMatch. - pub kind: String, + pub kind: Option<String>, /// Details about the match creation. #[serde(rename="creationDetails")] - pub creation_details: TurnBasedMatchModification, + pub creation_details: Option<TurnBasedMatchModification>, /// The status of the current user in the match. Derived from the match type, match status, the user's participant status, and the pending participant for the match. /// Possible values are: /// - "USER_INVITED" - The user has been invited to join the match and has not responded yet. @@ -2831,17 +2831,17 @@ pub struct TurnBasedMatch { /// - "USER_TURN" - The user has an action to take in the match. /// - "USER_MATCH_COMPLETED" - The match has ended (it is completed, canceled, or expired.) #[serde(rename="userMatchStatus")] - pub user_match_status: String, + pub user_match_status: Option<String>, /// The data / game state for this match. - pub data: TurnBasedMatchData, + pub data: Option<TurnBasedMatchData>, /// The participants involved in the match, along with their statuses. Includes participants who have left or declined invitations. - pub participants: Vec<TurnBasedMatchParticipant>, + pub participants: Option<Vec<TurnBasedMatchParticipant>>, /// The ID of the participant that is taking a turn. #[serde(rename="pendingParticipantId")] - pub pending_participant_id: String, + pub pending_participant_id: Option<String>, /// Details about the last update to the match. #[serde(rename="lastUpdateDetails")] - pub last_update_details: TurnBasedMatchModification, + pub last_update_details: Option<TurnBasedMatchModification>, } impl ResponseResult for TurnBasedMatch {} @@ -2881,12 +2881,12 @@ impl RequestValue for EventRecordRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstanceWebDetails { /// Uniquely identifies the type of this resource. Value is always the fixed string games#instanceWebDetails. - pub kind: String, + pub kind: Option<String>, /// Launch URL for the game. #[serde(rename="launchUrl")] - pub launch_url: String, + pub launch_url: Option<String>, /// Indicates that this instance is the default for new installations. - pub preferred: bool, + pub preferred: Option<bool>, } impl Part for InstanceWebDetails {} @@ -2905,11 +2905,11 @@ impl Part for InstanceWebDetails {} pub struct CategoryListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of categories with usage data. - pub items: Vec<Category>, + pub items: Option<Vec<Category>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#categoryListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CategoryListResponse {} @@ -2923,18 +2923,18 @@ impl ResponseResult for CategoryListResponse {} pub struct PlayerEvent { /// The ID of the event definition. #[serde(rename="definitionId")] - pub definition_id: String, + pub definition_id: Option<String>, /// The ID of the player. #[serde(rename="playerId")] - pub player_id: String, + pub player_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#playerEvent. - pub kind: String, + pub kind: Option<String>, /// The current number of times this event has occurred. #[serde(rename="numEvents")] - pub num_events: String, + pub num_events: Option<String>, /// The current number of times this event has occurred, as a string. The formatting of this string depends on the configuration of your event in the Play Games Developer Console. #[serde(rename="formattedNumEvents")] - pub formatted_num_events: String, + pub formatted_num_events: Option<String>, } impl Part for PlayerEvent {} @@ -2953,26 +2953,26 @@ impl Part for PlayerEvent {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Player { /// Uniquely identifies the type of this resource. Value is always the fixed string games#player. - pub kind: String, + pub kind: Option<String>, /// The name to display for the player. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// An object representation of the individual components of the player's name. For some players, these fields may not be present. - pub name: PlayerName, + pub name: Option<PlayerName>, /// The player's title rewarded for their game activities. - pub title: String, + pub title: Option<String>, /// The ID of the player. #[serde(rename="playerId")] - pub player_id: String, + pub player_id: Option<String>, /// Details about the last time this player played a multiplayer game with the currently authenticated player. Populated for PLAYED_WITH player collection members. #[serde(rename="lastPlayedWith")] - pub last_played_with: Played, + pub last_played_with: Option<Played>, /// An object to represent Play Game experience information for the player. #[serde(rename="experienceInfo")] - pub experience_info: PlayerExperienceInfo, + pub experience_info: Option<PlayerExperienceInfo>, /// The base URL for the image that represents the player. #[serde(rename="avatarImageUrl")] - pub avatar_image_url: String, + pub avatar_image_url: Option<String>, } impl Resource for Player {} @@ -2992,15 +2992,15 @@ impl ResponseResult for Player {} pub struct EventUpdateResponse { /// The current status of any updated events #[serde(rename="playerEvents")] - pub player_events: Vec<PlayerEvent>, + pub player_events: Option<Vec<PlayerEvent>>, /// Any batch-wide failures which occurred applying updates. #[serde(rename="batchFailures")] - pub batch_failures: Vec<EventBatchRecordFailure>, + pub batch_failures: Option<Vec<EventBatchRecordFailure>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#eventUpdateResponse. - pub kind: String, + pub kind: Option<String>, /// Any failures updating a particular event. #[serde(rename="eventFailures")] - pub event_failures: Vec<EventRecordFailure>, + pub event_failures: Option<Vec<EventRecordFailure>>, } impl ResponseResult for EventUpdateResponse {} @@ -3018,17 +3018,17 @@ impl ResponseResult for EventUpdateResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RevisionCheckResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string games#revisionCheckResponse. - pub kind: String, + pub kind: Option<String>, /// The result of the revision check. /// Possible values are: /// - "OK" - The revision being used is current. /// - "DEPRECATED" - There is currently a newer version available, but the revision being used still works. /// - "INVALID" - The revision being used is not supported in any released version. #[serde(rename="revisionStatus")] - pub revision_status: String, + pub revision_status: Option<String>, /// The version of the API this client revision should use when calling API methods. #[serde(rename="apiVersion")] - pub api_version: String, + pub api_version: Option<String>, } impl ResponseResult for RevisionCheckResponse {} @@ -3042,7 +3042,7 @@ impl ResponseResult for RevisionCheckResponse {} pub struct AchievementUpdateRequest { /// The achievement this update is being applied to. #[serde(rename="achievementId")] - pub achievement_id: String, + pub achievement_id: Option<String>, /// The type of update being applied. /// Possible values are: /// - "REVEAL" - Achievement is revealed. @@ -3050,15 +3050,15 @@ pub struct AchievementUpdateRequest { /// - "INCREMENT" - Achievement is incremented. /// - "SET_STEPS_AT_LEAST" - Achievement progress is set to at least the passed value. #[serde(rename="updateType")] - pub update_type: String, + pub update_type: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementUpdateRequest. - pub kind: String, + pub kind: Option<String>, /// The payload if an update of type SET_STEPS_AT_LEAST was requested for the achievement. #[serde(rename="setStepsAtLeastPayload")] - pub set_steps_at_least_payload: GamesAchievementSetStepsAtLeast, + pub set_steps_at_least_payload: Option<GamesAchievementSetStepsAtLeast>, /// The payload if an update of type INCREMENT was requested for the achievement. #[serde(rename="incrementPayload")] - pub increment_payload: GamesAchievementIncrement, + pub increment_payload: Option<GamesAchievementIncrement>, } impl Part for AchievementUpdateRequest {} @@ -3077,11 +3077,11 @@ impl Part for AchievementUpdateRequest {} pub struct LeaderboardListResponse { /// Token corresponding to the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The leaderboards. - pub items: Vec<Leaderboard>, + pub items: Option<Vec<Leaderboard>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboardListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for LeaderboardListResponse {} @@ -3094,9 +3094,9 @@ impl ResponseResult for LeaderboardListResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct GamesAchievementSetStepsAtLeast { /// Uniquely identifies the type of this resource. Value is always the fixed string games#GamesAchievementSetStepsAtLeast. - pub kind: String, + pub kind: Option<String>, /// The minimum number of steps for the achievement to be set to. - pub steps: i32, + pub steps: Option<i32>, } impl Part for GamesAchievementSetStepsAtLeast {} @@ -4819,16 +4819,20 @@ impl<'a, C, A> AchievementListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5084,16 +5088,20 @@ impl<'a, C, A> AchievementIncrementCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5333,16 +5341,20 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5492,7 +5504,7 @@ impl<'a, C, A> AchievementSetStepsAtLeastCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AchievementUpdateMultipleRequest = Default::default(); +/// let mut req = AchievementUpdateMultipleRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5558,16 +5570,20 @@ impl<'a, C, A> AchievementUpdateMultipleCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5791,16 +5807,20 @@ impl<'a, C, A> AchievementRevealCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6021,16 +6041,20 @@ impl<'a, C, A> AchievementUnlockCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6256,16 +6280,20 @@ impl<'a, C, A> LeaderboardGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6482,16 +6510,20 @@ impl<'a, C, A> LeaderboardListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6740,16 +6772,20 @@ impl<'a, C, A> MetagameListCategoriesByPlayerCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6975,16 +7011,20 @@ impl<'a, C, A> MetagameGetMetagameConfigCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7210,16 +7250,20 @@ impl<'a, C, A> PlayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7466,16 +7510,20 @@ impl<'a, C, A> PlayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7708,16 +7756,20 @@ impl<'a, C, A> QuestAcceptCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7960,16 +8012,20 @@ impl<'a, C, A> QuestListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8216,16 +8272,20 @@ impl<'a, C, A> SnapshotGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8468,16 +8528,20 @@ impl<'a, C, A> SnapshotListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8718,16 +8782,20 @@ impl<'a, C, A> TurnBasedMatcheDismisCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -8937,16 +9005,20 @@ impl<'a, C, A> TurnBasedMatcheSyncCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9197,16 +9269,20 @@ impl<'a, C, A> TurnBasedMatcheDeclineCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -9444,16 +9520,20 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9607,7 +9687,7 @@ impl<'a, C, A> TurnBasedMatcheGetCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TurnBasedMatchCreateRequest = Default::default(); +/// let mut req = TurnBasedMatchCreateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9678,16 +9758,20 @@ impl<'a, C, A> TurnBasedMatcheCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9923,16 +10007,20 @@ impl<'a, C, A> TurnBasedMatcheJoinCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -10172,16 +10260,20 @@ impl<'a, C, A> TurnBasedMatcheLeaveTurnCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -10425,16 +10517,20 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -10564,7 +10660,7 @@ impl<'a, C, A> TurnBasedMatcheCancelCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TurnBasedMatchResults = Default::default(); +/// let mut req = TurnBasedMatchResults::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10661,16 +10757,20 @@ impl<'a, C, A> TurnBasedMatcheFinishCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10916,16 +11016,20 @@ impl<'a, C, A> TurnBasedMatcheLeaveCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -11152,16 +11256,20 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11326,7 +11434,7 @@ impl<'a, C, A> TurnBasedMatcheListCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TurnBasedMatchTurn = Default::default(); +/// let mut req = TurnBasedMatchTurn::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11423,16 +11531,20 @@ impl<'a, C, A> TurnBasedMatcheTakeTurnCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11683,16 +11795,20 @@ impl<'a, C, A> TurnBasedMatcheRematchCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -11937,16 +12053,20 @@ impl<'a, C, A> ApplicationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12154,16 +12274,20 @@ impl<'a, C, A> ApplicationPlayedCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -12369,16 +12493,20 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12525,7 +12653,7 @@ impl<'a, C, A> RoomGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RoomLeaveRequest = Default::default(); +/// let mut req = RoomLeaveRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12622,16 +12750,20 @@ impl<'a, C, A> RoomLeaveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12861,16 +12993,20 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13021,7 +13157,7 @@ impl<'a, C, A> RoomListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RoomP2PStatuses = Default::default(); +/// let mut req = RoomP2PStatuses::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13118,16 +13254,20 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13287,7 +13427,7 @@ impl<'a, C, A> RoomReportStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RoomCreateRequest = Default::default(); +/// let mut req = RoomCreateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13358,16 +13498,20 @@ impl<'a, C, A> RoomCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13603,16 +13747,20 @@ impl<'a, C, A> RoomDeclineCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -13839,16 +13987,20 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -13978,7 +14130,7 @@ impl<'a, C, A> RoomDismisCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RoomJoinRequest = Default::default(); +/// let mut req = RoomJoinRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14075,16 +14227,20 @@ impl<'a, C, A> RoomJoinCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14337,16 +14493,20 @@ impl<'a, C, A> ScoreSubmitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -14610,16 +14770,20 @@ impl<'a, C, A> ScoreListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14906,16 +15070,20 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15103,7 +15271,7 @@ impl<'a, C, A> ScoreGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlayerScoreSubmissionList = Default::default(); +/// let mut req = PlayerScoreSubmissionList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15174,16 +15342,20 @@ impl<'a, C, A> ScoreSubmitMultipleCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15443,16 +15615,20 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15647,7 +15823,7 @@ impl<'a, C, A> ScoreListWindowCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PushTokenId = Default::default(); +/// let mut req = PushTokenId::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15712,16 +15888,20 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15854,7 +16034,7 @@ impl<'a, C, A> PushtokenRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PushToken = Default::default(); +/// let mut req = PushToken::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15919,16 +16099,20 @@ impl<'a, C, A> PushtokenUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16118,16 +16302,20 @@ impl<'a, C, A> RevisionCheckCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16342,16 +16530,20 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16502,7 +16694,7 @@ impl<'a, C, A> EventListDefinitionCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EventRecordRequest = Default::default(); +/// let mut req = EventRecordRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16573,16 +16765,20 @@ impl<'a, C, A> EventRecordCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16802,16 +16998,20 @@ impl<'a, C, A> EventListByPlayerCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17046,16 +17246,20 @@ impl<'a, C, A> QuestMilestoneClaimCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -17275,16 +17479,20 @@ impl<'a, C, A> AchievementDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/gamesconfiguration1_configuration-cli/Cargo.toml b/gen/gamesconfiguration1_configuration-cli/Cargo.toml index aec7654161..a3a7df111d 100644 --- a/gen/gamesconfiguration1_configuration-cli/Cargo.toml +++ b/gen/gamesconfiguration1_configuration-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-gamesconfiguration1_configuration-cli" -version = "0.0.1+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/games/services" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/gamesconfiguration1_configuration-cli/mkdocs.yml b/gen/gamesconfiguration1_configuration-cli/mkdocs.yml index c11c8648da..d3d7652522 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+20150325 +site_name: Games Configuration v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/cmn.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/gamesconfiguration1_configuration-cli/src/main.rs b/gen/gamesconfiguration1_configuration-cli/src/main.rs index c3bdf6253f..046971a6ee 100644 --- a/gen/gamesconfiguration1_configuration-cli/src/main.rs +++ b/gen/gamesconfiguration1_configuration-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -44,6 +45,12 @@ Configuration: 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. "); mod cmn; @@ -67,7 +74,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievement_configurations().delete(&self.opt.arg_achievement_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -98,7 +105,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -109,7 +115,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievement_configurations().get(&self.opt.arg_achievement_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -141,8 +147,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -151,10 +156,10 @@ impl Engine { fn _achievement_configurations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AchievementConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -174,24 +179,53 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_draft_description_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().description.is_none() { + request.draft.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_draft_init(request: &mut api::AchievementConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); } } + fn request_draft_name_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_description_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().description.is_none() { + request.published.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::AchievementConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); @@ -210,51 +244,51 @@ impl Engine { }, "draft.kind" => { request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.description.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.point-value" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer")); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.kind" => { request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.description.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.point-value" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer")); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "id" => { request_published_init(&mut request); @@ -277,8 +311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -289,7 +322,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievement_configurations().list(&self.opt.arg_application_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -327,8 +360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -337,10 +369,10 @@ impl Engine { fn _achievement_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AchievementConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -360,24 +392,53 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_draft_description_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().description.is_none() { + request.draft.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_draft_init(request: &mut api::AchievementConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); } } + fn request_draft_name_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_description_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().description.is_none() { + request.published.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::AchievementConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); @@ -396,51 +457,51 @@ impl Engine { }, "draft.kind" => { request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.description.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.point-value" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer")); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.kind" => { request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.description.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.point-value" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer")); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "id" => { request_published_init(&mut request); @@ -463,8 +524,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -473,10 +533,10 @@ impl Engine { fn _achievement_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AchievementConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -496,24 +556,53 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_draft_description_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().description.is_none() { + request.draft.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_draft_init(request: &mut api::AchievementConfiguration) { if request.draft.is_none() { request.draft = Some(Default::default()); } } + fn request_draft_name_init(request: &mut api::AchievementConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_description_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().description.is_none() { + request.published.as_mut().unwrap().description = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::AchievementConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::AchievementConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "achievement-type" => { request.achievement_type = Some(value.unwrap_or("").to_string()); @@ -532,51 +621,51 @@ impl Engine { }, "draft.kind" => { request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.description.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.point-value" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.point-value", "integer")); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_description_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.kind" => { request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.description.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().description.kind = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().description.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.point-value" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().point_value = arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().point_value = Some(arg_from_str(value.unwrap_or("-0"), err, "published.point-value", "integer")); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_description_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "id" => { request_published_init(&mut request); @@ -599,8 +688,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -611,7 +699,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.image_configurations().upload(&self.opt.arg_resource_id, &self.opt.arg_image_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -653,8 +741,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -665,7 +752,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.leaderboard_configurations().delete(&self.opt.arg_leaderboard_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -696,7 +783,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -707,7 +793,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.leaderboard_configurations().get(&self.opt.arg_leaderboard_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -739,8 +825,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -749,10 +834,10 @@ impl Engine { fn _leaderboard_configurations_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LeaderboardConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -772,9 +857,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -784,12 +870,138 @@ impl Engine { } } + fn request_draft_name_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_draft_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().score_format.is_none() { + request.draft.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::LeaderboardConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().score_format.is_none() { + request.published.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -807,108 +1019,108 @@ impl Engine { request.score_max = Some(value.unwrap_or("").to_string()); }, "published.score-format.currency-code" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.many.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_many_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.two.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_two_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.one.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_one_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.few.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_few_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.zero.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_zero_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.other.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_other_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.number-format-type" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "published.score-format.num-decimal-places" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer"); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer")); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "draft.score-format.currency-code" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.many.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_many_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.two.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_two_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.one.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_one_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.few.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_few_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.zero.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_zero_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.other.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_other_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.number-format-type" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "draft.score-format.num-decimal-places" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer"); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer")); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "id" => { request_draft_init(&mut request); @@ -931,8 +1143,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -943,7 +1154,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.leaderboard_configurations().list(&self.opt.arg_application_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -981,8 +1192,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -991,10 +1201,10 @@ impl Engine { fn _leaderboard_configurations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LeaderboardConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1014,9 +1224,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1026,12 +1237,138 @@ impl Engine { } } + fn request_draft_name_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_draft_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().score_format.is_none() { + request.draft.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::LeaderboardConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().score_format.is_none() { + request.published.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1049,108 +1386,108 @@ impl Engine { request.score_max = Some(value.unwrap_or("").to_string()); }, "published.score-format.currency-code" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.many.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_many_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.two.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_two_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.one.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_one_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.few.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_few_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.zero.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_zero_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.other.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_other_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.number-format-type" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "published.score-format.num-decimal-places" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer"); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer")); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "draft.score-format.currency-code" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.many.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_many_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.two.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_two_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.one.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_one_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.few.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_few_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.zero.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_zero_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.other.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_other_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.number-format-type" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "draft.score-format.num-decimal-places" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer"); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer")); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "id" => { request_draft_init(&mut request); @@ -1173,8 +1510,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1183,10 +1519,10 @@ impl Engine { fn _leaderboard_configurations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LeaderboardConfiguration = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1206,9 +1542,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1218,12 +1555,138 @@ impl Engine { } } + fn request_draft_name_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().name.is_none() { + request.draft.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_draft_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_draft_init(request); + if request.draft.as_mut().unwrap().score_format.is_none() { + request.draft.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_draft_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_draft_score_format_suffix_init(request); + if request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + fn request_published_init(request: &mut api::LeaderboardConfiguration) { if request.published.is_none() { request.published = Some(Default::default()); } } + fn request_published_name_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().name.is_none() { + request.published.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_published_score_format_init(request: &mut api::LeaderboardConfiguration) { + request_published_init(request); + if request.published.as_mut().unwrap().score_format.is_none() { + request.published.as_mut().unwrap().score_format = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_few_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_many_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_one_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_other_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_two_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two = Some(Default::default()); + } + } + + fn request_published_score_format_suffix_zero_init(request: &mut api::LeaderboardConfiguration) { + request_published_score_format_suffix_init(request); + if request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.is_none() { + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1241,108 +1704,108 @@ impl Engine { request.score_max = Some(value.unwrap_or("").to_string()); }, "published.score-format.currency-code" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.many.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_many_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.two.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_two_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.one.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_one_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.few.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_few_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.zero.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_zero_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.suffix.other.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_published_score_format_suffix_other_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.score-format.number-format-type" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "published.score-format.num-decimal-places" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer"); + request_published_score_format_suffix_init(&mut request); + request.published.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "published.score-format.num-decimal-places", "integer")); }, "published.icon-url" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "published.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_published_score_format_init(&mut request); + request.published.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.name.kind" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "published.sort-rank" => { - request_published_init(&mut request); - request.published.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer"); + request_published_name_init(&mut request); + request.published.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "published.sort-rank", "integer")); }, "draft.score-format.currency-code" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.currency_code = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.many.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.many.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_many_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().many.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.two.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.two.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_two_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().two.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.one.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.one.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_one_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().one.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.few.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.few.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_few_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().few.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.zero.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.zero.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_zero_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().zero.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.suffix.other.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.suffix.other.kind = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_other_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().suffix.as_mut().unwrap().other.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.score-format.number-format-type" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.number_format_type = value.unwrap_or("").to_string(); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().number_format_type = Some(value.unwrap_or("").to_string()); }, "draft.score-format.num-decimal-places" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().score_format.num_decimal_places = arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer"); + request_draft_score_format_suffix_init(&mut request); + request.draft.as_mut().unwrap().score_format.as_mut().unwrap().num_decimal_places = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.score-format.num-decimal-places", "integer")); }, "draft.icon-url" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().icon_url = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().icon_url = Some(value.unwrap_or("").to_string()); }, "draft.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_draft_score_format_init(&mut request); + request.draft.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.name.kind" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().name.kind = value.unwrap_or("").to_string(); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().name.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "draft.sort-rank" => { - request_draft_init(&mut request); - request.draft.as_mut().unwrap().sort_rank = arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer"); + request_draft_name_init(&mut request); + request.draft.as_mut().unwrap().sort_rank = Some(arg_from_str(value.unwrap_or("-0"), err, "draft.sort-rank", "integer")); }, "id" => { request_draft_init(&mut request); @@ -1365,8 +1828,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1394,13 +1856,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_image_configurations { + } + else if self.opt.cmd_image_configurations { if self.opt.cmd_upload { call_result = self._image_configurations_upload(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_leaderboard_configurations { + } + else if self.opt.cmd_leaderboard_configurations { if self.opt.cmd_delete { call_result = self._leaderboard_configurations_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -1436,21 +1900,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "gamesconfiguration1-configuration-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "gamesconfiguration1-configuration-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "gamesconfiguration1-configuration", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "gamesconfiguration1-configuration", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::GamesConfiguration::new(hyper::Client::new(), auth), + hub: api::GamesConfiguration::new(client, auth), }; match engine._doit(true) { @@ -1470,12 +1950,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 a1b2b4f290..8cef486989 100644 --- a/gen/gamesconfiguration1_configuration/Cargo.toml +++ b/gen/gamesconfiguration1_configuration/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-gamesconfiguration1_configuration" -version = "0.1.5+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/games/services" diff --git a/gen/gamesconfiguration1_configuration/README.md b/gen/gamesconfiguration1_configuration/README.md index 178411a627..9eb6dc3ed9 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+20150325*, where *20150325* 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.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*. Everything else about the *Games Configuration* *v1_configuration* API can be found at the [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesconfiguration1_configuration/src/cmn.rs b/gen/gamesconfiguration1_configuration/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/gamesconfiguration1_configuration/src/cmn.rs +++ b/gen/gamesconfiguration1_configuration/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/gamesconfiguration1_configuration/src/lib.rs b/gen/gamesconfiguration1_configuration/src/lib.rs index f63da63f54..62c9bdde57 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+20150325*, where *20150325* 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.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*. //! //! Everything else about the *Games Configuration* *v1_configuration* API can be found at the //! [official documentation site](https://developers.google.com/games/services). @@ -222,7 +222,7 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { - /// View and manage your Google Play Android Developer account + /// View and manage your Google Play Developer account Androidpublisher, } @@ -351,19 +351,19 @@ impl<'a, C, A> GamesConfiguration<C, A> pub struct GamesNumberFormatConfiguration { /// The curreny code string. Only used for CURRENCY format type. #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option<String>, /// The formatting for the number. /// Possible values are: /// - "NUMERIC" - Numbers are formatted to have no digits or a fixed number of digits after the decimal point according to locale. An optional custom unit can be added. /// - "TIME_DURATION" - Numbers are formatted to hours, minutes and seconds. /// - "CURRENCY" - Numbers are formatted to currency according to locale. #[serde(rename="numberFormatType")] - pub number_format_type: String, + pub number_format_type: Option<String>, /// The number of decimal places for number. Only used for NUMERIC format type. #[serde(rename="numDecimalPlaces")] - pub num_decimal_places: i32, + pub num_decimal_places: Option<i32>, /// An optional suffix for the NUMERIC format type. These strings follow the same plural rules as all Android string resources. - pub suffix: GamesNumberAffixConfiguration, + pub suffix: Option<GamesNumberAffixConfiguration>, } impl Part for GamesNumberFormatConfiguration {} @@ -376,9 +376,9 @@ impl Part for GamesNumberFormatConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocalizedStringBundle { /// Uniquely identifies the type of this resource. Value is always the fixed string gamesConfiguration#localizedStringBundle. - pub kind: String, + pub kind: Option<String>, /// The locale strings. - pub translations: Vec<LocalizedString>, + pub translations: Option<Vec<LocalizedString>>, } impl Part for LocalizedStringBundle {} @@ -391,11 +391,11 @@ impl Part for LocalizedStringBundle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocalizedString { /// The locale string. - pub locale: String, + pub locale: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesConfiguration#localizedString. - pub kind: String, + pub kind: Option<String>, /// The string value. - pub value: String, + pub value: Option<String>, } impl Part for LocalizedString {} @@ -414,11 +414,11 @@ impl Part for LocalizedString {} pub struct AchievementConfigurationListResponse { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The achievement configurations. - pub items: Vec<AchievementConfiguration>, + pub items: Option<Vec<AchievementConfiguration>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#achievementConfigurationListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AchievementConfigurationListResponse {} @@ -436,15 +436,15 @@ impl ResponseResult for AchievementConfigurationListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImageConfiguration { /// The url for this image. - pub url: String, + pub url: Option<String>, /// The resource ID of resource which the image belongs to. #[serde(rename="resourceId")] - pub resource_id: String, + pub resource_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesConfiguration#imageConfiguration. - pub kind: String, + pub kind: Option<String>, /// The image type for the image. #[serde(rename="imageType")] - pub image_type: String, + pub image_type: Option<String>, } impl Resource for ImageConfiguration {} @@ -458,17 +458,17 @@ impl ResponseResult for ImageConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GamesNumberAffixConfiguration { /// When the language requires special treatment of "small" numbers (as with 2, 3, and 4 in Czech; or numbers ending 2, 3, or 4 but not 12, 13, or 14 in Polish). - pub few: LocalizedStringBundle, + pub few: Option<LocalizedStringBundle>, /// When the language requires special treatment of the number 0 (as in Arabic). - pub zero: LocalizedStringBundle, + pub zero: Option<LocalizedStringBundle>, /// When the language does not require special treatment of the given quantity (as with all numbers in Chinese, or 42 in English). - pub other: LocalizedStringBundle, + pub other: Option<LocalizedStringBundle>, /// When the language requires special treatment of "large" numbers (as with numbers ending 11-99 in Maltese). - pub many: LocalizedStringBundle, + pub many: Option<LocalizedStringBundle>, /// When the language requires special treatment of numbers like two (as with 2 in Welsh, or 102 in Slovenian). - pub two: LocalizedStringBundle, + pub two: Option<LocalizedStringBundle>, /// When the language requires special treatment of numbers like one (as with the number 1 in English and most other languages; in Russian, any number ending in 1 but not ending in 11 is in this class). - pub one: LocalizedStringBundle, + pub one: Option<LocalizedStringBundle>, } impl Part for GamesNumberAffixConfiguration {} @@ -581,11 +581,11 @@ impl ResponseResult for LeaderboardConfiguration {} pub struct LeaderboardConfigurationListResponse { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The leaderboard configurations. - pub items: Vec<LeaderboardConfiguration>, + pub items: Option<Vec<LeaderboardConfiguration>>, /// Uniquely identifies the type of this resource. Value is always the fixed string games#leaderboardConfigurationListResponse. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for LeaderboardConfigurationListResponse {} @@ -599,19 +599,19 @@ impl ResponseResult for LeaderboardConfigurationListResponse {} pub struct AchievementConfigurationDetail { /// The icon url of this achievement. Writes to this field are ignored. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesConfiguration#achievementConfigurationDetail. - pub kind: String, + pub kind: Option<String>, /// Localized strings for the achievement name. - pub name: LocalizedStringBundle, + pub name: Option<LocalizedStringBundle>, /// Point value for the achievement. #[serde(rename="pointValue")] - pub point_value: i32, + pub point_value: Option<i32>, /// The sort rank of this achievement. Writes to this field are ignored. #[serde(rename="sortRank")] - pub sort_rank: i32, + pub sort_rank: Option<i32>, /// Localized strings for the achievement description. - pub description: LocalizedStringBundle, + pub description: Option<LocalizedStringBundle>, } impl Part for AchievementConfigurationDetail {} @@ -625,17 +625,17 @@ impl Part for AchievementConfigurationDetail {} pub struct LeaderboardConfigurationDetail { /// The score formatting for the leaderboard. #[serde(rename="scoreFormat")] - pub score_format: GamesNumberFormatConfiguration, + pub score_format: Option<GamesNumberFormatConfiguration>, /// The icon url of this leaderboard. Writes to this field are ignored. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesConfiguration#leaderboardConfigurationDetail. - pub kind: String, + pub kind: Option<String>, /// Localized strings for the leaderboard name. - pub name: LocalizedStringBundle, + pub name: Option<LocalizedStringBundle>, /// The sort rank of this leaderboard. Writes to this field are ignored. #[serde(rename="sortRank")] - pub sort_rank: i32, + pub sort_rank: Option<i32>, } impl Part for LeaderboardConfigurationDetail {} @@ -1136,16 +1136,20 @@ impl<'a, C, A> ImageConfigurationUploadCall<'a, C, A> where C: BorrowMut<hyper:: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -1484,16 +1488,20 @@ impl<'a, C, A> AchievementConfigurationListCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1647,7 +1655,7 @@ impl<'a, C, A> AchievementConfigurationListCall<'a, C, A> where C: BorrowMut<hyp /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AchievementConfiguration = Default::default(); +/// let mut req = AchievementConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1739,16 +1747,20 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1901,7 +1913,7 @@ impl<'a, C, A> AchievementConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AchievementConfiguration = Default::default(); +/// let mut req = AchievementConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1993,16 +2005,20 @@ impl<'a, C, A> AchievementConfigurationInsertCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2236,16 +2252,20 @@ impl<'a, C, A> AchievementConfigurationGetCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2385,7 +2405,7 @@ impl<'a, C, A> AchievementConfigurationGetCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AchievementConfiguration = Default::default(); +/// let mut req = AchievementConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2477,16 +2497,20 @@ impl<'a, C, A> AchievementConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2719,16 +2743,20 @@ impl<'a, C, A> AchievementConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2858,7 +2886,7 @@ impl<'a, C, A> AchievementConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LeaderboardConfiguration = Default::default(); +/// let mut req = LeaderboardConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2950,16 +2978,20 @@ impl<'a, C, A> LeaderboardConfigurationInsertCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3193,16 +3225,20 @@ impl<'a, C, A> LeaderboardConfigurationGetCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3342,7 +3378,7 @@ impl<'a, C, A> LeaderboardConfigurationGetCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LeaderboardConfiguration = Default::default(); +/// let mut req = LeaderboardConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3434,16 +3470,20 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3596,7 +3636,7 @@ impl<'a, C, A> LeaderboardConfigurationPatchCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LeaderboardConfiguration = Default::default(); +/// let mut req = LeaderboardConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3688,16 +3728,20 @@ impl<'a, C, A> LeaderboardConfigurationUpdateCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3941,16 +3985,20 @@ impl<'a, C, A> LeaderboardConfigurationListCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4184,16 +4232,20 @@ impl<'a, C, A> LeaderboardConfigurationDeleteCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) diff --git a/gen/gamesmanagement1_management-cli/Cargo.toml b/gen/gamesmanagement1_management-cli/Cargo.toml index ee100b41fa..2d86314870 100644 --- a/gen/gamesmanagement1_management-cli/Cargo.toml +++ b/gen/gamesmanagement1_management-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-gamesmanagement1_management-cli" -version = "0.0.1+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/games/services" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/gamesmanagement1_management-cli/mkdocs.yml b/gen/gamesmanagement1_management-cli/mkdocs.yml index 8110d34f67..ea7fc7dde3 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+20150325 +site_name: Games Management v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/gamesmanagement1_management-cli/src/cmn.rs +++ b/gen/gamesmanagement1_management-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/gamesmanagement1_management-cli/src/main.rs b/gen/gamesmanagement1_management-cli/src/main.rs index 2d0da1400f..f59c4cd86b 100644 --- a/gen/gamesmanagement1_management-cli/src/main.rs +++ b/gen/gamesmanagement1_management-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -58,6 +59,12 @@ Configuration: 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. "); mod cmn; @@ -81,7 +88,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievements().reset(&self.opt.arg_achievement_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -113,8 +120,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -125,7 +131,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievements().reset_all(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -157,8 +163,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -169,7 +174,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievements().reset_all_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -200,7 +205,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -211,7 +215,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.achievements().reset_for_all_players(&self.opt.arg_achievement_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -242,7 +246,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -251,10 +254,10 @@ 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::default(); + let mut request = api::AchievementResetMultipleForAllRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -274,18 +277,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.achievement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.achievement_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -306,7 +310,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -317,7 +320,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.applications().list_hidden(&self.opt.arg_application_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -355,8 +358,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -367,7 +369,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.events().reset(&self.opt.arg_event_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -398,7 +400,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -409,7 +410,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.events().reset_all(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -440,7 +441,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -451,7 +451,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.events().reset_all_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -482,7 +482,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -493,7 +492,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.events().reset_for_all_players(&self.opt.arg_event_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -524,7 +523,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -533,10 +531,10 @@ 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::default(); + let mut request = api::EventsResetMultipleForAllRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -556,18 +554,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.event_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.event_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -588,7 +587,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -599,7 +597,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.players().hide(&self.opt.arg_application_id, &self.opt.arg_player_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -630,7 +628,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -641,7 +638,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.players().unhide(&self.opt.arg_application_id, &self.opt.arg_player_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -672,7 +669,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -683,7 +679,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.quests().reset(&self.opt.arg_quest_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -714,7 +710,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -725,7 +720,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.quests().reset_all(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -756,7 +751,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -767,7 +761,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.quests().reset_all_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -798,7 +792,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -809,7 +802,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.quests().reset_for_all_players(&self.opt.arg_quest_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -840,7 +833,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -849,10 +841,10 @@ 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::default(); + let mut request = api::QuestsResetMultipleForAllRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -872,18 +864,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.quest_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.quest_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -904,7 +897,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -915,7 +907,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rooms().reset(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -946,7 +938,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -957,7 +948,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rooms().reset_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -988,7 +979,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -999,7 +989,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.scores().reset(&self.opt.arg_leaderboard_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1031,8 +1021,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1043,7 +1032,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.scores().reset_all(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1075,8 +1064,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1087,7 +1075,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.scores().reset_all_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1118,7 +1106,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1129,7 +1116,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.scores().reset_for_all_players(&self.opt.arg_leaderboard_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1160,7 +1147,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1169,10 +1155,10 @@ 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::default(); + let mut request = api::ScoresResetMultipleForAllRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1192,18 +1178,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.leaderboard_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.leaderboard_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -1224,7 +1211,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1235,7 +1221,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.turn_based_matches().reset(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1266,7 +1252,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1277,7 +1262,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.turn_based_matches().reset_for_all_players(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1308,7 +1293,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1334,13 +1318,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_applications { + } + else if self.opt.cmd_applications { if self.opt.cmd_list_hidden { call_result = self._applications_list_hidden(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_events { + } + else if self.opt.cmd_events { if self.opt.cmd_reset { call_result = self._events_reset(dry_run, &mut err); } else if self.opt.cmd_reset_all { @@ -1354,7 +1340,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_players { + } + else if self.opt.cmd_players { if self.opt.cmd_hide { call_result = self._players_hide(dry_run, &mut err); } else if self.opt.cmd_unhide { @@ -1362,7 +1349,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_quests { + } + else if self.opt.cmd_quests { if self.opt.cmd_reset { call_result = self._quests_reset(dry_run, &mut err); } else if self.opt.cmd_reset_all { @@ -1376,7 +1364,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_rooms { + } + else if self.opt.cmd_rooms { if self.opt.cmd_reset { call_result = self._rooms_reset(dry_run, &mut err); } else if self.opt.cmd_reset_for_all_players { @@ -1384,7 +1373,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_scores { + } + else if self.opt.cmd_scores { if self.opt.cmd_reset { call_result = self._scores_reset(dry_run, &mut err); } else if self.opt.cmd_reset_all { @@ -1398,7 +1388,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_turn_based_matches { + } + else if self.opt.cmd_turn_based_matches { if self.opt.cmd_reset { call_result = self._turn_based_matches_reset(dry_run, &mut err); } else if self.opt.cmd_reset_for_all_players { @@ -1426,21 +1417,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "gamesmanagement1-management-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "gamesmanagement1-management-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "gamesmanagement1-management", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "gamesmanagement1-management", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::GamesManagement::new(hyper::Client::new(), auth), + hub: api::GamesManagement::new(client, auth), }; match engine._doit(true) { @@ -1460,12 +1467,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 a69f182a8d..3df26734e5 100644 --- a/gen/gamesmanagement1_management/Cargo.toml +++ b/gen/gamesmanagement1_management/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-gamesmanagement1_management" -version = "0.1.5+20150325" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/games/services" diff --git a/gen/gamesmanagement1_management/README.md b/gen/gamesmanagement1_management/README.md index 061a42e210..bc13cd6329 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+20150325*, where *20150325* 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.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*. Everything else about the *Games Management* *v1_management* API can be found at the [official documentation site](https://developers.google.com/games/services). diff --git a/gen/gamesmanagement1_management/src/cmn.rs b/gen/gamesmanagement1_management/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/gamesmanagement1_management/src/cmn.rs +++ b/gen/gamesmanagement1_management/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/gamesmanagement1_management/src/lib.rs b/gen/gamesmanagement1_management/src/lib.rs index 7a221cd31a..5d3956538e 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+20150325*, where *20150325* 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.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*. //! //! Everything else about the *Games Management* *v1_management* API can be found at the //! [official documentation site](https://developers.google.com/games/services). @@ -373,19 +373,19 @@ impl<'a, C, A> GamesManagement<C, A> pub struct AchievementResetResponse { /// The ID of an achievement for which player state has been updated. #[serde(rename="definitionId")] - pub definition_id: String, + pub definition_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#achievementResetResponse. - pub kind: String, + pub kind: Option<String>, /// Flag to indicate if the requested update actually occurred. #[serde(rename="updateOccurred")] - pub update_occurred: bool, + pub update_occurred: Option<bool>, /// The current state of the achievement. This is the same as the initial state of the achievement. /// Possible values are: /// - "HIDDEN"- Achievement is hidden. /// - "REVEALED" - Achievement is revealed. /// - "UNLOCKED" - Achievement is unlocked. #[serde(rename="currentState")] - pub current_state: String, + pub current_state: Option<String>, } impl ResponseResult for AchievementResetResponse {} @@ -399,10 +399,10 @@ impl ResponseResult for AchievementResetResponse {} pub struct PlayerName { /// The given name of this player. In some places, this is known as the first name. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The family name of this player. In some places, this is known as the last name. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, } impl NestedType for PlayerName {} @@ -417,16 +417,16 @@ impl Part for PlayerName {} pub struct GamesPlayerExperienceInfoResource { /// The current number of experience points for the player. #[serde(rename="currentExperiencePoints")] - pub current_experience_points: String, + pub current_experience_points: Option<String>, /// The next level of the player. If the current level is the maximum level, this should be same as the current level. #[serde(rename="nextLevel")] - pub next_level: GamesPlayerLevelResource, + pub next_level: Option<GamesPlayerLevelResource>, /// The timestamp when the player was leveled up, in millis since Unix epoch UTC. #[serde(rename="lastLevelUpTimestampMillis")] - pub last_level_up_timestamp_millis: String, + pub last_level_up_timestamp_millis: Option<String>, /// The current level of the player. #[serde(rename="currentLevel")] - pub current_level: GamesPlayerLevelResource, + pub current_level: Option<GamesPlayerLevelResource>, } impl Part for GamesPlayerExperienceInfoResource {} @@ -480,10 +480,10 @@ impl RequestValue for AchievementResetMultipleForAllRequest {} pub struct GamesPlayedResource { /// True if the player was auto-matched with the currently authenticated user. #[serde(rename="autoMatched")] - pub auto_matched: bool, + pub auto_matched: Option<bool>, /// The last time the player played the game in milliseconds since the epoch in UTC. #[serde(rename="timeMillis")] - pub time_millis: String, + pub time_millis: Option<String>, } impl Part for GamesPlayedResource {} @@ -501,9 +501,9 @@ impl Part for GamesPlayedResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlayerScoreResetAllResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#playerScoreResetResponse. - pub kind: String, + pub kind: Option<String>, /// The leaderboard reset results. - pub results: Vec<PlayerScoreResetResponse>, + pub results: Option<Vec<PlayerScoreResetResponse>>, } impl ResponseResult for PlayerScoreResetAllResponse {} @@ -575,12 +575,12 @@ impl RequestValue for QuestsResetMultipleForAllRequest {} pub struct GamesPlayerLevelResource { /// The maximum experience points for this level. #[serde(rename="maxExperiencePoints")] - pub max_experience_points: String, + pub max_experience_points: Option<String>, /// The minimum experience points for this level. #[serde(rename="minExperiencePoints")] - pub min_experience_points: String, + pub min_experience_points: Option<String>, /// The level for the user. - pub level: i32, + pub level: Option<i32>, } impl Part for GamesPlayerLevelResource {} @@ -599,11 +599,11 @@ impl Part for GamesPlayerLevelResource {} pub struct HiddenPlayerList { /// The pagination token for the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The players. - pub items: Vec<HiddenPlayer>, + pub items: Option<Vec<HiddenPlayer>>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#hiddenPlayerList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for HiddenPlayerList {} @@ -621,9 +621,9 @@ impl ResponseResult for HiddenPlayerList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AchievementResetAllResponse { /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#achievementResetAllResponse. - pub kind: String, + pub kind: Option<String>, /// The achievement reset results. - pub results: Vec<AchievementResetResponse>, + pub results: Option<Vec<AchievementResetResponse>>, } impl ResponseResult for AchievementResetAllResponse {} @@ -662,16 +662,16 @@ impl RequestValue for ScoresResetMultipleForAllRequest {} pub struct PlayerScoreResetResponse { /// The ID of an leaderboard for which player state has been updated. #[serde(rename="definitionId")] - pub definition_id: String, + pub definition_id: Option<String>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#playerScoreResetResponse. - pub kind: String, + pub kind: Option<String>, /// The time spans of the updated score. /// Possible values are: /// - "ALL_TIME" - The score is an all-time score. /// - "WEEKLY" - The score is a weekly score. /// - "DAILY" - The score is a daily score. #[serde(rename="resetScoreTimeSpans")] - pub reset_score_time_spans: Vec<String>, + pub reset_score_time_spans: Option<Vec<String>>, } impl ResponseResult for PlayerScoreResetResponse {} @@ -684,12 +684,12 @@ impl ResponseResult for PlayerScoreResetResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HiddenPlayer { /// The player information. - pub player: Player, + pub player: Option<Player>, /// Uniquely identifies the type of this resource. Value is always the fixed string gamesManagement#hiddenPlayer. - pub kind: String, + pub kind: Option<String>, /// The time this player was hidden. #[serde(rename="hiddenTimeMillis")] - pub hidden_time_millis: String, + pub hidden_time_millis: Option<String>, } impl Part for HiddenPlayer {} @@ -1520,16 +1520,20 @@ impl<'a, C, A> AchievementResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1729,16 +1733,20 @@ impl<'a, C, A> AchievementResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1949,16 +1957,20 @@ impl<'a, C, A> AchievementResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2098,7 +2110,7 @@ impl<'a, C, A> AchievementResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AchievementResetMultipleForAllRequest = Default::default(); +/// let mut req = AchievementResetMultipleForAllRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2163,16 +2175,20 @@ impl<'a, C, A> AchievementResetMultipleForAllPlayerCall<'a, C, A> where C: Borro loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2360,16 +2376,20 @@ impl<'a, C, A> AchievementResetAllCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2581,16 +2601,20 @@ impl<'a, C, A> PlayerHideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2812,16 +2836,20 @@ impl<'a, C, A> PlayerUnhideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2961,7 +2989,7 @@ impl<'a, C, A> PlayerUnhideCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ScoresResetMultipleForAllRequest = Default::default(); +/// let mut req = ScoresResetMultipleForAllRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3026,16 +3054,20 @@ impl<'a, C, A> ScoreResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3222,16 +3254,20 @@ impl<'a, C, A> ScoreResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3406,16 +3442,20 @@ impl<'a, C, A> ScoreResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3625,16 +3665,20 @@ impl<'a, C, A> ScoreResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3845,16 +3889,20 @@ impl<'a, C, A> ScoreResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4048,16 +4096,20 @@ impl<'a, C, A> TurnBasedMatcheResetCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4231,16 +4283,20 @@ impl<'a, C, A> TurnBasedMatcheResetForAllPlayerCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4451,16 +4507,20 @@ impl<'a, C, A> ApplicationListHiddenCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4668,16 +4728,20 @@ impl<'a, C, A> RoomResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4851,16 +4915,20 @@ impl<'a, C, A> RoomResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5034,16 +5102,20 @@ impl<'a, C, A> QuestResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5163,7 +5235,7 @@ impl<'a, C, A> QuestResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: QuestsResetMultipleForAllRequest = Default::default(); +/// let mut req = QuestsResetMultipleForAllRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5228,16 +5300,20 @@ impl<'a, C, A> QuestResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5424,16 +5500,20 @@ impl<'a, C, A> QuestResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5633,16 +5713,20 @@ impl<'a, C, A> QuestResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5852,16 +5936,20 @@ impl<'a, C, A> QuestResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6045,16 +6133,20 @@ impl<'a, C, A> EventResetAllForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6254,16 +6346,20 @@ impl<'a, C, A> EventResetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6447,16 +6543,20 @@ impl<'a, C, A> EventResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6576,7 +6676,7 @@ impl<'a, C, A> EventResetAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: EventsResetMultipleForAllRequest = Default::default(); +/// let mut req = EventsResetMultipleForAllRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6641,16 +6741,20 @@ impl<'a, C, A> EventResetMultipleForAllPlayerCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6863,16 +6967,20 @@ impl<'a, C, A> EventResetForAllPlayerCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) diff --git a/gen/gan1_beta1-cli/Cargo.toml b/gen/gan1_beta1-cli/Cargo.toml index 57bcf59a6c..d9df66150a 100644 --- a/gen/gan1_beta1-cli/Cargo.toml +++ b/gen/gan1_beta1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-gan1_beta1-cli" version = "0.0.1+20130205" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/affiliate-network/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/gan1_beta1-cli/src/cmn.rs b/gen/gan1_beta1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/gan1_beta1-cli/src/cmn.rs +++ b/gen/gan1_beta1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/gan1_beta1-cli/src/main.rs b/gen/gan1_beta1-cli/src/main.rs index 21b0ba6bb9..021b7aa783 100644 --- a/gen/gan1_beta1-cli/src/main.rs +++ b/gen/gan1_beta1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -37,6 +38,12 @@ Configuration: 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. "); mod cmn; @@ -60,7 +67,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertisers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "advertiser-id" => { call = call.advertiser_id(value.unwrap_or("")); @@ -95,8 +102,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -107,7 +113,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.advertisers().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "relationship-status" => { call = call.relationship_status(value.unwrap_or("")); @@ -160,8 +166,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -172,7 +177,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.cc_offers().list(&self.opt.arg_publisher); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -210,8 +215,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -222,7 +226,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.events().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); @@ -302,8 +306,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -314,7 +317,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.links().get(&self.opt.arg_role, &self.opt.arg_role_id, &self.opt.arg_link_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -346,8 +349,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -356,10 +358,10 @@ impl Engine { fn _links_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Link = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -379,9 +381,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -397,12 +400,40 @@ impl Engine { } } + fn request_special_offers_free_shipping_min_init(request: &mut api::Link) { + request_special_offers_init(request); + if request.special_offers.as_mut().unwrap().free_shipping_min.is_none() { + request.special_offers.as_mut().unwrap().free_shipping_min = Some(Default::default()); + } + } + fn request_special_offers_init(request: &mut api::Link) { if request.special_offers.is_none() { request.special_offers = Some(Default::default()); } } + fn request_special_offers_percent_off_min_init(request: &mut api::Link) { + request_special_offers_init(request); + if request.special_offers.as_mut().unwrap().percent_off_min.is_none() { + request.special_offers.as_mut().unwrap().percent_off_min = Some(Default::default()); + } + } + + fn request_special_offers_price_cut_init(request: &mut api::Link) { + request_special_offers_init(request); + if request.special_offers.as_mut().unwrap().price_cut.is_none() { + request.special_offers.as_mut().unwrap().price_cut = Some(Default::default()); + } + } + + fn request_special_offers_price_cut_min_init(request: &mut api::Link) { + request_special_offers_init(request); + if request.special_offers.as_mut().unwrap().price_cut_min.is_none() { + request.special_offers.as_mut().unwrap().price_cut_min = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "link-type" => { request.link_type = Some(value.unwrap_or("").to_string()); @@ -423,60 +454,63 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "special-offers.price-cut.amount" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().price_cut.amount = arg_from_str(value.unwrap_or("0.0"), err, "special-offers.price-cut.amount", "number"); + request_special_offers_price_cut_init(&mut request); + request.special_offers.as_mut().unwrap().price_cut.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "special-offers.price-cut.amount", "number")); }, "special-offers.price-cut.currency-code" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().price_cut.currency_code = value.unwrap_or("").to_string(); + request_special_offers_price_cut_init(&mut request); + request.special_offers.as_mut().unwrap().price_cut.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "special-offers.price-cut-min.amount" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().price_cut_min.amount = arg_from_str(value.unwrap_or("0.0"), err, "special-offers.price-cut-min.amount", "number"); + request_special_offers_price_cut_min_init(&mut request); + request.special_offers.as_mut().unwrap().price_cut_min.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "special-offers.price-cut-min.amount", "number")); }, "special-offers.price-cut-min.currency-code" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().price_cut_min.currency_code = value.unwrap_or("").to_string(); + request_special_offers_price_cut_min_init(&mut request); + request.special_offers.as_mut().unwrap().price_cut_min.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "special-offers.free-shipping" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().free_shipping = arg_from_str(value.unwrap_or("false"), err, "special-offers.free-shipping", "boolean"); + request_special_offers_price_cut_min_init(&mut request); + request.special_offers.as_mut().unwrap().free_shipping = Some(arg_from_str(value.unwrap_or("false"), err, "special-offers.free-shipping", "boolean")); }, "special-offers.promotion-codes" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().promotion_codes.push(value.unwrap_or("").to_string()); + request_special_offers_price_cut_min_init(&mut request); + if request.special_offers.as_mut().unwrap().promotion_codes.is_none() { + request.special_offers.as_mut().unwrap().promotion_codes = Some(Default::default()); + } + request.special_offers.as_mut().unwrap().promotion_codes.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "special-offers.percent-off" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().percent_off = arg_from_str(value.unwrap_or("0.0"), err, "special-offers.percent-off", "number"); + request_special_offers_price_cut_min_init(&mut request); + request.special_offers.as_mut().unwrap().percent_off = Some(arg_from_str(value.unwrap_or("0.0"), err, "special-offers.percent-off", "number")); }, "special-offers.percent-off-min.amount" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().percent_off_min.amount = arg_from_str(value.unwrap_or("0.0"), err, "special-offers.percent-off-min.amount", "number"); + request_special_offers_percent_off_min_init(&mut request); + request.special_offers.as_mut().unwrap().percent_off_min.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "special-offers.percent-off-min.amount", "number")); }, "special-offers.percent-off-min.currency-code" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().percent_off_min.currency_code = value.unwrap_or("").to_string(); + request_special_offers_percent_off_min_init(&mut request); + request.special_offers.as_mut().unwrap().percent_off_min.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "special-offers.free-gift" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().free_gift = arg_from_str(value.unwrap_or("false"), err, "special-offers.free-gift", "boolean"); + request_special_offers_percent_off_min_init(&mut request); + request.special_offers.as_mut().unwrap().free_gift = Some(arg_from_str(value.unwrap_or("false"), err, "special-offers.free-gift", "boolean")); }, "special-offers.free-shipping-min.amount" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().free_shipping_min.amount = arg_from_str(value.unwrap_or("0.0"), err, "special-offers.free-shipping-min.amount", "number"); + request_special_offers_free_shipping_min_init(&mut request); + request.special_offers.as_mut().unwrap().free_shipping_min.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "special-offers.free-shipping-min.amount", "number")); }, "special-offers.free-shipping-min.currency-code" => { - request_special_offers_init(&mut request); - request.special_offers.as_mut().unwrap().free_shipping_min.currency_code = value.unwrap_or("").to_string(); + request_special_offers_free_shipping_min_init(&mut request); + request.special_offers.as_mut().unwrap().free_shipping_min.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "epc-seven-day-average.amount" => { request_epc_seven_day_average_init(&mut request); - request.epc_seven_day_average.as_mut().unwrap().amount = arg_from_str(value.unwrap_or("0.0"), err, "epc-seven-day-average.amount", "number"); + request.epc_seven_day_average.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "epc-seven-day-average.amount", "number")); }, "epc-seven-day-average.currency-code" => { request_epc_seven_day_average_init(&mut request); - request.epc_seven_day_average.as_mut().unwrap().currency_code = value.unwrap_or("").to_string(); + request.epc_seven_day_average.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "create-date" => { request_epc_seven_day_average_init(&mut request); @@ -516,11 +550,11 @@ impl Engine { }, "epc-ninety-day-average.amount" => { request_epc_ninety_day_average_init(&mut request); - request.epc_ninety_day_average.as_mut().unwrap().amount = arg_from_str(value.unwrap_or("0.0"), err, "epc-ninety-day-average.amount", "number"); + request.epc_ninety_day_average.as_mut().unwrap().amount = Some(arg_from_str(value.unwrap_or("0.0"), err, "epc-ninety-day-average.amount", "number")); }, "epc-ninety-day-average.currency-code" => { request_epc_ninety_day_average_init(&mut request); - request.epc_ninety_day_average.as_mut().unwrap().currency_code = value.unwrap_or("").to_string(); + request.epc_ninety_day_average.as_mut().unwrap().currency_code = Some(value.unwrap_or("").to_string()); }, "availability" => { request_epc_ninety_day_average_init(&mut request); @@ -551,8 +585,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -563,7 +596,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.links().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-date-min" => { call = call.start_date_min(value.unwrap_or("")); @@ -634,8 +667,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -646,7 +678,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.publishers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "publisher-id" => { call = call.publisher_id(value.unwrap_or("")); @@ -681,8 +713,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -693,7 +724,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.publishers().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "relationship-status" => { call = call.relationship_status(value.unwrap_or("")); @@ -746,8 +777,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -758,7 +788,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().get(&self.opt.arg_role, &self.opt.arg_role_id, &self.opt.arg_report_type); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "status" => { call = call.status(value.unwrap_or("")); @@ -823,8 +853,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -844,19 +873,22 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_cc_offers { + } + else if self.opt.cmd_cc_offers { if self.opt.cmd_list { call_result = self._cc_offers_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_events { + } + else if self.opt.cmd_events { if self.opt.cmd_list { call_result = self._events_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_links { + } + else if self.opt.cmd_links { if self.opt.cmd_get { call_result = self._links_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -866,7 +898,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_publishers { + } + else if self.opt.cmd_publishers { if self.opt.cmd_get { call_result = self._publishers_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -874,7 +907,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_reports { if self.opt.cmd_get { call_result = self._reports_get(dry_run, &mut err); } else { @@ -900,21 +934,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "gan1-beta1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "gan1-beta1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "gan1-beta1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "gan1-beta1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Gan::new(hyper::Client::new(), auth), + hub: api::Gan::new(client, auth), }; match engine._doit(true) { @@ -934,12 +984,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 213cd2c761..c4f057ea67 100644 --- a/gen/gan1_beta1/Cargo.toml +++ b/gen/gan1_beta1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-gan1_beta1" version = "0.1.5+20130205" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/affiliate-network/" diff --git a/gen/gan1_beta1/src/cmn.rs b/gen/gan1_beta1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/gan1_beta1/src/cmn.rs +++ b/gen/gan1_beta1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/gan1_beta1/src/lib.rs b/gen/gan1_beta1/src/lib.rs index fb2b62c02b..289e9cf9db 100644 --- a/gen/gan1_beta1/src/lib.rs +++ b/gen/gan1_beta1/src/lib.rs @@ -364,61 +364,61 @@ impl<'a, C, A> Gan<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Advertiser { /// The status of the requesting publisher's relationship this advertiser. - pub status: String, + pub status: Option<String>, /// Allows advertisers to submit product listings to Google Product Search. #[serde(rename="productFeedsEnabled")] - pub product_feeds_enabled: bool, + pub product_feeds_enabled: Option<bool>, /// Phone that this advertiser would like publishers to contact them with. #[serde(rename="contactPhone")] - pub contact_phone: String, + pub contact_phone: Option<String>, /// Description of the website the advertiser advertises from. - pub description: String, + pub description: Option<String>, /// List of merchant center ids for this advertiser #[serde(rename="merchantCenterIds")] - pub merchant_center_ids: Vec<String>, + pub merchant_center_ids: Option<Vec<String>>, /// The longest possible length of a commission (how long the cookies on the customer's browser last before they expire). #[serde(rename="commissionDuration")] - pub commission_duration: i32, + pub commission_duration: Option<i32>, /// Email that this advertiser would like publishers to contact them with. #[serde(rename="contactEmail")] - pub contact_email: String, + pub contact_email: Option<String>, /// Date that this advertiser was approved as a Google Affiliate Network advertiser. #[serde(rename="joinDate")] - pub join_date: String, + pub join_date: Option<String>, /// The ID of this advertiser. - pub id: String, + pub id: Option<String>, /// Category that this advertiser belongs to. A valid list of categories can be found here: http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en&answer=107581 - pub category: String, + pub category: Option<String>, /// The default link id for this advertiser. #[serde(rename="defaultLinkId")] - pub default_link_id: String, + pub default_link_id: Option<String>, /// The kind for an advertiser. - pub kind: String, + pub kind: Option<String>, /// URL of the website this advertiser advertises from. #[serde(rename="siteUrl")] - pub site_url: String, + pub site_url: Option<String>, /// The name of this advertiser. - pub name: String, + pub name: Option<String>, /// A rank based on commissions paid to publishers over the past 90 days. A number between 1 and 4 where 4 means the top quartile (most money paid) and 1 means the bottom quartile (least money paid). #[serde(rename="payoutRank")] - pub payout_rank: String, + pub payout_rank: Option<String>, /// The sum of fees paid to publishers divided by the total number of clicks over the past seven days. This value should be multiplied by 100 at the time of display. #[serde(rename="epcSevenDayAverage")] - pub epc_seven_day_average: Money, + pub epc_seven_day_average: Option<Money>, /// The sum of fees paid to publishers divided by the total number of clicks over the past three months. This value should be multiplied by 100 at the time of display. #[serde(rename="epcNinetyDayAverage")] - pub epc_ninety_day_average: Money, + pub epc_ninety_day_average: Option<Money>, /// True if the advertiser allows publisher created links, otherwise false. #[serde(rename="allowPublisherCreatedLinks")] - pub allow_publisher_created_links: bool, + pub allow_publisher_created_links: Option<bool>, /// The requested advertiser. - pub item: Option<Box<Advertiser>>, + pub item: Option<Option<Box<Advertiser>>>, /// URL to the logo this advertiser uses on the Google Affiliate Network. #[serde(rename="logoUrl")] - pub logo_url: String, + pub logo_url: Option<String>, /// List of redirect URLs for this advertiser #[serde(rename="redirectDomains")] - pub redirect_domains: Vec<String>, + pub redirect_domains: Option<Vec<String>>, } impl Resource for Advertiser {} @@ -432,21 +432,21 @@ impl ResponseResult for Advertiser {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CcOfferRewards { /// The kind of purchases covered by this rule. - pub category: String, + pub category: Option<String>, /// The number of units rewarded per purchase dollar. - pub amount: f64, + pub amount: Option<f64>, /// The minimum purchase amount in the given category before this rule applies. #[serde(rename="minRewardTier")] - pub min_reward_tier: f64, + pub min_reward_tier: Option<f64>, /// Other limits, for example, if this rule only applies during an introductory period. #[serde(rename="additionalDetails")] - pub additional_details: String, + pub additional_details: Option<String>, /// The maximum purchase amount in the given category for this rule to apply. #[serde(rename="maxRewardTier")] - pub max_reward_tier: f64, + pub max_reward_tier: Option<f64>, /// How long rewards granted by this rule last. #[serde(rename="expirationMonths")] - pub expiration_months: f64, + pub expiration_months: Option<f64>, } impl NestedType for CcOfferRewards {} @@ -466,11 +466,11 @@ impl Part for CcOfferRewards {} pub struct Links { /// The next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The links. - pub items: Vec<Link>, + pub items: Option<Vec<Link>>, /// The kind for a page of links. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Links {} @@ -489,11 +489,11 @@ impl ResponseResult for Links {} pub struct Publishers { /// The 'pageToken' to pass to the next request to get the next page, if there are more to retrieve. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The entity list. - pub items: Vec<Publisher>, + pub items: Option<Vec<Publisher>>, /// The kind for a page of entities. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Publishers {} @@ -506,10 +506,10 @@ impl ResponseResult for Publishers {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Money { /// The amount of money. - pub amount: f64, + pub amount: Option<f64>, /// The 3-letter code of the currency in question. #[serde(rename="currencyCode")] - pub currency_code: String, + pub currency_code: Option<String>, } impl Part for Money {} @@ -528,31 +528,31 @@ impl Part for Money {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Publisher { /// The status of the requesting advertiser's relationship with this publisher. - pub status: String, + pub status: Option<String>, /// The kind for a publisher. - pub kind: String, + pub kind: Option<String>, /// The name of this publisher. - pub name: String, + pub name: Option<String>, /// Classification that this publisher belongs to. See this link for all publisher classifications: http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en&answer=107625&ctx=cb&src=cb&cbid=-k5fihzthfaik&cbrank=4 - pub classification: String, + pub classification: Option<String>, /// The sum of fees paid to this publisher divided by the total number of clicks over the past seven days. Values are multiplied by 100 for display purposes. #[serde(rename="epcSevenDayAverage")] - pub epc_seven_day_average: Money, + pub epc_seven_day_average: Option<Money>, /// Websites that this publisher uses to advertise. - pub sites: Vec<String>, + pub sites: Option<Vec<String>>, /// The sum of fees paid to this publisher divided by the total number of clicks over the past three months. Values are multiplied by 100 for display purposes. #[serde(rename="epcNinetyDayAverage")] - pub epc_ninety_day_average: Money, + pub epc_ninety_day_average: Option<Money>, /// The requested publisher. - pub item: Option<Box<Publisher>>, + pub item: Option<Option<Box<Publisher>>>, /// A rank based on commissions paid to this publisher over the past 90 days. A number between 1 and 4 where 4 means the top quartile (most money paid) and 1 means the bottom quartile (least money paid). #[serde(rename="payoutRank")] - pub payout_rank: String, + pub payout_rank: Option<String>, /// Date that this publisher was approved as a Google Affiliate Network publisher. #[serde(rename="joinDate")] - pub join_date: String, + pub join_date: Option<String>, /// The ID of this publisher. - pub id: String, + pub id: Option<String>, } impl Resource for Publisher {} @@ -567,28 +567,28 @@ impl ResponseResult for Publisher {} pub struct LinkSpecialOffers { /// Price cut on the purchase #[serde(rename="priceCut")] - pub price_cut: Money, + pub price_cut: Option<Money>, /// Minimum purchase amount for price cut promotion #[serde(rename="priceCutMin")] - pub price_cut_min: Money, + pub price_cut_min: Option<Money>, /// Whether there is free shipping #[serde(rename="freeShipping")] - pub free_shipping: bool, + pub free_shipping: Option<bool>, /// List of promotion code associated with the link #[serde(rename="promotionCodes")] - pub promotion_codes: Vec<String>, + pub promotion_codes: Option<Vec<String>>, /// Percent off on the purchase #[serde(rename="percentOff")] - pub percent_off: f64, + pub percent_off: Option<f64>, /// Minimum purchase amount for percent off promotion #[serde(rename="percentOffMin")] - pub percent_off_min: Money, + pub percent_off_min: Option<Money>, /// Whether there is a free gift #[serde(rename="freeGift")] - pub free_gift: bool, + pub free_gift: Option<bool>, /// Minimum purchase amount for free shipping promotion #[serde(rename="freeShippingMin")] - pub free_shipping_min: Money, + pub free_shipping_min: Option<Money>, } impl NestedType for LinkSpecialOffers {} @@ -608,11 +608,11 @@ impl Part for LinkSpecialOffers {} pub struct Events { /// The 'pageToken' to pass to the next request to get the next page, if there are more to retrieve. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The event list. - pub items: Vec<Event>, + pub items: Option<Vec<Event>>, /// The kind for a page of events. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Events {} @@ -625,9 +625,9 @@ impl ResponseResult for Events {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CcOfferBonusRewards { /// How many units of reward will be granted. - pub amount: f64, + pub amount: Option<f64>, /// The circumstances under which this rule applies, for example, booking a flight via Orbitz. - pub details: String, + pub details: Option<String>, } impl NestedType for CcOfferBonusRewards {} @@ -641,16 +641,16 @@ impl Part for CcOfferBonusRewards {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CcOfferDefaultFees { /// The type of charge, for example Purchases. - pub category: String, + pub category: Option<String>, /// The highest rate the issuer may charge for defaulting on debt in this category. Expressed as an absolute number, not as a percentage. #[serde(rename="maxRate")] - pub max_rate: f64, + pub max_rate: Option<f64>, /// The lowest rate the issuer may charge for defaulting on debt in this category. Expressed as an absolute number, not as a percentage. #[serde(rename="minRate")] - pub min_rate: f64, + pub min_rate: Option<f64>, /// Fixed or variable. #[serde(rename="rateType")] - pub rate_type: String, + pub rate_type: Option<String>, } impl NestedType for CcOfferDefaultFees {} @@ -669,9 +669,9 @@ impl Part for CcOfferDefaultFees {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CcOffers { /// The credit card offers. - pub items: Vec<CcOffer>, + pub items: Option<Vec<CcOffer>>, /// The kind for a page of credit card offers. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for CcOffers {} @@ -761,28 +761,28 @@ impl ResponseResult for Link {} pub struct EventProducts { /// Fee that the advertiser paid to the Google Affiliate Network for this product. #[serde(rename="networkFee")] - pub network_fee: Money, + pub network_fee: Option<Money>, /// Sku of this product. - pub sku: String, + pub sku: Option<String>, /// Name of the category this product belongs to. #[serde(rename="categoryName")] - pub category_name: String, + pub category_name: Option<String>, /// Sku name of this product. #[serde(rename="skuName")] - pub sku_name: String, + pub sku_name: Option<String>, /// Fee that the advertiser paid to the publisehr for this product. #[serde(rename="publisherFee")] - pub publisher_fee: Money, + pub publisher_fee: Option<Money>, /// Amount earned by the publisher on this product. - pub earnings: Money, + pub earnings: Option<Money>, /// Price per unit of this product. #[serde(rename="unitPrice")] - pub unit_price: Money, + pub unit_price: Option<Money>, /// Id of the category this product belongs to. #[serde(rename="categoryId")] - pub category_id: String, + pub category_id: Option<String>, /// Quantity of this product bought/exchanged. - pub quantity: String, + pub quantity: Option<String>, } impl NestedType for EventProducts {} @@ -801,22 +801,22 @@ impl Part for EventProducts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// The totals rows for the report - pub totals_rows: Vec<Vec<String>>, + pub totals_rows: Option<Vec<Vec<String>>>, /// The kind for a report. - pub kind: String, + pub kind: Option<String>, /// The rows of data for the report - pub rows: Vec<Vec<String>>, + pub rows: Option<Vec<Vec<String>>>, /// The end of the date range for this report, exclusive. - pub end_date: String, + pub end_date: Option<String>, /// The number of matching rows before paging is applied. - pub matching_row_count: String, + pub matching_row_count: Option<String>, /// The column names for the report - pub column_names: Vec<String>, + pub column_names: Option<Vec<String>>, /// The report type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The start of the date range for this report, inclusive. - pub start_date: String, + pub start_date: Option<String>, } impl Resource for Report {} @@ -836,11 +836,11 @@ impl ResponseResult for Report {} pub struct Advertisers { /// The 'pageToken' to pass to the next request to get the next page, if there are more to retrieve. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The advertiser list. - pub items: Vec<Advertiser>, + pub items: Option<Vec<Advertiser>>, /// The kind for a page of advertisers. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Advertisers {} @@ -2180,7 +2180,7 @@ impl<'a, C, A> PublisherGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Link = Default::default(); +/// let mut req = Link::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. diff --git a/gen/genomics1_beta2-cli/Cargo.toml b/gen/genomics1_beta2-cli/Cargo.toml index dd8bed2560..e9adc21004 100644 --- a/gen/genomics1_beta2-cli/Cargo.toml +++ b/gen/genomics1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-genomics1_beta2-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/genomics/v1beta2/reference" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/genomics1_beta2-cli/mkdocs.yml b/gen/genomics1_beta2-cli/mkdocs.yml index 8dc274dc09..691911deef 100644 --- a/gen/genomics1_beta2-cli/mkdocs.yml +++ b/gen/genomics1_beta2-cli/mkdocs.yml @@ -55,7 +55,7 @@ pages: - ['references_search.md', 'References', 'Search'] - ['referencesets_get.md', 'Referencesets', 'Get'] - ['referencesets_search.md', 'Referencesets', 'Search'] -- ['streaming-variant-store_streamvariants.md', 'Streaming Variant Store', 'Streamvariants'] +- ['streaming-readstore_streamreads.md', 'Streaming Readstore', 'Streamreads'] - ['variants_create.md', 'Variants', 'Create'] - ['variants_delete.md', 'Variants', 'Delete'] - ['variants_get.md', 'Variants', 'Get'] diff --git a/gen/genomics1_beta2-cli/src/cmn.rs b/gen/genomics1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/genomics1_beta2-cli/src/cmn.rs +++ b/gen/genomics1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/genomics1_beta2-cli/src/main.rs b/gen/genomics1_beta2-cli/src/main.rs index cad5239303..efdb35f1ff 100644 --- a/gen/genomics1_beta2-cli/src/main.rs +++ b/gen/genomics1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -64,7 +65,7 @@ Usage: 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-variant-store streamvariants -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>] @@ -91,6 +92,12 @@ Configuration: 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. "); mod cmn; @@ -112,10 +119,10 @@ struct Engine { impl Engine { fn _annotation_sets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AnnotationSet = Default::default(); + let mut request = api::AnnotationSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -135,9 +142,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -177,8 +185,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -189,7 +196,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.annotation_sets().delete(&self.opt.arg_annotation_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -220,7 +227,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -231,7 +237,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.annotation_sets().get(&self.opt.arg_annotation_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -263,8 +269,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -273,10 +278,10 @@ impl Engine { fn _annotation_sets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AnnotationSet = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -296,9 +301,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -338,8 +344,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -348,10 +353,10 @@ impl Engine { fn _annotation_sets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchAnnotationSetsRequest = Default::default(); + let mut request = api::SearchAnnotationSetsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -371,9 +376,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -386,9 +392,9 @@ impl Engine { }, "dataset-ids" => { if request.dataset_ids.is_none() { - request.dataset_ids = Some(Default::default()); + request.dataset_ids = Some(Default::default()); } - request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "page-token" => { request.page_token = Some(value.unwrap_or("").to_string()); @@ -398,9 +404,9 @@ impl Engine { }, "types" => { if request.types.is_none() { - request.types = Some(Default::default()); + request.types = Some(Default::default()); } - request.types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -419,8 +425,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -429,10 +434,10 @@ impl Engine { fn _annotation_sets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AnnotationSet = Default::default(); + let mut request = api::AnnotationSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -452,9 +457,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -494,8 +500,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -504,10 +509,10 @@ impl Engine { fn _annotations_batch_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::BatchCreateAnnotationsRequest = Default::default(); + let mut request = api::BatchCreateAnnotationsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -527,9 +532,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -551,8 +557,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -561,10 +566,10 @@ impl Engine { fn _annotations_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Annotation = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -584,9 +589,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -596,6 +602,13 @@ impl Engine { } } + fn request_transcript_coding_sequence_init(request: &mut api::Annotation) { + request_transcript_init(request); + if request.transcript.as_mut().unwrap().coding_sequence.is_none() { + request.transcript.as_mut().unwrap().coding_sequence = Some(Default::default()); + } + } + fn request_transcript_init(request: &mut api::Annotation) { if request.transcript.is_none() { request.transcript = Some(Default::default()); @@ -613,40 +626,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.start" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.start = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.end" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.end = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "transcript.gene-id" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "variant.effect" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().effect = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().effect = Some(value.unwrap_or("").to_string()); }, "variant.transcript-ids" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().transcript_ids.push(value.unwrap_or("").to_string()); + if request.variant.as_mut().unwrap().transcript_ids.is_none() { + request.variant.as_mut().unwrap().transcript_ids = Some(Default::default()); + } + request.variant.as_mut().unwrap().transcript_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "variant.alternate-bases" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().alternate_bases = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().alternate_bases = Some(value.unwrap_or("").to_string()); }, "variant.clinical-significance" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().clinical_significance = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().clinical_significance = Some(value.unwrap_or("").to_string()); }, "variant.type" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "variant.gene-id" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "annotation-set-id" => { request_variant_init(&mut request); @@ -654,23 +670,23 @@ impl Engine { }, "position.start" => { request_position_init(&mut request); - request.position.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "position.reference-id" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_id = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_id = Some(value.unwrap_or("").to_string()); }, "position.end" => { request_position_init(&mut request); - request.position.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "position.reverse-strand" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reverse_strand = arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean"); + request.position.as_mut().unwrap().reverse_strand = Some(arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean")); }, "position.reference-name" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_name = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_name = Some(value.unwrap_or("").to_string()); }, "type" => { request_position_init(&mut request); @@ -697,8 +713,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -709,7 +724,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.annotations().delete(&self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -740,7 +755,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -751,7 +765,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.annotations().get(&self.opt.arg_annotation_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -783,8 +797,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -793,10 +806,10 @@ impl Engine { fn _annotations_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Annotation = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -816,9 +829,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -828,6 +842,13 @@ impl Engine { } } + fn request_transcript_coding_sequence_init(request: &mut api::Annotation) { + request_transcript_init(request); + if request.transcript.as_mut().unwrap().coding_sequence.is_none() { + request.transcript.as_mut().unwrap().coding_sequence = Some(Default::default()); + } + } + fn request_transcript_init(request: &mut api::Annotation) { if request.transcript.is_none() { request.transcript = Some(Default::default()); @@ -845,40 +866,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.start" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.start = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.end" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.end = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "transcript.gene-id" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "variant.effect" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().effect = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().effect = Some(value.unwrap_or("").to_string()); }, "variant.transcript-ids" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().transcript_ids.push(value.unwrap_or("").to_string()); + if request.variant.as_mut().unwrap().transcript_ids.is_none() { + request.variant.as_mut().unwrap().transcript_ids = Some(Default::default()); + } + request.variant.as_mut().unwrap().transcript_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "variant.alternate-bases" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().alternate_bases = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().alternate_bases = Some(value.unwrap_or("").to_string()); }, "variant.clinical-significance" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().clinical_significance = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().clinical_significance = Some(value.unwrap_or("").to_string()); }, "variant.type" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "variant.gene-id" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "annotation-set-id" => { request_variant_init(&mut request); @@ -886,23 +910,23 @@ impl Engine { }, "position.start" => { request_position_init(&mut request); - request.position.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "position.reference-id" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_id = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_id = Some(value.unwrap_or("").to_string()); }, "position.end" => { request_position_init(&mut request); - request.position.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "position.reverse-strand" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reverse_strand = arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean"); + request.position.as_mut().unwrap().reverse_strand = Some(arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean")); }, "position.reference-name" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_name = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_name = Some(value.unwrap_or("").to_string()); }, "type" => { request_position_init(&mut request); @@ -929,8 +953,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -939,10 +962,10 @@ impl Engine { fn _annotations_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchAnnotationsRequest = Default::default(); + let mut request = api::SearchAnnotationsRequest::default(); let mut call = self.hub.annotations().search(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -962,9 +985,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -980,26 +1004,26 @@ impl Engine { }, "range.start" => { request_range_init(&mut request); - request.range.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.range.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "range.reference-id" => { request_range_init(&mut request); - request.range.as_mut().unwrap().reference_id = value.unwrap_or("").to_string(); + request.range.as_mut().unwrap().reference_id = Some(value.unwrap_or("").to_string()); }, "range.end" => { request_range_init(&mut request); - request.range.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.range.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "range.reference-name" => { request_range_init(&mut request); - request.range.as_mut().unwrap().reference_name = value.unwrap_or("").to_string(); + request.range.as_mut().unwrap().reference_name = Some(value.unwrap_or("").to_string()); }, "annotation-set-ids" => { request_range_init(&mut request); if request.annotation_set_ids.is_none() { - request.annotation_set_ids = Some(Default::default()); + request.annotation_set_ids = Some(Default::default()); } - request.annotation_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.annotation_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "page-size" => { request_range_init(&mut request); @@ -1022,8 +1046,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1032,10 +1055,10 @@ impl Engine { fn _annotations_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Annotation = Default::default(); + let mut request = api::Annotation::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1055,9 +1078,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1067,6 +1091,13 @@ impl Engine { } } + fn request_transcript_coding_sequence_init(request: &mut api::Annotation) { + request_transcript_init(request); + if request.transcript.as_mut().unwrap().coding_sequence.is_none() { + request.transcript.as_mut().unwrap().coding_sequence = Some(Default::default()); + } + } + fn request_transcript_init(request: &mut api::Annotation) { if request.transcript.is_none() { request.transcript = Some(Default::default()); @@ -1084,40 +1115,43 @@ impl Engine { request.name = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.start" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.start = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "transcript.coding-sequence.end" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().coding_sequence.end = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().coding_sequence.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "transcript.gene-id" => { - request_transcript_init(&mut request); - request.transcript.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request_transcript_coding_sequence_init(&mut request); + request.transcript.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "variant.effect" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().effect = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().effect = Some(value.unwrap_or("").to_string()); }, "variant.transcript-ids" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().transcript_ids.push(value.unwrap_or("").to_string()); + if request.variant.as_mut().unwrap().transcript_ids.is_none() { + request.variant.as_mut().unwrap().transcript_ids = Some(Default::default()); + } + request.variant.as_mut().unwrap().transcript_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "variant.alternate-bases" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().alternate_bases = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().alternate_bases = Some(value.unwrap_or("").to_string()); }, "variant.clinical-significance" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().clinical_significance = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().clinical_significance = Some(value.unwrap_or("").to_string()); }, "variant.type" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "variant.gene-id" => { request_variant_init(&mut request); - request.variant.as_mut().unwrap().gene_id = value.unwrap_or("").to_string(); + request.variant.as_mut().unwrap().gene_id = Some(value.unwrap_or("").to_string()); }, "annotation-set-id" => { request_variant_init(&mut request); @@ -1125,23 +1159,23 @@ impl Engine { }, "position.start" => { request_position_init(&mut request); - request.position.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "position.reference-id" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_id = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_id = Some(value.unwrap_or("").to_string()); }, "position.end" => { request_position_init(&mut request); - request.position.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "position.reverse-strand" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reverse_strand = arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean"); + request.position.as_mut().unwrap().reverse_strand = Some(arg_from_str(value.unwrap_or("false"), err, "position.reverse-strand", "boolean")); }, "position.reference-name" => { request_position_init(&mut request); - request.position.as_mut().unwrap().reference_name = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().reference_name = Some(value.unwrap_or("").to_string()); }, "type" => { request_position_init(&mut request); @@ -1168,8 +1202,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1178,10 +1211,10 @@ impl Engine { fn _callsets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CallSet = Default::default(); + let mut request = api::CallSet::default(); let mut call = self.hub.callsets().create(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1201,9 +1234,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1216,9 +1250,9 @@ impl Engine { }, "variant-set-ids" => { if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + request.variant_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -1243,8 +1277,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1255,7 +1288,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.callsets().delete(&self.opt.arg_call_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1286,7 +1319,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1297,7 +1329,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.callsets().get(&self.opt.arg_call_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1329,8 +1361,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1339,10 +1370,10 @@ impl Engine { fn _callsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CallSet = Default::default(); + let mut request = api::CallSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1362,9 +1393,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1377,9 +1409,9 @@ impl Engine { }, "variant-set-ids" => { if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + request.variant_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -1404,8 +1436,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1414,10 +1445,10 @@ impl Engine { fn _callsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchCallSetsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1437,9 +1468,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1449,9 +1481,9 @@ impl Engine { }, "variant-set-ids" => { if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + request.variant_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -1476,8 +1508,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1486,10 +1517,10 @@ impl Engine { fn _callsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CallSet = Default::default(); + let mut request = api::CallSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1509,9 +1540,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1524,9 +1556,9 @@ impl Engine { }, "variant-set-ids" => { if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + request.variant_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -1551,8 +1583,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1561,10 +1592,10 @@ impl Engine { fn _datasets_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Dataset = Default::default(); + let mut request = api::Dataset::default(); let mut call = self.hub.datasets().create(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1584,9 +1615,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1620,8 +1652,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1632,7 +1663,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.datasets().delete(&self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1663,7 +1694,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1674,7 +1704,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.datasets().get(&self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1706,8 +1736,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1718,7 +1747,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.datasets().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "project-number" => { call = call.project_number(value.unwrap_or("")); @@ -1759,8 +1788,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1769,10 +1797,10 @@ impl Engine { fn _datasets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Dataset = Default::default(); + let mut request = api::Dataset::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1792,9 +1820,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1828,8 +1857,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1840,7 +1868,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.datasets().undelete(&self.opt.arg_dataset_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1872,8 +1900,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1882,10 +1909,10 @@ impl Engine { fn _datasets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Dataset = Default::default(); + let mut request = api::Dataset::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1905,9 +1932,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1941,8 +1969,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1951,10 +1978,10 @@ impl Engine { fn _experimental_jobs_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ExperimentalCreateJobRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1974,18 +2001,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { "paired-source-uris" => { if request.paired_source_uris.is_none() { - request.paired_source_uris = Some(Default::default()); + request.paired_source_uris = Some(Default::default()); } - request.paired_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.paired_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "align" => { request.align = Some(arg_from_str(value.unwrap_or("false"), err, "align", "boolean")); @@ -1995,9 +2023,9 @@ impl Engine { }, "source-uris" => { if request.source_uris.is_none() { - request.source_uris = Some(Default::default()); + request.source_uris = Some(Default::default()); } - request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "gcs-output-path" => { request.gcs_output_path = Some(value.unwrap_or("").to_string()); @@ -2022,8 +2050,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2034,7 +2061,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.jobs().cancel(&self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2065,7 +2092,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2076,7 +2102,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.jobs().get(&self.opt.arg_job_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2108,8 +2134,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2118,10 +2143,10 @@ impl Engine { fn _jobs_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchJobsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2141,18 +2166,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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" => { if request.status.is_none() { - request.status = Some(Default::default()); + request.status = Some(Default::default()); } - request.status.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.status.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "created-after" => { request.created_after = Some(value.unwrap_or("").to_string()); @@ -2186,8 +2212,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2196,10 +2221,10 @@ impl Engine { fn _readgroupsets_align(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AlignReadGroupSetsRequest = Default::default(); + let mut request = api::AlignReadGroupSetsRequest::default(); let mut call = self.hub.readgroupsets().align(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2219,9 +2244,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2231,71 +2257,94 @@ impl Engine { } } + fn request_interleaved_fastq_source_metadata_init(request: &mut api::AlignReadGroupSetsRequest) { + request_interleaved_fastq_source_init(request); + if request.interleaved_fastq_source.as_mut().unwrap().metadata.is_none() { + request.interleaved_fastq_source.as_mut().unwrap().metadata = Some(Default::default()); + } + } + fn request_paired_fastq_source_init(request: &mut api::AlignReadGroupSetsRequest) { if request.paired_fastq_source.is_none() { request.paired_fastq_source = Some(Default::default()); } } + fn request_paired_fastq_source_metadata_init(request: &mut api::AlignReadGroupSetsRequest) { + request_paired_fastq_source_init(request); + if request.paired_fastq_source.as_mut().unwrap().metadata.is_none() { + request.paired_fastq_source.as_mut().unwrap().metadata = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "interleaved-fastq-source.source-uris" => { request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().source_uris.push(value.unwrap_or("").to_string()); + if request.interleaved_fastq_source.as_mut().unwrap().source_uris.is_none() { + request.interleaved_fastq_source.as_mut().unwrap().source_uris = Some(Default::default()); + } + request.interleaved_fastq_source.as_mut().unwrap().source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "interleaved-fastq-source.metadata.read-group-name" => { - request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().metadata.read_group_name = value.unwrap_or("").to_string(); + request_interleaved_fastq_source_metadata_init(&mut request); + request.interleaved_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().read_group_name = Some(value.unwrap_or("").to_string()); }, "interleaved-fastq-source.metadata.sample-name" => { - request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().metadata.sample_name = value.unwrap_or("").to_string(); + request_interleaved_fastq_source_metadata_init(&mut request); + request.interleaved_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().sample_name = Some(value.unwrap_or("").to_string()); }, "interleaved-fastq-source.metadata.library-name" => { - request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().metadata.library_name = value.unwrap_or("").to_string(); + request_interleaved_fastq_source_metadata_init(&mut request); + request.interleaved_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().library_name = Some(value.unwrap_or("").to_string()); }, "interleaved-fastq-source.metadata.platform-name" => { - request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().metadata.platform_name = value.unwrap_or("").to_string(); + request_interleaved_fastq_source_metadata_init(&mut request); + request.interleaved_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().platform_name = Some(value.unwrap_or("").to_string()); }, "interleaved-fastq-source.metadata.platform-unit" => { - request_interleaved_fastq_source_init(&mut request); - request.interleaved_fastq_source.as_mut().unwrap().metadata.platform_unit = value.unwrap_or("").to_string(); + request_interleaved_fastq_source_metadata_init(&mut request); + request.interleaved_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().platform_unit = Some(value.unwrap_or("").to_string()); }, "bam-source-uris" => { request_interleaved_fastq_source_init(&mut request); if request.bam_source_uris.is_none() { - request.bam_source_uris = Some(Default::default()); + request.bam_source_uris = Some(Default::default()); } - request.bam_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.bam_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "paired-fastq-source.second-source-uris" => { request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().second_source_uris.push(value.unwrap_or("").to_string()); + if request.paired_fastq_source.as_mut().unwrap().second_source_uris.is_none() { + request.paired_fastq_source.as_mut().unwrap().second_source_uris = Some(Default::default()); + } + request.paired_fastq_source.as_mut().unwrap().second_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "paired-fastq-source.metadata.read-group-name" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().metadata.read_group_name = value.unwrap_or("").to_string(); + request_paired_fastq_source_metadata_init(&mut request); + request.paired_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().read_group_name = Some(value.unwrap_or("").to_string()); }, "paired-fastq-source.metadata.sample-name" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().metadata.sample_name = value.unwrap_or("").to_string(); + request_paired_fastq_source_metadata_init(&mut request); + request.paired_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().sample_name = Some(value.unwrap_or("").to_string()); }, "paired-fastq-source.metadata.library-name" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().metadata.library_name = value.unwrap_or("").to_string(); + request_paired_fastq_source_metadata_init(&mut request); + request.paired_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().library_name = Some(value.unwrap_or("").to_string()); }, "paired-fastq-source.metadata.platform-name" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().metadata.platform_name = value.unwrap_or("").to_string(); + request_paired_fastq_source_metadata_init(&mut request); + request.paired_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().platform_name = Some(value.unwrap_or("").to_string()); }, "paired-fastq-source.metadata.platform-unit" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().metadata.platform_unit = value.unwrap_or("").to_string(); + request_paired_fastq_source_metadata_init(&mut request); + request.paired_fastq_source.as_mut().unwrap().metadata.as_mut().unwrap().platform_unit = Some(value.unwrap_or("").to_string()); }, "paired-fastq-source.first-source-uris" => { - request_paired_fastq_source_init(&mut request); - request.paired_fastq_source.as_mut().unwrap().first_source_uris.push(value.unwrap_or("").to_string()); + request_paired_fastq_source_metadata_init(&mut request); + if request.paired_fastq_source.as_mut().unwrap().first_source_uris.is_none() { + request.paired_fastq_source.as_mut().unwrap().first_source_uris = Some(Default::default()); + } + request.paired_fastq_source.as_mut().unwrap().first_source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "read-group-set-id" => { request_paired_fastq_source_init(&mut request); @@ -2322,8 +2371,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2332,10 +2380,10 @@ impl Engine { fn _readgroupsets_call(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::CallReadGroupSetsRequest = Default::default(); + let mut request = api::CallReadGroupSetsRequest::default(); let mut call = self.hub.readgroupsets().call(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2355,18 +2403,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "read-group-set-id" => { request.read_group_set_id = Some(value.unwrap_or("").to_string()); @@ -2391,8 +2440,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2403,7 +2451,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.readgroupsets().coveragebuckets_list(&self.opt.arg_read_group_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "target-bucket-width" => { call = call.target_bucket_width(value.unwrap_or("")); @@ -2453,8 +2501,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2465,7 +2512,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.readgroupsets().delete(&self.opt.arg_read_group_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2496,7 +2543,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2505,10 +2551,10 @@ impl Engine { fn _readgroupsets_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ExportReadGroupSetsRequest = Default::default(); + let mut request = api::ExportReadGroupSetsRequest::default(); let mut call = self.hub.readgroupsets().export(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2528,9 +2574,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2540,15 +2587,15 @@ impl Engine { }, "reference-names" => { if request.reference_names.is_none() { - request.reference_names = Some(Default::default()); + request.reference_names = Some(Default::default()); } - request.reference_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -2570,8 +2617,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2582,7 +2628,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.readgroupsets().get(&self.opt.arg_read_group_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2614,8 +2660,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2624,10 +2669,10 @@ impl Engine { fn _readgroupsets_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ImportReadGroupSetsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2647,9 +2692,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2659,9 +2705,9 @@ impl Engine { }, "source-uris" => { if request.source_uris.is_none() { - request.source_uris = Some(Default::default()); + request.source_uris = Some(Default::default()); } - request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "partition-strategy" => { request.partition_strategy = Some(value.unwrap_or("").to_string()); @@ -2686,8 +2732,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2696,10 +2741,10 @@ impl Engine { fn _readgroupsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ReadGroupSet = Default::default(); + let mut request = api::ReadGroupSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2719,9 +2764,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2758,8 +2804,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2768,10 +2813,10 @@ impl Engine { fn _readgroupsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchReadGroupSetsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2791,9 +2836,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2803,9 +2849,9 @@ impl Engine { }, "dataset-ids" => { if request.dataset_ids.is_none() { - request.dataset_ids = Some(Default::default()); + request.dataset_ids = Some(Default::default()); } - request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -2830,8 +2876,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2840,10 +2885,10 @@ impl Engine { fn _readgroupsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ReadGroupSet = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2863,9 +2908,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2902,8 +2948,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2912,10 +2957,10 @@ impl Engine { fn _reads_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchReadsRequest = Default::default(); + let mut request = api::SearchReadsRequest::default(); let mut call = self.hub.reads().search(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2935,24 +2980,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { "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 = Some(Default::default()); } - request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "read-group-ids" => { if request.read_group_ids.is_none() { - request.read_group_ids = Some(Default::default()); + request.read_group_ids = Some(Default::default()); } - request.read_group_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.read_group_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")); @@ -2986,8 +3032,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2998,7 +3043,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.references().bases_list(&self.opt.arg_reference_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start" => { call = call.start(value.unwrap_or("")); @@ -3042,8 +3087,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3054,7 +3098,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.references().get(&self.opt.arg_reference_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3086,8 +3130,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3096,10 +3139,10 @@ impl Engine { fn _references_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchReferencesRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3119,18 +3162,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { "md5checksums" => { if request.md5checksums.is_none() { - request.md5checksums = Some(Default::default()); + request.md5checksums = Some(Default::default()); } - request.md5checksums.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.md5checksums.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "page-token" => { request.page_token = Some(value.unwrap_or("").to_string()); @@ -3140,9 +3184,9 @@ impl Engine { }, "accessions" => { if request.accessions.is_none() { - request.accessions = Some(Default::default()); + request.accessions = Some(Default::default()); } - request.accessions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.accessions.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")); @@ -3164,8 +3208,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3176,7 +3219,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.referencesets().get(&self.opt.arg_reference_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3208,8 +3251,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3218,10 +3260,10 @@ impl Engine { fn _referencesets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchReferenceSetsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3241,27 +3283,28 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { "md5checksums" => { if request.md5checksums.is_none() { - request.md5checksums = Some(Default::default()); + request.md5checksums = Some(Default::default()); } - request.md5checksums.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.md5checksums.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "assembly-id" => { request.assembly_id = Some(value.unwrap_or("").to_string()); }, "accessions" => { if request.accessions.is_none() { - request.accessions = Some(Default::default()); + request.accessions = Some(Default::default()); } - request.accessions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.accessions.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")); @@ -3286,20 +3329,19 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } } } - fn _streaming_variant_store_streamvariants(&self, dry_run: bool, err: &mut InvalidOptionsError) + fn _streaming_readstore_streamreads(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::StreamVariantsRequest = Default::default(); - let mut call = self.hub.streaming_variant_store().streamvariants(&request); + let mut request = api::StreamReadsRequest::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3319,24 +3361,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { - "variant-set-ids" => { - if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + "read-group-set-ids" => { + if request.read_group_set_ids.is_none() { + request.read_group_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(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()); + request.read_group_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "end" => { request.end = Some(value.unwrap_or("").to_string()); @@ -3364,8 +3401,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3374,10 +3410,10 @@ impl Engine { fn _variants_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Variant = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3397,9 +3433,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3418,24 +3455,24 @@ impl Engine { }, "filter" => { if request.filter.is_none() { - request.filter = Some(Default::default()); + request.filter = Some(Default::default()); } - request.filter.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.filter.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start" => { request.start = Some(value.unwrap_or("").to_string()); }, "names" => { if request.names.is_none() { - request.names = Some(Default::default()); + request.names = Some(Default::default()); } - request.names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "alternate-bases" => { if request.alternate_bases.is_none() { - request.alternate_bases = Some(Default::default()); + request.alternate_bases = Some(Default::default()); } - request.alternate_bases.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.alternate_bases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reference-name" => { request.reference_name = Some(value.unwrap_or("").to_string()); @@ -3463,8 +3500,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3475,7 +3511,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.variants().delete(&self.opt.arg_variant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3506,7 +3542,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3517,7 +3552,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.variants().get(&self.opt.arg_variant_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3549,8 +3584,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3559,10 +3593,10 @@ impl Engine { fn _variants_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchVariantsRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3582,9 +3616,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3606,9 +3641,9 @@ impl Engine { }, "call-set-ids" => { if request.call_set_ids.is_none() { - request.call_set_ids = Some(Default::default()); + request.call_set_ids = Some(Default::default()); } - request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "variant-name" => { request.variant_name = Some(value.unwrap_or("").to_string()); @@ -3618,9 +3653,9 @@ impl Engine { }, "variant-set-ids" => { if request.variant_set_ids.is_none() { - request.variant_set_ids = Some(Default::default()); + request.variant_set_ids = Some(Default::default()); } - request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.variant_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -3639,8 +3674,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3649,10 +3683,10 @@ impl Engine { fn _variants_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Variant = Default::default(); + let mut request = api::Variant::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3672,9 +3706,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3693,24 +3728,24 @@ impl Engine { }, "filter" => { if request.filter.is_none() { - request.filter = Some(Default::default()); + request.filter = Some(Default::default()); } - request.filter.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.filter.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "start" => { request.start = Some(value.unwrap_or("").to_string()); }, "names" => { if request.names.is_none() { - request.names = Some(Default::default()); + request.names = Some(Default::default()); } - request.names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "alternate-bases" => { if request.alternate_bases.is_none() { - request.alternate_bases = Some(Default::default()); + request.alternate_bases = Some(Default::default()); } - request.alternate_bases.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.alternate_bases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "reference-name" => { request.reference_name = Some(value.unwrap_or("").to_string()); @@ -3738,8 +3773,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3750,7 +3784,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.variantsets().delete(&self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3781,7 +3815,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3790,10 +3823,10 @@ impl Engine { fn _variantsets_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ExportVariantSetRequest = Default::default(); + let mut request = api::ExportVariantSetRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3813,9 +3846,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3828,9 +3862,9 @@ impl Engine { }, "call-set-ids" => { if request.call_set_ids.is_none() { - request.call_set_ids = Some(Default::default()); + request.call_set_ids = Some(Default::default()); } - request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.call_set_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "project-number" => { request.project_number = Some(value.unwrap_or("").to_string()); @@ -3855,8 +3889,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3867,7 +3900,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.variantsets().get(&self.opt.arg_variant_set_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3899,8 +3932,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3909,10 +3941,10 @@ impl Engine { fn _variantsets_import_variants(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ImportVariantsRequest = Default::default(); + let mut request = api::ImportVariantsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3932,18 +3964,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.source_uris.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "format" => { request.format = Some(value.unwrap_or("").to_string()); @@ -3965,8 +3998,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3975,10 +4007,10 @@ impl Engine { fn _variantsets_merge_variants(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::MergeVariantsRequest = Default::default(); + let mut request = api::MergeVariantsRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3998,9 +4030,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4021,7 +4054,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4030,10 +4062,10 @@ impl Engine { fn _variantsets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::VariantSet = Default::default(); + let mut request = api::VariantSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4053,9 +4085,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4083,8 +4116,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4093,10 +4125,10 @@ impl Engine { fn _variantsets_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SearchVariantSetsRequest = Default::default(); + let mut request = api::SearchVariantSetsRequest::default(); let mut call = self.hub.variantsets().search(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4116,9 +4148,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4128,9 +4161,9 @@ impl Engine { }, "dataset-ids" => { if request.dataset_ids.is_none() { - request.dataset_ids = Some(Default::default()); + request.dataset_ids = Some(Default::default()); } - request.dataset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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")); @@ -4152,8 +4185,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4162,10 +4194,10 @@ impl Engine { fn _variantsets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::VariantSet = Default::default(); + let mut request = api::VariantSet::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4185,9 +4217,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4215,8 +4248,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4244,7 +4276,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_annotations { + } + else if self.opt.cmd_annotations { if self.opt.cmd_batch_create { call_result = self._annotations_batch_create(dry_run, &mut err); } else if self.opt.cmd_create { @@ -4262,7 +4295,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_callsets { + } + else if self.opt.cmd_callsets { if self.opt.cmd_create { call_result = self._callsets_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -4278,7 +4312,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_datasets { + } + else if self.opt.cmd_datasets { if self.opt.cmd_create { call_result = self._datasets_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -4296,13 +4331,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_experimental { + } + else if self.opt.cmd_experimental { if self.opt.cmd_jobs_create { call_result = self._experimental_jobs_create(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_jobs { + } + else if self.opt.cmd_jobs { if self.opt.cmd_cancel { call_result = self._jobs_cancel(dry_run, &mut err); } else if self.opt.cmd_get { @@ -4312,7 +4349,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_readgroupsets { + } + else if self.opt.cmd_readgroupsets { if self.opt.cmd_align { call_result = self._readgroupsets_align(dry_run, &mut err); } else if self.opt.cmd_call { @@ -4336,13 +4374,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_reads { + } + else if self.opt.cmd_reads { if self.opt.cmd_search { call_result = self._reads_search(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_references { + } + else if self.opt.cmd_references { if self.opt.cmd_bases_list { call_result = self._references_bases_list(dry_run, &mut err); } else if self.opt.cmd_get { @@ -4352,7 +4392,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_referencesets { + } + else if self.opt.cmd_referencesets { if self.opt.cmd_get { call_result = self._referencesets_get(dry_run, &mut err); } else if self.opt.cmd_search { @@ -4360,13 +4401,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_streaming_variant_store { - if self.opt.cmd_streamvariants { - call_result = self._streaming_variant_store_streamvariants(dry_run, &mut err); + } + else if self.opt.cmd_streaming_readstore { + if self.opt.cmd_streamreads { + call_result = self._streaming_readstore_streamreads(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_variants { + } + else if self.opt.cmd_variants { if self.opt.cmd_create { call_result = self._variants_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -4380,7 +4423,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_variantsets { + } + else if self.opt.cmd_variantsets { if self.opt.cmd_delete { call_result = self._variantsets_delete(dry_run, &mut err); } else if self.opt.cmd_export { @@ -4420,21 +4464,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "genomics1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "genomics1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "genomics1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "genomics1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Genomics::new(hyper::Client::new(), auth), + hub: api::Genomics::new(client, auth), }; match engine._doit(true) { @@ -4454,12 +4514,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 30c945e05a..045c5762ed 100644 --- a/gen/genomics1_beta2/Cargo.toml +++ b/gen/genomics1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-genomics1_beta2" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/genomics/v1beta2/reference" diff --git a/gen/genomics1_beta2/README.md b/gen/genomics1_beta2/README.md index 4df8acb406..767c26c480 100644 --- a/gen/genomics1_beta2/README.md +++ b/gen/genomics1_beta2/README.md @@ -33,8 +33,8 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*bases list*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.ReferenceBaseListCall.html), [*get*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.ReferenceGetCall.html) and [*search*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.ReferenceSearchCall.html) * referencesets * [*get*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.ReferencesetGetCall.html) and [*search*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.ReferencesetSearchCall.html) -* streaming variant store - * [*streamvariants*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.StreamingVariantStoreStreamvariantCall.html) +* streaming readstore + * [*streamreads*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.StreamingReadstoreStreamreadCall.html) * [variants](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.Variant.html) * [*create*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.VariantCreateCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.VariantDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.VariantGetCall.html), [*search*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.VariantSearchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_genomics1_beta2/struct.VariantUpdateCall.html) * variantsets @@ -123,7 +123,7 @@ let mut hub = Genomics::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Annotation = Default::default(); +let mut req = Annotation::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/genomics1_beta2/src/cmn.rs b/gen/genomics1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/genomics1_beta2/src/cmn.rs +++ b/gen/genomics1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/genomics1_beta2/src/lib.rs b/gen/genomics1_beta2/src/lib.rs index 4b08430aa8..a6dac77b3d 100644 --- a/gen/genomics1_beta2/src/lib.rs +++ b/gen/genomics1_beta2/src/lib.rs @@ -31,8 +31,8 @@ //! * [*bases list*](struct.ReferenceBaseListCall.html), [*get*](struct.ReferenceGetCall.html) and [*search*](struct.ReferenceSearchCall.html) //! * referencesets //! * [*get*](struct.ReferencesetGetCall.html) and [*search*](struct.ReferencesetSearchCall.html) -//! * streaming variant store -//! * [*streamvariants*](struct.StreamingVariantStoreStreamvariantCall.html) +//! * streaming readstore +//! * [*streamreads*](struct.StreamingReadstoreStreamreadCall.html) //! * [variants](struct.Variant.html) //! * [*create*](struct.VariantCreateCall.html), [*delete*](struct.VariantDeleteCall.html), [*get*](struct.VariantGetCall.html), [*search*](struct.VariantSearchCall.html) and [*update*](struct.VariantUpdateCall.html) //! * variantsets @@ -124,7 +124,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Annotation = Default::default(); +//! let mut req = Annotation::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -311,7 +311,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Annotation = Default::default(); +/// let mut req = Annotation::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -385,8 +385,8 @@ impl<'a, C, A> Genomics<C, A> pub fn referencesets(&'a self) -> ReferencesetMethods<'a, C, A> { ReferencesetMethods { hub: &self } } - pub fn streaming_variant_store(&'a self) -> StreamingVariantStoreMethods<'a, C, A> { - StreamingVariantStoreMethods { hub: &self } + pub fn streaming_readstore(&'a self) -> StreamingReadstoreMethods<'a, C, A> { + StreamingReadstoreMethods { hub: &self } } pub fn variants(&'a self) -> VariantMethods<'a, C, A> { VariantMethods { hub: &self } @@ -422,7 +422,7 @@ impl<'a, C, A> Genomics<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BatchAnnotationsResponse { /// The resulting per-annotation entries, ordered consistently with the original request. - pub entries: Vec<BatchAnnotationsResponseEntry>, + pub entries: Option<Vec<BatchAnnotationsResponseEntry>>, } impl ResponseResult for BatchAnnotationsResponse {} @@ -460,7 +460,7 @@ impl RequestValue for SearchVariantSetsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Int32Value { /// The int32 value. - pub value: i32, + pub value: Option<i32>, } impl Part for Int32Value {} @@ -479,9 +479,9 @@ impl Part for Int32Value {} pub struct SearchJobsResponse { /// The continuation token which is used to page through large result sets. Provide this value is a subsequent request to return the next page of results. This field will be empty if there are no more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of jobs results, ordered newest to oldest. - pub jobs: Vec<Job>, + pub jobs: Option<Vec<Job>>, } impl ResponseResult for SearchJobsResponse {} @@ -495,23 +495,23 @@ impl ResponseResult for SearchJobsResponse {} pub struct VariantAnnotation { /// Google annotation IDs of the transcripts affected by this variant. These should be provided when the variant is created. #[serde(rename="transcriptIds")] - pub transcript_ids: Vec<String>, + pub transcript_ids: Option<Vec<String>>, /// The alternate allele for this variant. If multiple alternate alleles exist at this location, create a separate variant for each one, as they may represent distinct conditions. #[serde(rename="alternateBases")] - pub alternate_bases: String, + pub alternate_bases: Option<String>, /// Describes the clinical significance of a variant. It is adapted from the ClinVar controlled vocabulary for clinical significance described at: http://www.ncbi.nlm.nih.gov/clinvar/docs/clinsig/ #[serde(rename="clinicalSignificance")] - pub clinical_significance: String, + pub clinical_significance: Option<String>, /// The set of conditions associated with this variant. A condition describes the way a variant influences human health. - pub conditions: Vec<VariantAnnotationCondition>, + pub conditions: Option<Vec<VariantAnnotationCondition>>, /// Type has been adapted from ClinVar's list of variant types. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Effect of the variant on the coding sequence. - pub effect: String, + pub effect: Option<String>, /// Google annotation ID of the gene affected by this variant. This should be provided when the variant is created. #[serde(rename="geneId")] - pub gene_id: String, + pub gene_id: Option<String>, } impl Part for VariantAnnotation {} @@ -525,15 +525,15 @@ impl Part for VariantAnnotation {} pub struct VariantAnnotationCondition { /// The MedGen concept id associated with this gene. Search for these IDs at http://www.ncbi.nlm.nih.gov/medgen/ #[serde(rename="conceptId")] - pub concept_id: String, + pub concept_id: Option<String>, /// The OMIM id for this condition. Search for these IDs at http://omim.org/ #[serde(rename="omimId")] - pub omim_id: String, + pub omim_id: Option<String>, /// The set of external IDs for this condition. #[serde(rename="externalIds")] - pub external_ids: Vec<ExternalId>, + pub external_ids: Option<Vec<ExternalId>>, /// A set of names for the condition. - pub names: Vec<String>, + pub names: Option<Vec<String>>, } impl Part for VariantAnnotationCondition {} @@ -567,20 +567,20 @@ impl RequestValue for ImportVariantsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metadata { /// Remaining structured metadata key-value pairs. - pub info: HashMap<String, Vec<String>>, + pub info: Option<HashMap<String, Vec<String>>>, /// A textual description of this metadata. - pub description: String, + pub description: Option<String>, /// The top-level key. - pub key: String, + pub key: Option<String>, /// The type of data. Possible types include: Integer, Float, Flag, Character, and String. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The number of values that can be included in a field described by this metadata. - pub number: String, + pub number: Option<String>, /// The value field for simple metadata - pub value: String, + pub value: Option<String>, /// User-provided ID field, not enforced by this API. Two or more pieces of structured metadata with identical id and key fields are considered equivalent. - pub id: String, + pub id: Option<String>, } impl Part for Metadata {} @@ -599,13 +599,13 @@ impl Part for Metadata {} pub struct ListCoverageBucketsResponse { /// The coverage buckets. The list of buckets is sparse; a bucket with 0 overlapping reads is not returned. A bucket never crosses more than one reference sequence. Each bucket has width bucketWidth, unless its end is the end of the reference sequence. #[serde(rename="coverageBuckets")] - pub coverage_buckets: Vec<CoverageBucket>, + pub coverage_buckets: Option<Vec<CoverageBucket>>, /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The length of each coverage bucket in base pairs. Note that buckets at the end of a reference sequence may be shorter. This value is omitted if the bucket width is infinity (the default behaviour, with no range or targetBucketWidth). #[serde(rename="bucketWidth")] - pub bucket_width: String, + pub bucket_width: Option<String>, } impl ResponseResult for ListCoverageBucketsResponse {} @@ -619,19 +619,19 @@ impl ResponseResult for ListCoverageBucketsResponse {} pub struct FastqMetadata { /// Optionally specifies the platform unit for alignment from FASTQ. For example: flowcell-barcode.lane for Illumina or slide for SOLID. #[serde(rename="platformUnit")] - pub platform_unit: String, + pub platform_unit: Option<String>, /// Optionally specifies the read group name for alignment from FASTQ. #[serde(rename="readGroupName")] - pub read_group_name: String, + pub read_group_name: Option<String>, /// Optionally specifies the library name for alignment from FASTQ. #[serde(rename="libraryName")] - pub library_name: String, + pub library_name: Option<String>, /// Optionally specifies the platform name for alignment from FASTQ. For example: CAPILLARY, LS454, ILLUMINA, SOLID, HELICOS, IONTORRENT, PACBIO. #[serde(rename="platformName")] - pub platform_name: String, + pub platform_name: Option<String>, /// Optionally specifies the sample name for alignment from FASTQ. #[serde(rename="sampleName")] - pub sample_name: String, + pub sample_name: Option<String>, } impl Part for FastqMetadata {} @@ -650,7 +650,7 @@ impl Part for FastqMetadata {} pub struct ExportVariantSetResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for ExportVariantSetResponse {} @@ -669,9 +669,9 @@ impl ResponseResult for ExportVariantSetResponse {} pub struct SearchAnnotationsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matching annotations. - pub annotations: Vec<Annotation>, + pub annotations: Option<Vec<Annotation>>, } impl ResponseResult for SearchAnnotationsResponse {} @@ -685,16 +685,16 @@ impl ResponseResult for SearchAnnotationsResponse {} pub struct ReadGroupProgram { /// The command line used to run this program. #[serde(rename="commandLine")] - pub command_line: String, + pub command_line: Option<String>, /// The version of the program run. - pub version: String, + pub version: Option<String>, /// The user specified locally unique ID of the program. Used along with prevProgramId to define an ordering between programs. - pub id: String, + pub id: Option<String>, /// The name of the program. - pub name: String, + pub name: Option<String>, /// The ID of the program run before this one. #[serde(rename="prevProgramId")] - pub prev_program_id: String, + pub prev_program_id: Option<String>, } impl Part for ReadGroupProgram {} @@ -741,7 +741,7 @@ pub struct Transcript { /// /// Note that in some cases, the reference genome will not exactly match the observed mRNA transcript e.g. due to variance in the source genome from reference. In these cases, exon.frame will not necessarily match the expected reference reading frame and coding exon reference bases cannot necessarily be concatenated to produce the original transcript mRNA. #[serde(rename="codingSequence")] - pub coding_sequence: TranscriptCodingSequence, + pub coding_sequence: Option<TranscriptCodingSequence>, /// The exons that compose this transcript. This field should be unset for genomes where transcript splicing does not occur, for example prokaryotes. /// /// @@ -752,10 +752,10 @@ pub struct Transcript { /// /// /// Exons are ordered by start position and may not overlap. - pub exons: Vec<TranscriptExon>, + pub exons: Option<Vec<TranscriptExon>>, /// The annotation ID of the gene from which this transcript is transcribed. #[serde(rename="geneId")] - pub gene_id: String, + pub gene_id: Option<String>, } impl Part for Transcript {} @@ -810,12 +810,12 @@ impl ResponseResult for Annotation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct JobRequest { /// The data source of the request, for example, a Google Cloud Storage object path or Readset ID. - pub source: Vec<String>, + pub source: Option<Vec<String>>, /// The data destination of the request, for example, a Google BigQuery Table or Dataset ID. - pub destination: Vec<String>, + pub destination: Option<Vec<String>>, /// The original request type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for JobRequest {} @@ -834,9 +834,9 @@ impl Part for JobRequest {} pub struct SearchVariantsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of matching Variants. - pub variants: Vec<Variant>, + pub variants: Option<Vec<Variant>>, } impl ResponseResult for SearchVariantsResponse {} @@ -882,18 +882,18 @@ impl RequestValue for SearchJobsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RangePosition { /// The start position of the range on the reference, 0-based inclusive. - pub start: String, + pub start: Option<String>, /// The ID of the Google Genomics reference associated with this range. #[serde(rename="referenceId")] - pub reference_id: String, + pub reference_id: Option<String>, /// The end position of the range on the reference, 0-based exclusive. - pub end: String, + pub end: Option<String>, /// Whether this range refers to the reverse strand, as opposed to the forward strand. Note that regardless of this field, the start/end position of the range always refer to the forward strand. #[serde(rename="reverseStrand")] - pub reverse_strand: bool, + pub reverse_strand: Option<bool>, /// The display name corresponding to the reference specified by referenceId, for example chr1, 1, or chrX. #[serde(rename="referenceName")] - pub reference_name: String, + pub reference_name: Option<String>, } impl Part for RangePosition {} @@ -907,9 +907,9 @@ impl Part for RangePosition {} pub struct ExternalId { /// The name of the source of this data. #[serde(rename="sourceName")] - pub source_name: String, + pub source_name: Option<String>, /// The id used by the source of this data. - pub id: String, + pub id: Option<String>, } impl Part for ExternalId {} @@ -957,13 +957,13 @@ impl ResponseResult for CallSet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Position { /// The 0-based offset from the start of the forward strand for that reference. - pub position: String, + pub position: Option<String>, /// Whether this position is on the reverse strand, as opposed to the forward strand. #[serde(rename="reverseStrand")] - pub reverse_strand: bool, + pub reverse_strand: Option<bool>, /// The name of the reference in whatever reference set is being used. #[serde(rename="referenceName")] - pub reference_name: String, + pub reference_name: Option<String>, } impl Part for Position {} @@ -982,7 +982,7 @@ impl Part for Position {} pub struct ImportVariantsResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for ImportVariantsResponse {} @@ -996,16 +996,16 @@ impl ResponseResult for ImportVariantsResponse {} pub struct ReadGroupExperiment { /// The sequencing center used as part of this experiment. #[serde(rename="sequencingCenter")] - pub sequencing_center: String, + pub sequencing_center: Option<String>, /// The library used as part of this experiment. Note: This is not an actual ID within this repository, but rather an identifier for a library which may be meaningful to some external system. #[serde(rename="libraryId")] - pub library_id: String, + pub library_id: Option<String>, /// The instrument model used as part of this experiment. This maps to sequencing technology in BAM. #[serde(rename="instrumentModel")] - pub instrument_model: String, + pub instrument_model: Option<String>, /// The platform unit used as part of this experiment e.g. flowcell-barcode.lane for Illumina or slide for SOLiD. Corresponds to the #[serde(rename="platformUnit")] - pub platform_unit: String, + pub platform_unit: Option<String>, } impl Part for ReadGroupExperiment {} @@ -1030,7 +1030,7 @@ pub struct SearchCallSetsRequest { pub variant_set_ids: Option<Vec<String>>, /// Only return call sets for which a substring of the name matches this string. pub name: Option<String>, - /// The maximum number of call sets to return. + /// The maximum number of call sets to return. If unspecified, defaults to 1000. #[serde(rename="pageSize")] pub page_size: Option<i32>, } @@ -1051,9 +1051,9 @@ impl RequestValue for SearchCallSetsRequest {} pub struct ListDatasetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of matching Datasets. - pub datasets: Vec<Dataset>, + pub datasets: Option<Vec<Dataset>>, } impl ResponseResult for ListDatasetsResponse {} @@ -1100,7 +1100,7 @@ impl RequestValue for ImportReadGroupSetsRequest {} pub struct CallReadGroupSetsResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for CallReadGroupSetsResponse {} @@ -1120,22 +1120,22 @@ impl ResponseResult for CallReadGroupSetsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Reference { /// The length of this reference's sequence. - pub length: String, + pub length: Option<String>, /// The name of this reference, for example 22. - pub name: String, + pub name: Option<String>, /// The URI from which the sequence was obtained. Specifies a FASTA format file/string with one name, sequence pair. #[serde(rename="sourceURI")] - pub source_uri: String, + pub source_uri: Option<String>, /// ID from http://www.ncbi.nlm.nih.gov/taxonomy (e.g. 9606->human) if not specified by the containing reference set. #[serde(rename="ncbiTaxonId")] - pub ncbi_taxon_id: i32, + pub ncbi_taxon_id: Option<i32>, /// All known corresponding accession IDs in INSDC (GenBank/ENA/DDBJ) ideally with a version number, for example GCF_000001405.26. #[serde(rename="sourceAccessions")] - pub source_accessions: Vec<String>, + pub source_accessions: Option<Vec<String>>, /// The Google generated immutable ID of the reference. - pub id: String, + pub id: Option<String>, /// MD5 of the upper-case sequence excluding all whitespace characters (this is equivalent to SQ:M5 in SAM). This value is represented in lower case hexadecimal format. - pub md5checksum: String, + pub md5checksum: Option<String>, } impl Resource for Reference {} @@ -1208,29 +1208,29 @@ impl RequestValue for SearchReferencesRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReadGroup { /// A map of additional read group information. - pub info: HashMap<String, Vec<String>>, + pub info: Option<HashMap<String, Vec<String>>>, /// The predicted insert size of this read group. The insert size is the length the sequenced DNA fragment from end-to-end, not including the adapters. #[serde(rename="predictedInsertSize")] - pub predicted_insert_size: i32, + pub predicted_insert_size: Option<i32>, /// The read group name. This corresponds to the @RG ID field in the SAM spec. - pub name: String, + pub name: Option<String>, /// The programs used to generate this read group. Programs are always identical for all read groups within a read group set. For this reason, only the first read group in a returned set will have this field populated. - pub programs: Vec<ReadGroupProgram>, + pub programs: Option<Vec<ReadGroupProgram>>, /// The sample this read group's data was generated from. Note: This is not an actual ID within this repository, but rather an identifier for a sample which may be meaningful to some external system. #[serde(rename="sampleId")] - pub sample_id: String, + pub sample_id: Option<String>, /// The experiment used to generate this read group. - pub experiment: ReadGroupExperiment, + pub experiment: Option<ReadGroupExperiment>, /// The reference set the reads in this read group are aligned to. Required if there are any read alignments. #[serde(rename="referenceSetId")] - pub reference_set_id: String, + pub reference_set_id: Option<String>, /// The generated unique read group ID. Note: This is different than the @RG ID field in the SAM spec. For that value, see the name field. - pub id: String, + pub id: Option<String>, /// The ID of the dataset this read group belongs to. #[serde(rename="datasetId")] - pub dataset_id: String, + pub dataset_id: Option<String>, /// A free-form text description of this read group. - pub description: String, + pub description: Option<String>, } impl Part for ReadGroup {} @@ -1249,10 +1249,10 @@ impl Part for ReadGroup {} pub struct SearchReadGroupSetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of matching read group sets. #[serde(rename="readGroupSets")] - pub read_group_sets: Vec<ReadGroupSet>, + pub read_group_sets: Option<Vec<ReadGroupSet>>, } impl ResponseResult for SearchReadGroupSetsResponse {} @@ -1271,7 +1271,7 @@ impl ResponseResult for SearchReadGroupSetsResponse {} pub struct ImportReadGroupSetsResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for ImportReadGroupSetsResponse {} @@ -1290,7 +1290,7 @@ impl ResponseResult for ImportReadGroupSetsResponse {} pub struct ExportReadGroupSetsResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for ExportReadGroupSetsResponse {} @@ -1330,9 +1330,9 @@ impl RequestValue for SearchReadGroupSetsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BatchAnnotationsResponseEntry { /// The resulting status for this annotation operation. - pub status: BatchAnnotationsResponseEntryStatus, + pub status: Option<BatchAnnotationsResponseEntryStatus>, /// The annotation, if any. - pub annotation: Annotation, + pub annotation: Option<Annotation>, } impl Part for BatchAnnotationsResponseEntry {} @@ -1345,9 +1345,9 @@ impl Part for BatchAnnotationsResponseEntry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BatchAnnotationsResponseEntryStatus { /// Error message for this status, if any. - pub message: String, + pub message: Option<String>, /// The HTTP status code for this operation. - pub code: i32, + pub code: Option<i32>, } impl Part for BatchAnnotationsResponseEntryStatus {} @@ -1366,11 +1366,11 @@ impl Part for BatchAnnotationsResponseEntryStatus {} pub struct ListBasesResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The offset position (0-based) of the given sequence from the start of this Reference. This value will differ for each page in a paginated request. - pub offset: String, + pub offset: Option<String>, /// A substring of the bases that make up this reference. - pub sequence: String, + pub sequence: Option<String>, } impl ResponseResult for ListBasesResponse {} @@ -1384,10 +1384,10 @@ impl ResponseResult for ListBasesResponse {} pub struct ReferenceBound { /// An upper bound (inclusive) on the starting coordinate of any variant in the reference sequence. #[serde(rename="upperBound")] - pub upper_bound: String, + pub upper_bound: Option<String>, /// The reference the bound is associate with. #[serde(rename="referenceName")] - pub reference_name: String, + pub reference_name: Option<String>, } impl Part for ReferenceBound {} @@ -1400,20 +1400,20 @@ impl Part for ReferenceBound {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Call { /// A map of additional variant call information. - pub info: HashMap<String, Vec<String>>, + pub info: Option<HashMap<String, Vec<String>>>, /// The genotype of this variant call. Each value represents either the value of the referenceBases field or a 1-based index into alternateBases. If a variant had a referenceBases value of T and an alternateBases value of ["A", "C"], and the genotype was [2, 1], that would mean the call represented the heterozygous value CA for this variant. If the genotype was instead [0, 1], the represented value would be TA. Ordering of the genotype values is important if the phaseset is present. If a genotype is not called (that is, a . is present in the GT string) -1 is returned. - pub genotype: Vec<i32>, + pub genotype: Option<Vec<i32>>, /// The ID of the call set this variant call belongs to. #[serde(rename="callSetId")] - pub call_set_id: String, + pub call_set_id: Option<String>, /// If this field is present, this variant call's genotype ordering implies the phase of the bases and is consistent with any other variant calls in the same reference sequence which have the same phaseset value. When importing data from VCF, if the genotype data was phased but no phase set was specified this field will be set to *. - pub phaseset: String, + pub phaseset: Option<String>, /// The genotype likelihoods for this variant call. Each array entry represents how likely a specific genotype is for this call. The value ordering is defined by the GL tag in the VCF spec. If Phred-scaled genotype likelihood scores (PL) are available and log10(P) genotype likelihood scores (GL) are not, PL scores are converted to GL scores. If both are available, PL scores are stored in info. #[serde(rename="genotypeLikelihood")] - pub genotype_likelihood: Vec<f64>, + pub genotype_likelihood: Option<Vec<f64>>, /// The name of the call set this variant call belongs to. #[serde(rename="callSetName")] - pub call_set_name: String, + pub call_set_name: Option<String>, } impl Part for Call {} @@ -1432,7 +1432,7 @@ impl Part for Call {} pub struct ExperimentalCreateJobResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for ExperimentalCreateJobResponse {} @@ -1449,18 +1449,18 @@ impl ResponseResult for ExperimentalCreateJobResponse {} /// #[derive(Default, Clone, Debug, Serialize)] pub struct SearchVariantsRequest { - /// Required. The end of the window (0-based, exclusive) for which overlapping variants should be returned. + /// The end of the window, 0-based exclusive. If unspecified or 0, defaults to the length of the reference. pub end: Option<String>, - /// The maximum number of variants to return. + /// The maximum number of variants to return. If unspecified, defaults to 5000. #[serde(rename="pageSize")] pub page_size: Option<i32>, /// The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response. #[serde(rename="pageToken")] pub page_token: Option<String>, - /// The maximum number of calls to return. However, at least one variant will always be returned, even if it has more calls than this limit. + /// The maximum number of calls to return. However, at least one variant will always be returned, even if it has more calls than this limit. If unspecified, defaults to 5000. #[serde(rename="maxCalls")] pub max_calls: Option<i32>, - /// Required. The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. + /// The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. If unspecified, defaults to 0. pub start: Option<String>, /// Only return variant calls which belong to call sets with these ids. Leaving this blank returns all variant calls. If a variant has no calls belonging to any of these call sets, it won't be returned at all. Currently, variants with no calls from any call set will never be returned. #[serde(rename="callSetIds")] @@ -1536,7 +1536,7 @@ pub struct Read { /// The fragment name. Equivalent to QNAME (query template name) in SAM. #[serde(rename="fragmentName")] pub fragment_name: Option<String>, - /// The mapping of the primary alignment of the (readNumber+1)%numberReads read in the fragment. It replaces mate position and mate strand in SAM. + /// The position of the primary alignment of the (readNumber+1)%numberReads read in the fragment. It replaces mate position and mate strand in SAM. This field will be unset if that read is unmapped or if the fragment only has a single read. #[serde(rename="nextMatePosition")] pub next_mate_position: Option<Position>, /// Whether this alignment is supplementary. Equivalent to SAM flag 0x800. Supplementary alignments are used in the representation of a chimeric alignment. In a chimeric alignment, a read is split into multiple linear alignments that map to different reference contigs. The first linear alignment in the read will be designated as the representative alignment; the remaining linear alignments will be designated as supplementary alignments. These alignments may have different mapping quality scores. In each linear alignment in a chimeric alignment, the read will be hard clipped. The alignedSequence and alignedQuality fields in the alignment record will only represent the bases for its respective linear alignment. @@ -1547,7 +1547,7 @@ pub struct Read { pub fragment_length: Option<i32>, /// The unique ID for this read. This is a generated unique ID, not to be confused with fragmentName. pub id: Option<String>, - /// The linear alignment for this alignment record. This field will be null if the read is unmapped. + /// The linear alignment for this alignment record. This field will be unset if the read is unmapped. pub alignment: Option<LinearAlignment>, /// A map of additional read alignment information. pub info: Option<HashMap<String, Vec<String>>>, @@ -1620,12 +1620,11 @@ impl RequestValue for ExperimentalCreateJobRequest {} /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// -/// * [streamvariants streaming variant store](struct.StreamingVariantStoreStreamvariantCall.html) (response) +/// * [get variants](struct.VariantGetCall.html) (response) +/// * [search variants](struct.VariantSearchCall.html) (none) /// * [update variants](struct.VariantUpdateCall.html) (request|response) /// * [delete variants](struct.VariantDeleteCall.html) (none) /// * [create variants](struct.VariantCreateCall.html) (request|response) -/// * [get variants](struct.VariantGetCall.html) (response) -/// * [search variants](struct.VariantSearchCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Variant { @@ -1679,10 +1678,10 @@ impl ResponseResult for Variant {} pub struct SearchAnnotationSetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matching annotation sets. #[serde(rename="annotationSets")] - pub annotation_sets: Vec<AnnotationSet>, + pub annotation_sets: Option<Vec<AnnotationSet>>, } impl ResponseResult for SearchAnnotationSetsResponse {} @@ -1703,25 +1702,25 @@ impl ResponseResult for SearchAnnotationSetsResponse {} pub struct Job { /// A more detailed description of this job's current status. #[serde(rename="detailedStatus")] - pub detailed_status: String, + pub detailed_status: Option<String>, /// The status of this job. - pub status: String, + pub status: Option<String>, /// Any errors that occurred during processing. - pub errors: Vec<String>, + pub errors: Option<Vec<String>>, /// Any warnings that occurred during processing. - pub warnings: Vec<String>, + pub warnings: Option<Vec<String>>, /// The date this job was created, in milliseconds from the epoch. - pub created: String, + pub created: Option<String>, /// A summarized representation of the original service request. - pub request: JobRequest, + pub request: Option<JobRequest>, /// The job ID. - pub id: String, + pub id: Option<String>, /// If this Job represents an import, this field will contain the IDs of the objects that were successfully imported. #[serde(rename="importedIds")] - pub imported_ids: Vec<String>, + pub imported_ids: Option<Vec<String>>, /// The Google Developers Console project number to which this job belongs. #[serde(rename="projectNumber")] - pub project_number: String, + pub project_number: Option<String>, } impl Resource for Job {} @@ -1830,10 +1829,10 @@ impl RequestValue for ExportReadGroupSetsRequest {} pub struct SearchReferenceSetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matching references sets. #[serde(rename="referenceSets")] - pub reference_sets: Vec<ReferenceSet>, + pub reference_sets: Option<Vec<ReferenceSet>>, } impl ResponseResult for SearchReferenceSetsResponse {} @@ -1851,26 +1850,26 @@ impl ResponseResult for SearchReferenceSetsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReferenceSet { /// Free text description of this reference set. - pub description: String, + pub description: Option<String>, /// The URI from which the references were obtained. #[serde(rename="sourceURI")] - pub source_uri: String, + pub source_uri: Option<String>, /// The IDs of the reference objects that are part of this set. Reference.md5checksum must be unique within this set. #[serde(rename="referenceIds")] - pub reference_ids: Vec<String>, + pub reference_ids: Option<Vec<String>>, /// Public id of this reference set, such as GRCh37. #[serde(rename="assemblyId")] - pub assembly_id: String, + pub assembly_id: Option<String>, /// All known corresponding accession IDs in INSDC (GenBank/ENA/DDBJ) ideally with a version number, for example NC_000001.11. #[serde(rename="sourceAccessions")] - pub source_accessions: Vec<String>, + pub source_accessions: Option<Vec<String>>, /// ID from http://www.ncbi.nlm.nih.gov/taxonomy (e.g. 9606->human) indicating the species which this assembly is intended to model. Note that contained references may specify a different ncbiTaxonId, as assemblies may contain reference sequences which do not belong to the modeled species, e.g. EBV in a human reference genome. #[serde(rename="ncbiTaxonId")] - pub ncbi_taxon_id: i32, + pub ncbi_taxon_id: Option<i32>, /// The Google generated immutable ID of the reference set. - pub id: String, + pub id: Option<String>, /// Order-independent MD5 checksum which identifies this reference set. The checksum is computed by sorting all lower case hexidecimal string reference.md5checksum (for all reference in this set) in ascending lexicographic order, concatenating, and taking the MD5 of that value. The resulting value is represented in lower case hexadecimal format. - pub md5checksum: String, + pub md5checksum: Option<String>, } impl Resource for ReferenceSet {} @@ -1920,7 +1919,7 @@ impl ResponseResult for VariantSet {} pub struct AlignReadGroupSetsResponse { /// A job ID that can be used to get status information. #[serde(rename="jobId")] - pub job_id: String, + pub job_id: Option<String>, } impl ResponseResult for AlignReadGroupSetsResponse {} @@ -1961,12 +1960,12 @@ impl RequestValue for SearchAnnotationsRequest {} pub struct PairedFastqSource { /// A list of URIs pointing at paired end FASTQ files in Google Cloud Storage which will be aligned. The second of each paired file should be specified here, in an order that matches the first of each paired file specified in firstSourceUris. For example: firstSourceUris: [file1_1.fq, file2_1.fq], secondSourceUris: [file1_2.fq, file2_2.fq]. The caller must have READ permissions for these files. #[serde(rename="secondSourceUris")] - pub second_source_uris: Vec<String>, + pub second_source_uris: Option<Vec<String>>, /// A list of URIs pointing at paired end FASTQ files in Google Cloud Storage which will be aligned. The first of each paired file should be specified here, in an order that matches the second of each paired file specified in secondSourceUris. For example: firstSourceUris: [file1_1.fq, file2_1.fq], secondSourceUris: [file1_2.fq, file2_2.fq]. The caller must have READ permissions for these files. #[serde(rename="firstSourceUris")] - pub first_source_uris: Vec<String>, + pub first_source_uris: Option<Vec<String>>, /// Optionally specifies the metadata to be associated with the final aligned read group set. - pub metadata: FastqMetadata, + pub metadata: Option<FastqMetadata>, } impl Part for PairedFastqSource {} @@ -2014,12 +2013,12 @@ impl RequestValue for SearchReadsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Range { /// The start position of the range on the reference, 0-based inclusive. If specified, referenceName must also be specified. - pub start: String, + pub start: Option<String>, /// The end position of the range on the reference, 0-based exclusive. If specified, referenceName must also be specified. - pub end: String, + pub end: Option<String>, /// The reference sequence name, for example chr1, 1, or chrX. #[serde(rename="referenceName")] - pub reference_name: String, + pub reference_name: Option<String>, } impl Part for Range {} @@ -2070,9 +2069,9 @@ impl RequestValue for SearchAnnotationSetsRequest {} pub struct SearchReadsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of matching alignments sorted by mapped genomic coordinate, if any, ascending in position within the same reference. Unmapped reads, which have no position, are returned last and are further sorted in ascending lexicographic order by fragment name. - pub alignments: Vec<Read>, + pub alignments: Option<Vec<Read>>, } impl ResponseResult for SearchReadsResponse {} @@ -2086,14 +2085,32 @@ impl ResponseResult for SearchReadsResponse {} pub struct InterleavedFastqSource { /// A list of URIs pointing at interleaved FASTQ files in Google Cloud Storage which will be aligned. The caller must have READ permissions for these files. #[serde(rename="sourceUris")] - pub source_uris: Vec<String>, + pub source_uris: Option<Vec<String>>, /// Optionally specifies the metadata to be associated with the final aligned read group set. - pub metadata: FastqMetadata, + pub metadata: Option<FastqMetadata>, } impl Part for InterleavedFastqSource {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [streamreads streaming readstore](struct.StreamingReadstoreStreamreadCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct StreamReadsResponse { + /// no description provided + pub alignments: Option<Vec<Read>>, +} + +impl ResponseResult for StreamReadsResponse {} + + /// There is no detailed description. /// /// # Activities @@ -2107,43 +2124,14 @@ impl Part for InterleavedFastqSource {} pub struct SearchReferencesResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The matching references. - pub references: Vec<Reference>, + pub references: Option<Vec<Reference>>, } impl ResponseResult for SearchReferencesResponse {} -/// The stream variants request. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [streamvariants streaming variant store](struct.StreamingVariantStoreStreamvariantCall.html) (request) -/// -#[derive(Default, Clone, Debug, Serialize)] -pub struct StreamVariantsRequest { - /// The end of the window (0-based, exclusive) for which overlapping variants should be returned. - pub end: Option<String>, - /// Exactly one variant set ID must be provided. Only variants from this variant set will be returned. - #[serde(rename="variantSetIds")] - pub variant_set_ids: Option<Vec<String>>, - /// Required. Only return variants in this reference sequence. - #[serde(rename="referenceName")] - pub reference_name: Option<String>, - /// Only return variant calls which belong to call sets with these ids. Leaving this blank returns all variant calls. - #[serde(rename="callSetIds")] - pub call_set_ids: Option<Vec<String>>, - /// The beginning of the window (0-based, inclusive) for which overlapping variants should be returned. - pub start: Option<String>, -} - -impl RequestValue for StreamVariantsRequest {} - - /// A read group set is a logical collection of read groups, which are collections of reads produced by a sequencer. A read group set typically models reads corresponding to one sample, sequenced one way, and aligned one way. /// - A read group set belongs to one dataset. /// - A read group belongs to one read group set. @@ -2184,6 +2172,32 @@ impl Resource for ReadGroupSet {} impl ResponseResult for ReadGroupSet {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [streamreads streaming readstore](struct.StreamingReadstoreStreamreadCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize)] +pub struct StreamReadsRequest { + /// The end position of the range on the reference, 0-based exclusive. If specified, referenceName must also be specified. + pub end: Option<String>, + /// The reference sequence name, for example chr1, 1, or chrX. If set to *, only unmapped reads are returned. + #[serde(rename="referenceName")] + pub reference_name: Option<String>, + /// The ID of the read groups set within which to search for reads. Exactly one ID must be provided. + #[serde(rename="readGroupSetIds")] + pub read_group_set_ids: Option<Vec<String>>, + /// The start position of the range on the reference, 0-based inclusive. If specified, referenceName must also be specified. + pub start: Option<String>, +} + +impl RequestValue for StreamReadsRequest {} + + /// A 0-based half-open genomic coordinate range for search requests. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2191,15 +2205,15 @@ impl ResponseResult for ReadGroupSet {} #[derive(Default, Clone, Debug, Serialize)] pub struct QueryRange { /// The start position of the range on the reference, 0-based inclusive. If specified, referenceId or referenceName must also be specified. Defaults to 0. - pub start: String, + pub start: Option<String>, /// The ID of the reference to query. At most one of referenceId and referenceName should be specified. #[serde(rename="referenceId")] - pub reference_id: String, + pub reference_id: Option<String>, /// The end position of the range on the reference, 0-based exclusive. If specified, referenceId or referenceName must also be specified. If unset or 0, defaults to the length of the reference. - pub end: String, + pub end: Option<String>, /// The name of the reference to query, within the reference set associated with this query. At most one of referenceId and referenceName pshould be specified. #[serde(rename="referenceName")] - pub reference_name: String, + pub reference_name: Option<String>, } impl Part for QueryRange {} @@ -2212,12 +2226,12 @@ impl Part for QueryRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LinearAlignment { /// The position of this alignment. - pub position: Position, + pub position: Option<Position>, /// Represents the local alignment of this sequence (alignment matches, indels, etc) against the reference. - pub cigar: Vec<CigarUnit>, + pub cigar: Option<Vec<CigarUnit>>, /// The mapping quality of this alignment. Represents how likely the read maps to this position as opposed to other locations. #[serde(rename="mappingQuality")] - pub mapping_quality: i32, + pub mapping_quality: Option<i32>, } impl Part for LinearAlignment {} @@ -2272,12 +2286,12 @@ impl ResponseResult for AnnotationSet {} pub struct CigarUnit { /// referenceSequence is only used at mismatches (SEQUENCE_MISMATCH) and deletions (DELETE). Filling this field replaces SAM's MD tag. If the relevant information is not available, this field is unset. #[serde(rename="referenceSequence")] - pub reference_sequence: String, + pub reference_sequence: Option<String>, /// no description provided - pub operation: String, + pub operation: Option<String>, /// The number of bases that the operation runs for. Required. #[serde(rename="operationLength")] - pub operation_length: String, + pub operation_length: Option<String>, } impl Part for CigarUnit {} @@ -2290,9 +2304,9 @@ impl Part for CigarUnit {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TranscriptCodingSequence { /// The start of the coding sequence on this annotation's reference sequence, 0-based inclusive. Note that this position is relative to the reference start, and not the containing annotation start. - pub start: String, + pub start: Option<String>, /// The end of the coding sequence on this annotation's reference sequence, 0-based exclusive. Note that this position is relative to the reference start, and not the containing annotation start. - pub end: String, + pub end: Option<String>, } impl Part for TranscriptCodingSequence {} @@ -2305,13 +2319,13 @@ impl Part for TranscriptCodingSequence {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TranscriptExon { /// The start position of the exon on this annotation's reference sequence, 0-based inclusive. Note that this is relative to the reference start, and not the containing annotation start. - pub start: String, + pub start: Option<String>, /// The frame of this exon. Contains a value of 0, 1, or 2, which indicates the offset of the first coding base of the exon within the reading frame of the coding DNA sequence, if any. This field is dependent on the strandedness of this annotation (see Annotation.position.reverseStrand). For forward stranded annotations, this offset is relative to the exon.start. For reverse strand annotations, this offset is relative to the exon.end-1. /// /// Unset if this exon does not intersect the coding sequence. Upon creation of a transcript, the frame must be populated for all or none of the coding exons. - pub frame: Int32Value, + pub frame: Option<Int32Value>, /// The end position of the exon on this annotation's reference sequence, 0-based exclusive. Note that this is relative to the reference start, and not the containing annotation start. - pub end: String, + pub end: Option<String>, } impl Part for TranscriptExon {} @@ -2330,10 +2344,10 @@ impl Part for TranscriptExon {} pub struct SearchVariantSetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The variant sets belonging to the requested dataset. #[serde(rename="variantSets")] - pub variant_sets: Vec<VariantSet>, + pub variant_sets: Option<Vec<VariantSet>>, } impl ResponseResult for SearchVariantSetsResponse {} @@ -2347,9 +2361,9 @@ impl ResponseResult for SearchVariantSetsResponse {} pub struct CoverageBucket { /// The average number of reads which are aligned to each individual reference base in this bucket. #[serde(rename="meanCoverage")] - pub mean_coverage: f32, + pub mean_coverage: Option<f32>, /// The genomic coordinate range spanned by this bucket. - pub range: Range, + pub range: Option<Range>, } impl Part for CoverageBucket {} @@ -2368,10 +2382,10 @@ impl Part for CoverageBucket {} pub struct SearchCallSetsResponse { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. This field will be empty if there aren't any additional results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of matching call sets. #[serde(rename="callSets")] - pub call_sets: Vec<CallSet>, + pub call_sets: Option<Vec<CallSet>>, } impl ResponseResult for SearchCallSetsResponse {} @@ -2449,23 +2463,6 @@ impl<'a, C, A> MethodsBuilder for DatasetMethods<'a, C, A> {} impl<'a, C, A> DatasetMethods<'a, C, A> { - /// Create a builder to help you perform the following task: - /// - /// Creates a new dataset. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn create(&self, request: &Dataset) -> DatasetCreateCall<'a, C, A> { - DatasetCreateCall { - hub: self.hub, - _request: request.clone(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Updates a dataset. @@ -2485,6 +2482,23 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Creates a new dataset. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn create(&self, request: &Dataset) -> DatasetCreateCall<'a, C, A> { + DatasetCreateCall { + hub: self.hub, + _request: request.clone(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Deletes a dataset. @@ -2536,6 +2550,21 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Lists datasets within a project. + pub fn list(&self) -> DatasetListCall<'a, C, A> { + DatasetListCall { + hub: self.hub, + _project_number: Default::default(), + _page_token: Default::default(), + _page_size: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Updates a dataset. This method supports patch semantics. @@ -2554,21 +2583,6 @@ impl<'a, C, A> DatasetMethods<'a, C, A> { _additional_params: Default::default(), } } - - /// Create a builder to help you perform the following task: - /// - /// Lists datasets within a project. - pub fn list(&self) -> DatasetListCall<'a, C, A> { - DatasetListCall { - hub: self.hub, - _project_number: Default::default(), - _page_token: Default::default(), - _page_size: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } } @@ -2744,63 +2758,6 @@ impl<'a, C, A> ReferencesetMethods<'a, C, A> { -/// A builder providing access to all methods supported on *streamingVariantStore* resources. -/// It is not used directly, but through the `Genomics` hub. -/// -/// # Example -/// -/// Instantiate a resource builder -/// -/// ```test_harness,no_run -/// extern crate hyper; -/// extern crate yup_oauth2 as oauth2; -/// extern crate google_genomics1_beta2 as genomics1_beta2; -/// -/// # #[test] fn egal() { -/// use std::default::Default; -/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// use genomics1_beta2::Genomics; -/// -/// let secret: ApplicationSecret = Default::default(); -/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// hyper::Client::new(), -/// <MemoryStorage as Default>::default(), None); -/// let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `streamvariants(...)` -/// // to build up your call. -/// let rb = hub.streaming_variant_store(); -/// # } -/// ``` -pub struct StreamingVariantStoreMethods<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, -} - -impl<'a, C, A> MethodsBuilder for StreamingVariantStoreMethods<'a, C, A> {} - -impl<'a, C, A> StreamingVariantStoreMethods<'a, C, A> { - - /// Create a builder to help you perform the following task: - /// - /// Returns a stream of all the variants matching the search request, ordered by reference name, position, and ID. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn streamvariants(&self, request: &StreamVariantsRequest) -> StreamingVariantStoreStreamvariantCall<'a, C, A> { - StreamingVariantStoreStreamvariantCall { - hub: self.hub, - _request: request.clone(), - _delegate: Default::default(), - _additional_params: Default::default(), - } - } -} - - - /// A builder providing access to all methods supported on *callset* resources. /// It is not used directly, but through the `Genomics` hub. /// @@ -2950,6 +2907,67 @@ impl<'a, C, A> CallsetMethods<'a, C, A> { +/// A builder providing access to all methods supported on *streamingReadstore* resources. +/// It is not used directly, but through the `Genomics` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_genomics1_beta2 as genomics1_beta2; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use genomics1_beta2::Genomics; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `streamreads(...)` +/// // to build up your call. +/// let rb = hub.streaming_readstore(); +/// # } +/// ``` +pub struct StreamingReadstoreMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, +} + +impl<'a, C, A> MethodsBuilder for StreamingReadstoreMethods<'a, C, A> {} + +impl<'a, C, A> StreamingReadstoreMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Gets a stream of reads for one or more read group sets. Reads search operates over a genomic coordinate space of reference sequence & position defined over the reference sequences to which the requested read group sets are aligned. + /// + /// If a target positional range is specified, all reads whose alignment to the reference genome overlap the range are returned. + /// + /// All reads returned are ordered by genomic coordinate (reference sequence & position). Reads with equivalent genomic coordinates are returned in a deterministic order. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn streamreads(&self, request: &StreamReadsRequest) -> StreamingReadstoreStreamreadCall<'a, C, A> { + StreamingReadstoreStreamreadCall { + hub: self.hub, + _request: request.clone(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *read* resources. /// It is not used directly, but through the `Genomics` hub. /// @@ -3052,25 +3070,6 @@ impl<'a, C, A> MethodsBuilder for ReadgroupsetMethods<'a, C, A> {} impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { - /// Create a builder to help you perform the following task: - /// - /// Updates a read group set. - /// - /// # Arguments - /// - /// * `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> { - ReadgroupsetUpdateCall { - hub: self.hub, - _request: request.clone(), - _read_group_set_id: read_group_set_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Exports read group sets to a BAM file in Google Cloud Storage. @@ -3090,25 +3089,6 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Creates read group sets by asynchronously importing the provided information. - /// - /// Note that currently comments in the input file header are not imported and some custom tags will be converted to strings, rather than preserving tag types. The caller must have WRITE permissions to the dataset. - /// - /// # Arguments - /// - /// * `request` - No description provided. - pub fn import(&self, request: &ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { - ReadgroupsetImportCall { - hub: self.hub, - _request: request.clone(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Updates a read group set. This method supports patch semantics. @@ -3145,6 +3125,25 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Creates read group sets by asynchronously importing the provided information. + /// + /// Note that currently comments in the input file header are not imported and some custom tags will be converted to strings, rather than preserving tag types. The caller must have WRITE permissions to the dataset. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn import(&self, request: &ImportReadGroupSetsRequest) -> ReadgroupsetImportCall<'a, C, A> { + ReadgroupsetImportCall { + hub: self.hub, + _request: request.clone(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Aligns read data from existing read group sets or files from Google Cloud Storage. See the alignment and variant calling documentation for more details. @@ -3162,6 +3161,42 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Gets a read group set by ID. + /// + /// # Arguments + /// + /// * `readGroupSetId` - The ID of the read group set. + pub fn get(&self, read_group_set_id: &str) -> ReadgroupsetGetCall<'a, C, A> { + ReadgroupsetGetCall { + hub: self.hub, + _read_group_set_id: read_group_set_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates a read group set. + /// + /// # Arguments + /// + /// * `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> { + ReadgroupsetUpdateCall { + hub: self.hub, + _request: request.clone(), + _read_group_set_id: read_group_set_id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Lists fixed width coverage buckets for a read group set, each of which correspond to a range of a reference sequence. Each bucket summarizes coverage information across its corresponding genomic range. @@ -3222,23 +3257,6 @@ impl<'a, C, A> ReadgroupsetMethods<'a, C, A> { _additional_params: Default::default(), } } - - /// Create a builder to help you perform the following task: - /// - /// Gets a read group set by ID. - /// - /// # Arguments - /// - /// * `readGroupSetId` - The ID of the read group set. - pub fn get(&self, read_group_set_id: &str) -> ReadgroupsetGetCall<'a, C, A> { - ReadgroupsetGetCall { - hub: self.hub, - _read_group_set_id: read_group_set_id.to_string(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } } @@ -3662,14 +3680,14 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. This method supports patch semantics. + /// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. /// /// # Arguments /// /// * `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> { - AnnotationPatchCall { + pub fn update(&self, request: &Annotation, annotation_id: &str) -> AnnotationUpdateCall<'a, C, A> { + AnnotationUpdateCall { hub: self.hub, _request: request.clone(), _annotation_id: annotation_id.to_string(), @@ -3681,16 +3699,14 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. + /// Gets an annotation. Caller must have READ permission for the associated annotation set. /// /// # Arguments /// - /// * `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> { - AnnotationUpdateCall { + /// * `annotationId` - The ID of the annotation set to be retrieved. + pub fn get(&self, annotation_id: &str) -> AnnotationGetCall<'a, C, A> { + AnnotationGetCall { hub: self.hub, - _request: request.clone(), _annotation_id: annotation_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -3734,14 +3750,16 @@ impl<'a, C, A> AnnotationMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// - /// Gets an annotation. Caller must have READ permission for the associated annotation set. + /// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. This method supports patch semantics. /// /// # Arguments /// - /// * `annotationId` - The ID of the annotation set to be retrieved. - pub fn get(&self, annotation_id: &str) -> AnnotationGetCall<'a, C, A> { - AnnotationGetCall { + /// * `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> { + AnnotationPatchCall { hub: self.hub, + _request: request.clone(), _annotation_id: annotation_id.to_string(), _delegate: Default::default(), _scopes: Default::default(), @@ -4046,224 +4064,6 @@ impl<'a, C, A> VariantsetMethods<'a, C, A> { // CallBuilders ### // ################# -/// Creates a new dataset. -/// -/// A builder for the *create* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// use genomics1_beta2::Dataset; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::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().create(&req) -/// .doit(); -/// # } -/// ``` -pub struct DatasetCreateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _request: Dataset, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for DatasetCreateCall<'a, C, A> {} - -impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Dataset)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.datasets.create", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/datasets".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetCreateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> DatasetCreateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> DatasetCreateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates a dataset. /// /// A builder for the *update* method supported by a *dataset* resource. @@ -4291,7 +4091,7 @@ impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4383,16 +4183,20 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4518,6 +4322,228 @@ impl<'a, C, A> DatasetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Creates a new dataset. +/// +/// A builder for the *create* method supported by a *dataset* resource. +/// It is not used directly, but through a `DatasetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// use genomics1_beta2::Dataset; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Dataset::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().create(&req) +/// .doit(); +/// # } +/// ``` +pub struct DatasetCreateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _request: Dataset, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for DatasetCreateCall<'a, C, A> {} + +impl<'a, C, A> DatasetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Dataset)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.datasets.create", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + for &field in ["alt"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/datasets".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetCreateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> DatasetCreateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> DatasetCreateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Deletes a dataset. /// /// A builder for the *delete* method supported by a *dataset* resource. @@ -4625,16 +4651,20 @@ impl<'a, C, A> DatasetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4845,16 +4875,20 @@ impl<'a, C, A> DatasetUndeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5075,16 +5109,20 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5197,6 +5235,240 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } +/// Lists datasets within a project. +/// +/// A builder for the *list* method supported by a *dataset* resource. +/// It is not used directly, but through a `DatasetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list() +/// .project_number("accusam") +/// .page_token("takimata") +/// .page_size(-70) +/// .doit(); +/// # } +/// ``` +pub struct DatasetListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _project_number: Option<String>, + _page_token: Option<String>, + _page_size: Option<i32>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for DatasetListCall<'a, C, A> {} + +impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ListDatasetsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.datasets.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + if let Some(value) = self._project_number { + params.push(("projectNumber", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._page_size { + params.push(("pageSize", value.to_string())); + } + for &field in ["alt", "projectNumber", "pageToken", "pageSize"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/datasets".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The project to list datasets for. + /// + /// Sets the *project number* query property to the given value. + pub fn project_number(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { + self._project_number = Some(new_value.to_string()); + self + } + /// The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The maximum number of results returned by this request. If unspecified, defaults to 50. + /// + /// Sets the *page size* query property to the given value. + pub fn page_size(mut self, new_value: i32) -> DatasetListCall<'a, C, A> { + self._page_size = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> DatasetListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Readonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> DatasetListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates a dataset. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *dataset* resource. @@ -5224,7 +5496,7 @@ impl<'a, C, A> DatasetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Dataset = Default::default(); +/// let mut req = Dataset::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5316,16 +5588,20 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5451,236 +5727,6 @@ impl<'a, C, A> DatasetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } -/// Lists datasets within a project. -/// -/// A builder for the *list* method supported by a *dataset* resource. -/// It is not used directly, but through a `DatasetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().list() -/// .project_number("takimata") -/// .page_token("justo") -/// .page_size(-1) -/// .doit(); -/// # } -/// ``` -pub struct DatasetListCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _project_number: Option<String>, - _page_token: Option<String>, - _page_size: Option<i32>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for DatasetListCall<'a, C, A> {} - -impl<'a, C, A> DatasetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ListDatasetsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.datasets.list", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); - if let Some(value) = self._project_number { - params.push(("projectNumber", value.to_string())); - } - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._page_size { - params.push(("pageSize", value.to_string())); - } - for &field in ["alt", "projectNumber", "pageToken", "pageSize"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/datasets".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The project to list datasets for. - /// - /// Sets the *project number* query property to the given value. - pub fn project_number(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { - self._project_number = Some(new_value.to_string()); - self - } - /// The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> DatasetListCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// The maximum number of results returned by this request. If unspecified, defaults to 50. - /// - /// Sets the *page size* query property to the given value. - pub fn page_size(mut self, new_value: i32) -> DatasetListCall<'a, C, A> { - self._page_size = Some(new_value); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> DatasetListCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> DatasetListCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> DatasetListCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Cancels a job by ID. Note that it is possible for partial results to be generated and stored for cancelled jobs. /// /// A builder for the *cancel* method supported by a *job* resource. @@ -5788,16 +5834,20 @@ impl<'a, C, A> JobCancelCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6008,16 +6058,20 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6157,7 +6211,7 @@ impl<'a, C, A> JobGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchJobsRequest = Default::default(); +/// let mut req = SearchJobsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6223,16 +6277,20 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6377,7 +6435,7 @@ impl<'a, C, A> JobSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchReferenceSetsRequest = Default::default(); +/// let mut req = SearchReferenceSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6443,16 +6501,20 @@ impl<'a, C, A> ReferencesetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6678,16 +6740,20 @@ impl<'a, C, A> ReferencesetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6800,205 +6866,6 @@ impl<'a, C, A> ReferencesetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, } -/// Returns a stream of all the variants matching the search request, ordered by reference name, position, and ID. -/// -/// A builder for the *streamvariants* method supported by a *streamingVariantStore* resource. -/// It is not used directly, but through a `StreamingVariantStoreMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// use genomics1_beta2::StreamVariantsRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: StreamVariantsRequest = Default::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.streaming_variant_store().streamvariants(&req) -/// .doit(); -/// # } -/// ``` -pub struct StreamingVariantStoreStreamvariantCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _request: StreamVariantsRequest, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, -} - -impl<'a, C, A> CallBuilder for StreamingVariantStoreStreamvariantCall<'a, C, A> {} - -impl<'a, C, A> StreamingVariantStoreStreamvariantCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Variant)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.streamingVariantStore.streamvariants", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/streamingVariantStore/streamvariants".to_string(); - - let mut key = self.hub.auth.borrow_mut().api_key(); - if key.is_none() { - key = dlg.api_key(); - } - match key { - Some(value) => params.push(("key", value)), - None => { - dlg.finished(false); - return Err(Error::MissingAPIKey) - } - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn request(mut self, new_value: &StreamVariantsRequest) -> StreamingVariantStoreStreamvariantCall<'a, C, A> { - self._request = new_value.clone(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> StreamingVariantStoreStreamvariantCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> StreamingVariantStoreStreamvariantCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - -} - - /// Deletes a call set. /// /// A builder for the *delete* method supported by a *callset* resource. @@ -7106,16 +6973,20 @@ impl<'a, C, A> CallsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7247,7 +7118,7 @@ impl<'a, C, A> CallsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchCallSetsRequest = Default::default(); +/// let mut req = SearchCallSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7313,16 +7184,20 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7465,7 +7340,7 @@ impl<'a, C, A> CallsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CallSet = Default::default(); +/// let mut req = CallSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7557,16 +7432,20 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7719,7 +7598,7 @@ impl<'a, C, A> CallsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CallSet = Default::default(); +/// let mut req = CallSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7785,16 +7664,20 @@ impl<'a, C, A> CallsetCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8018,16 +7901,20 @@ impl<'a, C, A> CallsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8167,7 +8054,7 @@ impl<'a, C, A> CallsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CallSet = Default::default(); +/// let mut req = CallSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8259,16 +8146,20 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8394,6 +8285,209 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Gets a stream of reads for one or more read group sets. Reads search operates over a genomic coordinate space of reference sequence & position defined over the reference sequences to which the requested read group sets are aligned. +/// +/// If a target positional range is specified, all reads whose alignment to the reference genome overlap the range are returned. +/// +/// All reads returned are ordered by genomic coordinate (reference sequence & position). Reads with equivalent genomic coordinates are returned in a deterministic order. +/// +/// A builder for the *streamreads* method supported by a *streamingReadstore* resource. +/// It is not used directly, but through a `StreamingReadstoreMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// use genomics1_beta2::StreamReadsRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = StreamReadsRequest::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.streaming_readstore().streamreads(&req) +/// .doit(); +/// # } +/// ``` +pub struct StreamingReadstoreStreamreadCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _request: StreamReadsRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, +} + +impl<'a, C, A> CallBuilder for StreamingReadstoreStreamreadCall<'a, C, A> {} + +impl<'a, C, A> StreamingReadstoreStreamreadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, StreamReadsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.streamingReadstore.streamreads", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + for &field in ["alt"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/streamingReadstore/streamreads".to_string(); + + let mut key = self.hub.auth.borrow_mut().api_key(); + if key.is_none() { + key = dlg.api_key(); + } + match key { + Some(value) => params.push(("key", value)), + None => { + dlg.finished(false); + return Err(Error::MissingAPIKey) + } + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> StreamingReadstoreStreamreadCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> StreamingReadstoreStreamreadCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + /// Gets a list of reads for one or more read group sets. Reads search operates over a genomic coordinate space of reference sequence & position defined over the reference sequences to which the requested read group sets are aligned. /// /// If a target positional range is specified, search returns all reads whose alignment to the reference genome overlap the range. A query which specifies only read group set IDs yields all reads in those read group sets, including unmapped reads. @@ -8427,7 +8521,7 @@ impl<'a, C, A> CallsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchReadsRequest = Default::default(); +/// let mut req = SearchReadsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8493,16 +8587,20 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8618,260 +8716,6 @@ impl<'a, C, A> ReadSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa } -/// Updates a read group set. -/// -/// A builder for the *update* method supported by a *readgroupset* resource. -/// It is not used directly, but through a `ReadgroupsetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// use genomics1_beta2::ReadGroupSet; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: ReadGroupSet = Default::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.readgroupsets().update(&req, "readGroupSetId") -/// .doit(); -/// # } -/// ``` -pub struct ReadgroupsetUpdateCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _request: ReadGroupSet, - _read_group_set_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReadgroupsetUpdateCall<'a, C, A> {} - -impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ReadGroupSet)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.readgroupsets.update", - http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("readGroupSetId", self._read_group_set_id.to_string())); - for &field in ["alt", "readGroupSetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/{readGroupSetId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{readGroupSetId}", "readGroupSetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["readGroupSetId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - 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. - /// - /// Sets the *read group set id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn read_group_set_id(mut self, new_value: &str) -> ReadgroupsetUpdateCall<'a, C, A> { - self._read_group_set_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetUpdateCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetUpdateCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetUpdateCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Exports read group sets to a BAM file in Google Cloud Storage. /// /// Note that currently there may be some differences between exported BAM files and the original BAM file at the time of import. In particular, comments in the input file header will not be preserved, some custom tags will be converted to strings, and original reference sequence order is not necessarily preserved. @@ -8901,7 +8745,7 @@ impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ExportReadGroupSetsRequest = Default::default(); +/// let mut req = ExportReadGroupSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8967,16 +8811,20 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9092,226 +8940,6 @@ impl<'a, C, A> ReadgroupsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client } -/// Creates read group sets by asynchronously importing the provided information. -/// -/// Note that currently comments in the input file header are not imported and some custom tags will be converted to strings, rather than preserving tag types. The caller must have WRITE permissions to the dataset. -/// -/// A builder for the *import* method supported by a *readgroupset* resource. -/// It is not used directly, but through a `ReadgroupsetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// use genomics1_beta2::ImportReadGroupSetsRequest; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: ImportReadGroupSetsRequest = Default::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.readgroupsets().import(&req) -/// .doit(); -/// # } -/// ``` -pub struct ReadgroupsetImportCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _request: ImportReadGroupSetsRequest, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReadgroupsetImportCall<'a, C, A> {} - -impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ImportReadGroupSetsResponse)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.readgroupsets.import", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - for &field in ["alt"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/import".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::DevstorageReadWrite.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetImportCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetImportCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::DevstorageReadWrite`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetImportCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates a read group set. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *readgroupset* resource. @@ -9339,7 +8967,7 @@ impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ReadGroupSet = Default::default(); +/// let mut req = ReadGroupSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9431,16 +9059,20 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9593,7 +9225,7 @@ impl<'a, C, A> ReadgroupsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CallReadGroupSetsRequest = Default::default(); +/// let mut req = CallReadGroupSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9659,16 +9291,20 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9784,6 +9420,230 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, } +/// Creates read group sets by asynchronously importing the provided information. +/// +/// Note that currently comments in the input file header are not imported and some custom tags will be converted to strings, rather than preserving tag types. The caller must have WRITE permissions to the dataset. +/// +/// A builder for the *import* method supported by a *readgroupset* resource. +/// It is not used directly, but through a `ReadgroupsetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// use genomics1_beta2::ImportReadGroupSetsRequest; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ImportReadGroupSetsRequest::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.readgroupsets().import(&req) +/// .doit(); +/// # } +/// ``` +pub struct ReadgroupsetImportCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _request: ImportReadGroupSetsRequest, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReadgroupsetImportCall<'a, C, A> {} + +impl<'a, C, A> ReadgroupsetImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ImportReadGroupSetsResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.readgroupsets.import", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + for &field in ["alt"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/import".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::DevstorageReadWrite.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetImportCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetImportCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::DevstorageReadWrite`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetImportCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Aligns read data from existing read group sets or files from Google Cloud Storage. See the alignment and variant calling documentation for more details. /// /// A builder for the *align* method supported by a *readgroupset* resource. @@ -9811,7 +9671,7 @@ impl<'a, C, A> ReadgroupsetCallCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AlignReadGroupSetsRequest = Default::default(); +/// let mut req = AlignReadGroupSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9877,16 +9737,20 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10002,6 +9866,498 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> } +/// Gets a read group set by ID. +/// +/// A builder for the *get* method supported by a *readgroupset* resource. +/// It is not used directly, but through a `ReadgroupsetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("readGroupSetId") +/// .doit(); +/// # } +/// ``` +pub struct ReadgroupsetGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _read_group_set_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReadgroupsetGetCall<'a, C, A> {} + +impl<'a, C, A> ReadgroupsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ReadGroupSet)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.readgroupsets.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("readGroupSetId", self._read_group_set_id.to_string())); + for &field in ["alt", "readGroupSetId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/{readGroupSetId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{readGroupSetId}", "readGroupSetId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["readGroupSetId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The ID of the read group set. + /// + /// Sets the *read group set id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn read_group_set_id(mut self, new_value: &str) -> ReadgroupsetGetCall<'a, C, A> { + self._read_group_set_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Readonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Updates a read group set. +/// +/// A builder for the *update* method supported by a *readgroupset* resource. +/// It is not used directly, but through a `ReadgroupsetMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// use genomics1_beta2::ReadGroupSet; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ReadGroupSet::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.readgroupsets().update(&req, "readGroupSetId") +/// .doit(); +/// # } +/// ``` +pub struct ReadgroupsetUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _request: ReadGroupSet, + _read_group_set_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ReadgroupsetUpdateCall<'a, C, A> {} + +impl<'a, C, A> ReadgroupsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ReadGroupSet)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.readgroupsets.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("readGroupSetId", self._read_group_set_id.to_string())); + for &field in ["alt", "readGroupSetId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/{readGroupSetId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{readGroupSetId}", "readGroupSetId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["readGroupSetId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + 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. + /// + /// Sets the *read group set id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn read_group_set_id(mut self, new_value: &str) -> ReadgroupsetUpdateCall<'a, C, A> { + self._read_group_set_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Lists fixed width coverage buckets for a read group set, each of which correspond to a range of a reference sequence. Each bucket summarizes coverage information across its corresponding genomic range. /// /// Coverage is defined as the number of reads which are aligned to a given base in the reference sequence. Coverage buckets are available at several precomputed bucket widths, enabling retrieval of various coverage 'zoom levels'. The caller must have READ permissions for the target read group set. @@ -10032,11 +10388,11 @@ impl<'a, C, A> ReadgroupsetAlignCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // Values shown here are possibly random and not representative ! /// let result = hub.readgroupsets().coveragebuckets_list("readGroupSetId") /// .target_bucket_width("justo") -/// .range_start("justo") +/// .range_start("et") /// .range_reference_name("et") -/// .range_end("et") -/// .page_token("diam") -/// .page_size(-55) +/// .range_end("diam") +/// .page_token("ipsum") +/// .page_size(-5) /// .doit(); /// # } /// ``` @@ -10142,16 +10498,20 @@ impl<'a, C, A> ReadgroupsetCoveragebucketListCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10413,16 +10773,20 @@ impl<'a, C, A> ReadgroupsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10554,7 +10918,7 @@ impl<'a, C, A> ReadgroupsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchReadGroupSetsRequest = Default::default(); +/// let mut req = SearchReadGroupSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10620,16 +10984,20 @@ impl<'a, C, A> ReadgroupsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10745,236 +11113,6 @@ impl<'a, C, A> ReadgroupsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client } -/// Gets a read group set by ID. -/// -/// A builder for the *get* method supported by a *readgroupset* resource. -/// It is not used directly, but through a `ReadgroupsetMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("readGroupSetId") -/// .doit(); -/// # } -/// ``` -pub struct ReadgroupsetGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _read_group_set_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ReadgroupsetGetCall<'a, C, A> {} - -impl<'a, C, A> ReadgroupsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ReadGroupSet)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.readgroupsets.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); - params.push(("readGroupSetId", self._read_group_set_id.to_string())); - for &field in ["alt", "readGroupSetId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/readgroupsets/{readGroupSetId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{readGroupSetId}", "readGroupSetId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["readGroupSetId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The ID of the read group set. - /// - /// Sets the *read group set id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn read_group_set_id(mut self, new_value: &str) -> ReadgroupsetGetCall<'a, C, A> { - self._read_group_set_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReadgroupsetGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ReadgroupsetGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ReadgroupsetGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Lists the bases in a reference, optionally restricted to a range. /// /// Implements GlobalAllianceApi.getReferenceBases. @@ -11105,16 +11243,20 @@ impl<'a, C, A> ReferenceBaseListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11284,7 +11426,7 @@ impl<'a, C, A> ReferenceBaseListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchReferencesRequest = Default::default(); +/// let mut req = SearchReferencesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11350,16 +11492,20 @@ impl<'a, C, A> ReferenceSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11585,16 +11731,20 @@ impl<'a, C, A> ReferenceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11815,16 +11965,20 @@ impl<'a, C, A> AnnotationSetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11964,7 +12118,7 @@ impl<'a, C, A> AnnotationSetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AnnotationSet = Default::default(); +/// let mut req = AnnotationSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12056,16 +12210,20 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12218,7 +12376,7 @@ impl<'a, C, A> AnnotationSetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AnnotationSet = Default::default(); +/// let mut req = AnnotationSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12284,16 +12442,20 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12436,7 +12598,7 @@ impl<'a, C, A> AnnotationSetCreateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchAnnotationSetsRequest = Default::default(); +/// let mut req = SearchAnnotationSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12502,16 +12664,20 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12654,7 +12820,7 @@ impl<'a, C, A> AnnotationSetSearchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AnnotationSet = Default::default(); +/// let mut req = AnnotationSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12746,16 +12912,20 @@ impl<'a, C, A> AnnotationSetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12988,16 +13158,20 @@ impl<'a, C, A> AnnotationSetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13129,7 +13303,7 @@ impl<'a, C, A> AnnotationSetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchVariantsRequest = Default::default(); +/// let mut req = SearchVariantsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13195,16 +13369,20 @@ impl<'a, C, A> VariantSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13427,16 +13605,20 @@ impl<'a, C, A> VariantDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13647,16 +13829,20 @@ impl<'a, C, A> VariantGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13796,7 +13982,7 @@ impl<'a, C, A> VariantGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Variant = Default::default(); +/// let mut req = Variant::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13862,16 +14048,20 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14014,7 +14204,7 @@ impl<'a, C, A> VariantCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Variant = Default::default(); +/// let mut req = Variant::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14106,16 +14296,20 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14241,260 +14435,6 @@ impl<'a, C, A> VariantUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } -/// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. This method supports patch semantics. -/// -/// A builder for the *patch* method supported by a *annotation* resource. -/// It is not used directly, but through a `AnnotationMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_genomics1_beta2 as genomics1_beta2; -/// use genomics1_beta2::Annotation; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use genomics1_beta2::Genomics; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Genomics::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Annotation = Default::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") -/// .doit(); -/// # } -/// ``` -pub struct AnnotationPatchCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Genomics<C, A>, - _request: Annotation, - _annotation_id: String, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for AnnotationPatchCall<'a, C, A> {} - -impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Annotation)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "genomics.annotations.patch", - http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); - params.push(("annotationId", self._annotation_id.to_string())); - for &field in ["alt", "annotationId"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/genomics/v1beta2/annotations/{annotationId}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{annotationId}", "annotationId")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["annotationId"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// The ID of the annotation set to be updated. - /// - /// Sets the *annotation id* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn annotation_id(mut self, new_value: &str) -> AnnotationPatchCall<'a, C, A> { - self._annotation_id = new_value.to_string(); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AnnotationPatchCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AnnotationPatchCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AnnotationPatchCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. /// /// A builder for the *update* method supported by a *annotation* resource. @@ -14522,7 +14462,7 @@ impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Annotation = Default::default(); +/// let mut req = Annotation::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14614,16 +14554,20 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14749,6 +14693,240 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, } +/// Gets an annotation. Caller must have READ permission for the associated annotation set. +/// +/// A builder for the *get* method supported by a *annotation* resource. +/// It is not used directly, but through a `AnnotationMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use genomics1_beta2::Genomics; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("annotationId") +/// .doit(); +/// # } +/// ``` +pub struct AnnotationGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Genomics<C, A>, + _annotation_id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for AnnotationGetCall<'a, C, A> {} + +impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Annotation)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "genomics.annotations.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + params.push(("annotationId", self._annotation_id.to_string())); + for &field in ["alt", "annotationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/genomics/v1beta2/annotations/{annotationId}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{annotationId}", "annotationId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["annotationId"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The ID of the annotation set to be retrieved. + /// + /// Sets the *annotation id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn annotation_id(mut self, new_value: &str) -> AnnotationGetCall<'a, C, A> { + self._annotation_id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AnnotationGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> AnnotationGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Readonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> AnnotationGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Searches for annotations that match the given criteria. Results are returned ordered by start position. Annotations that have matching start positions are ordered deterministically. Caller must have READ permission for the queried annotation sets. /// /// A builder for the *search* method supported by a *annotation* resource. @@ -14776,7 +14954,7 @@ impl<'a, C, A> AnnotationUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchAnnotationsRequest = Default::default(); +/// let mut req = SearchAnnotationsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14842,16 +15020,20 @@ impl<'a, C, A> AnnotationSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15074,16 +15256,20 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -15186,9 +15372,9 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, } -/// Gets an annotation. Caller must have READ permission for the associated annotation set. +/// Updates an annotation. The update must respect all mutability restrictions and other invariants described on the annotation resource. Caller must have WRITE permission for the associated dataset. This method supports patch semantics. /// -/// A builder for the *get* method supported by a *annotation* resource. +/// A builder for the *patch* method supported by a *annotation* resource. /// It is not used directly, but through a `AnnotationMethods` instance. /// /// # Example @@ -15199,6 +15385,7 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_genomics1_beta2 as genomics1_beta2; +/// use genomics1_beta2::Annotation; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -15209,26 +15396,32 @@ impl<'a, C, A> AnnotationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// # hyper::Client::new(), /// # <MemoryStorage as Default>::default(), None); /// # let mut hub = Genomics::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// 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().get("annotationId") +/// let result = hub.annotations().patch(&req, "annotationId") /// .doit(); /// # } /// ``` -pub struct AnnotationGetCall<'a, C, A> +pub struct AnnotationPatchCall<'a, C, A> where C: 'a, A: 'a { hub: &'a Genomics<C, A>, + _request: Annotation, _annotation_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> } -impl<'a, C, A> CallBuilder for AnnotationGetCall<'a, C, A> {} +impl<'a, C, A> CallBuilder for AnnotationPatchCall<'a, C, A> {} -impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { +impl<'a, C, A> AnnotationPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { /// Perform the operation you have build so far. @@ -15240,9 +15433,9 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: Some(d) => d, None => &mut dd }; - dlg.begin(MethodInfo { id: "genomics.annotations.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + dlg.begin(MethodInfo { id: "genomics.annotations.patch", + http_method: hyper::method::Method::Patch }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); params.push(("annotationId", self._annotation_id.to_string())); for &field in ["alt", "annotationId"].iter() { if self._additional_params.contains_key(field) { @@ -15258,7 +15451,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut url = "https://www.googleapis.com/genomics/v1beta2/annotations/{annotationId}".to_string(); if self._scopes.len() == 0 { - self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{annotationId}", "annotationId")].iter() { @@ -15291,24 +15484,36 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); } + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref()) .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); dlg.pre_request(); req.send() @@ -15354,13 +15559,22 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } - /// The ID of the annotation set to be retrieved. + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// The ID of the annotation set to be updated. /// /// Sets the *annotation id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. - pub fn annotation_id(mut self, new_value: &str) -> AnnotationGetCall<'a, C, A> { + pub fn annotation_id(mut self, new_value: &str) -> AnnotationPatchCall<'a, C, A> { self._annotation_id = new_value.to_string(); self } @@ -15370,7 +15584,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> AnnotationGetCall<'a, C, A> { + pub fn delegate(mut self, new_value: &'a mut Delegate) -> AnnotationPatchCall<'a, C, A> { self._delegate = Some(new_value); self } @@ -15391,7 +15605,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> AnnotationGetCall<'a, C, A> + pub fn param<T>(mut self, name: T, value: T) -> AnnotationPatchCall<'a, C, A> where T: AsRef<str> { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self @@ -15400,7 +15614,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Readonly`. + /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. @@ -15408,7 +15622,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> AnnotationGetCall<'a, C, A> + pub fn add_scope<T>(mut self, scope: T) -> AnnotationPatchCall<'a, C, A> where T: AsRef<str> { self._scopes.insert(scope.as_ref().to_string(), ()); self @@ -15443,7 +15657,7 @@ impl<'a, C, A> AnnotationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Annotation = Default::default(); +/// let mut req = Annotation::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15509,16 +15723,20 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15664,7 +15882,7 @@ impl<'a, C, A> AnnotationCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BatchCreateAnnotationsRequest = Default::default(); +/// let mut req = BatchCreateAnnotationsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15730,16 +15948,20 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15882,7 +16104,7 @@ impl<'a, C, A> AnnotationBatchCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ExperimentalCreateJobRequest = Default::default(); +/// let mut req = ExperimentalCreateJobRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15948,16 +16170,20 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16100,7 +16326,7 @@ impl<'a, C, A> ExperimentalJobCreateCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: VariantSet = Default::default(); +/// let mut req = VariantSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16192,16 +16418,20 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16354,7 +16584,7 @@ impl<'a, C, A> VariantsetUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ExportVariantSetRequest = Default::default(); +/// let mut req = ExportVariantSetRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16446,16 +16676,20 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16608,7 +16842,7 @@ impl<'a, C, A> VariantsetExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: VariantSet = Default::default(); +/// let mut req = VariantSet::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16700,16 +16934,20 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16864,7 +17102,7 @@ impl<'a, C, A> VariantsetPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SearchVariantSetsRequest = Default::default(); +/// let mut req = SearchVariantSetsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16930,16 +17168,20 @@ impl<'a, C, A> VariantsetSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17163,16 +17405,20 @@ impl<'a, C, A> VariantsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17314,7 +17560,7 @@ impl<'a, C, A> VariantsetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: MergeVariantsRequest = Default::default(); +/// let mut req = MergeVariantsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17405,16 +17651,20 @@ impl<'a, C, A> VariantsetMergeVariantCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17637,16 +17887,20 @@ impl<'a, C, A> VariantsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -17778,7 +18032,7 @@ impl<'a, C, A> VariantsetDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ImportVariantsRequest = Default::default(); +/// let mut req = ImportVariantsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17870,16 +18124,20 @@ impl<'a, C, A> VariantsetImportVariantCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/gmail1-cli/Cargo.toml b/gen/gmail1-cli/Cargo.toml index e5c1156803..dd6bd70e21 100644 --- a/gen/gmail1-cli/Cargo.toml +++ b/gen/gmail1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-gmail1-cli" version = "0.0.1+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/gmail/api/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/gmail1-cli/src/cmn.rs b/gen/gmail1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/gmail1-cli/src/cmn.rs +++ b/gen/gmail1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/gmail1-cli/src/main.rs b/gen/gmail1-cli/src/main.rs index 7c1b6ba7ce..ae217387e7 100644 --- a/gen/gmail1-cli/src/main.rs +++ b/gen/gmail1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -61,6 +62,12 @@ Configuration: 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. "); mod cmn; @@ -82,10 +89,10 @@ struct Engine { impl Engine { fn _users_drafts_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Draft = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -105,9 +112,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -117,6 +125,13 @@ impl Engine { } } + fn request_message_payload_body_init(request: &mut api::Draft) { + request_message_payload_init(request); + if request.message.as_mut().unwrap().payload.as_mut().unwrap().body.is_none() { + request.message.as_mut().unwrap().payload.as_mut().unwrap().body = Some(Default::default()); + } + } + fn request_message_payload_init(request: &mut api::Draft) { request_message_init(request); if request.message.as_mut().unwrap().payload.is_none() { @@ -130,28 +145,28 @@ impl Engine { request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.data" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); }, "message.payload.body.attachment-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().attachment_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.size" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer"); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().size = Some(arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer")); }, "message.payload.mime-type" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "message.payload.part-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "message.payload.filename" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "message.snippet" => { request_message_payload_init(&mut request); @@ -172,9 +187,9 @@ impl Engine { "message.label-ids" => { request_message_payload_init(&mut request); if request.message.as_mut().unwrap().label_ids.is_none() { - request.message.as_mut().unwrap().label_ids = Some(Default::default()); + request.message.as_mut().unwrap().label_ids = Some(Default::default()); } - request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "message.id" => { request_message_payload_init(&mut request); @@ -211,8 +226,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -223,7 +237,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().drafts_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -254,7 +268,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -265,7 +278,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().drafts_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "format" => { call = call.format(value.unwrap_or("")); @@ -300,8 +313,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -312,7 +324,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().drafts_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -350,8 +362,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -360,10 +371,10 @@ impl Engine { fn _users_drafts_send(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Draft = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -383,9 +394,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -395,6 +407,13 @@ impl Engine { } } + fn request_message_payload_body_init(request: &mut api::Draft) { + request_message_payload_init(request); + if request.message.as_mut().unwrap().payload.as_mut().unwrap().body.is_none() { + request.message.as_mut().unwrap().payload.as_mut().unwrap().body = Some(Default::default()); + } + } + fn request_message_payload_init(request: &mut api::Draft) { request_message_init(request); if request.message.as_mut().unwrap().payload.is_none() { @@ -408,28 +427,28 @@ impl Engine { request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.data" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); }, "message.payload.body.attachment-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().attachment_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.size" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer"); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().size = Some(arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer")); }, "message.payload.mime-type" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "message.payload.part-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "message.payload.filename" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "message.snippet" => { request_message_payload_init(&mut request); @@ -450,9 +469,9 @@ impl Engine { "message.label-ids" => { request_message_payload_init(&mut request); if request.message.as_mut().unwrap().label_ids.is_none() { - request.message.as_mut().unwrap().label_ids = Some(Default::default()); + request.message.as_mut().unwrap().label_ids = Some(Default::default()); } - request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "message.id" => { request_message_payload_init(&mut request); @@ -489,8 +508,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -499,10 +517,10 @@ impl Engine { fn _users_drafts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Draft = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -522,9 +540,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -534,6 +553,13 @@ impl Engine { } } + fn request_message_payload_body_init(request: &mut api::Draft) { + request_message_payload_init(request); + if request.message.as_mut().unwrap().payload.as_mut().unwrap().body.is_none() { + request.message.as_mut().unwrap().payload.as_mut().unwrap().body = Some(Default::default()); + } + } + fn request_message_payload_init(request: &mut api::Draft) { request_message_init(request); if request.message.as_mut().unwrap().payload.is_none() { @@ -547,28 +573,28 @@ impl Engine { request.message.as_mut().unwrap().history_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.data" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().data = Some(value.unwrap_or("").to_string()); }, "message.payload.body.attachment-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().attachment_id = Some(value.unwrap_or("").to_string()); }, "message.payload.body.size" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer"); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().body.as_mut().unwrap().size = Some(arg_from_str(value.unwrap_or("-0"), err, "message.payload.body.size", "integer")); }, "message.payload.mime-type" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "message.payload.part-id" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "message.payload.filename" => { - request_message_payload_init(&mut request); - request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_message_payload_body_init(&mut request); + request.message.as_mut().unwrap().payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "message.snippet" => { request_message_payload_init(&mut request); @@ -589,9 +615,9 @@ impl Engine { "message.label-ids" => { request_message_payload_init(&mut request); if request.message.as_mut().unwrap().label_ids.is_none() { - request.message.as_mut().unwrap().label_ids = Some(Default::default()); + request.message.as_mut().unwrap().label_ids = Some(Default::default()); } - request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.message.as_mut().unwrap().label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "message.id" => { request_message_payload_init(&mut request); @@ -628,8 +654,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -640,7 +665,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().get_profile(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -672,8 +697,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -684,7 +708,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().history_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-history-id" => { call = call.start_history_id(value.unwrap_or("")); @@ -728,8 +752,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -738,10 +761,10 @@ impl Engine { fn _users_labels_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Label = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -761,9 +784,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -812,8 +836,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -824,7 +847,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().labels_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -855,7 +878,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -866,7 +888,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().labels_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -898,8 +920,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -910,7 +931,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().labels_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -942,8 +963,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -952,10 +972,10 @@ impl Engine { fn _users_labels_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Label = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -975,9 +995,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1026,8 +1047,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1036,10 +1056,10 @@ impl Engine { fn _users_labels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Label = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1059,9 +1079,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1110,8 +1131,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1122,7 +1142,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_attachments_get(&self.opt.arg_user_id, &self.opt.arg_message_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1154,8 +1174,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1166,7 +1185,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1197,7 +1216,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1208,7 +1226,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "metadata-headers" => { call = call.add_metadata_headers(value.unwrap_or("")); @@ -1246,8 +1264,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1256,10 +1273,10 @@ impl Engine { fn _users_messages_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Message = Default::default(); + let mut request = api::Message::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "process-for-calendar" => { call = call.process_for_calendar(arg_from_str(value.unwrap_or("false"), err, "process-for-calendar", "boolean")); @@ -1291,12 +1308,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); @@ -1308,28 +1333,28 @@ impl Engine { request.history_id = Some(value.unwrap_or("").to_string()); }, "payload.body.data" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "payload.body.size", "integer"); + 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_init(&mut request); - request.payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "payload.part-id" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "payload.filename" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "snippet" => { request_payload_init(&mut request); @@ -1350,9 +1375,9 @@ impl Engine { "label-ids" => { request_payload_init(&mut request); if request.label_ids.is_none() { - request.label_ids = Some(Default::default()); + request.label_ids = Some(Default::default()); } - request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_payload_init(&mut request); @@ -1385,8 +1410,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1395,10 +1419,10 @@ impl Engine { fn _users_messages_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Message = Default::default(); + let mut request = api::Message::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "internal-date-source" => { call = call.internal_date_source(value.unwrap_or("")); @@ -1424,12 +1448,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); @@ -1441,28 +1473,28 @@ impl Engine { request.history_id = Some(value.unwrap_or("").to_string()); }, "payload.body.data" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "payload.body.size", "integer"); + 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_init(&mut request); - request.payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "payload.part-id" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "payload.filename" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "snippet" => { request_payload_init(&mut request); @@ -1483,9 +1515,9 @@ impl Engine { "label-ids" => { request_payload_init(&mut request); if request.label_ids.is_none() { - request.label_ids = Some(Default::default()); + request.label_ids = Some(Default::default()); } - request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_payload_init(&mut request); @@ -1518,8 +1550,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1530,7 +1561,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "q" => { call = call.q(value.unwrap_or("")); @@ -1577,8 +1608,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1587,10 +1617,10 @@ impl Engine { fn _users_messages_modify(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ModifyMessageRequest = Default::default(); + let mut request = api::ModifyMessageRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1610,24 +1640,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1646,8 +1677,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1656,10 +1686,10 @@ impl Engine { fn _users_messages_send(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Message = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1679,12 +1709,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()); @@ -1696,28 +1734,28 @@ impl Engine { request.history_id = Some(value.unwrap_or("").to_string()); }, "payload.body.data" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().body.data = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.attachment_id = value.unwrap_or("").to_string(); + 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_init(&mut request); - request.payload.as_mut().unwrap().body.size = arg_from_str(value.unwrap_or("-0"), err, "payload.body.size", "integer"); + 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_init(&mut request); - request.payload.as_mut().unwrap().mime_type = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().mime_type = Some(value.unwrap_or("").to_string()); }, "payload.part-id" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().part_id = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().part_id = Some(value.unwrap_or("").to_string()); }, "payload.filename" => { - request_payload_init(&mut request); - request.payload.as_mut().unwrap().filename = value.unwrap_or("").to_string(); + request_payload_body_init(&mut request); + request.payload.as_mut().unwrap().filename = Some(value.unwrap_or("").to_string()); }, "snippet" => { request_payload_init(&mut request); @@ -1738,9 +1776,9 @@ impl Engine { "label-ids" => { request_payload_init(&mut request); if request.label_ids.is_none() { - request.label_ids = Some(Default::default()); + request.label_ids = Some(Default::default()); } - request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_payload_init(&mut request); @@ -1773,8 +1811,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1785,7 +1822,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_trash(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1817,8 +1854,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1829,7 +1865,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().messages_untrash(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1861,8 +1897,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1873,7 +1908,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().threads_delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1904,7 +1939,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1915,7 +1949,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().threads_get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "metadata-headers" => { call = call.add_metadata_headers(value.unwrap_or("")); @@ -1953,8 +1987,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1965,7 +1998,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().threads_list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "q" => { call = call.q(value.unwrap_or("")); @@ -2012,8 +2045,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2022,10 +2054,10 @@ impl Engine { fn _users_threads_modify(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ModifyThreadRequest = Default::default(); + let mut request = api::ModifyThreadRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2045,24 +2077,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.remove_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.add_label_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -2081,8 +2114,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2093,7 +2125,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().threads_trash(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2125,8 +2157,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2137,7 +2168,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().threads_untrash(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2169,8 +2200,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2266,21 +2296,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "gmail1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "gmail1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "gmail1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "gmail1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Gmail::new(hyper::Client::new(), auth), + hub: api::Gmail::new(client, auth), }; match engine._doit(true) { @@ -2300,12 +2346,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/gmail1/Cargo.toml b/gen/gmail1/Cargo.toml index 8bccb9f8ba..98ff204a31 100644 --- a/gen/gmail1/Cargo.toml +++ b/gen/gmail1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-gmail1" version = "0.1.5+20150303" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/gmail/api/" diff --git a/gen/gmail1/README.md b/gen/gmail1/README.md index 0a413b1a7f..c6280528a5 100644 --- a/gen/gmail1/README.md +++ b/gen/gmail1/README.md @@ -110,7 +110,7 @@ let mut hub = Gmail::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Message = Default::default(); +let mut req = Message::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `upload(...)`. diff --git a/gen/gmail1/src/cmn.rs b/gen/gmail1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/gmail1/src/cmn.rs +++ b/gen/gmail1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/gmail1/src/lib.rs b/gen/gmail1/src/lib.rs index f1aa90b2ae..d245f1cf4b 100644 --- a/gen/gmail1/src/lib.rs +++ b/gen/gmail1/src/lib.rs @@ -111,7 +111,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Message = Default::default(); +//! let mut req = Message::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `upload(...)`. @@ -311,7 +311,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Message = Default::default(); +/// let mut req = Message::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -385,9 +385,9 @@ impl<'a, C, A> Gmail<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MessagePartHeader { /// The name of the header before the : separator. For example, To. - pub name: String, + pub name: Option<String>, /// The value of the header after the : separator. For example, someuser@example.com. - pub value: String, + pub value: Option<String>, } impl Part for MessagePartHeader {} @@ -406,11 +406,11 @@ impl Part for MessagePartHeader {} pub struct MessagePartBody { /// When present, contains the ID of an external attachment that can be retrieved in a separate messages.attachments.get request. When not present, the entire content of the message part body is contained in the data field. #[serde(rename="attachmentId")] - pub attachment_id: String, + pub attachment_id: Option<String>, /// The body data of a MIME message part. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment. - pub data: String, + pub data: Option<String>, /// Total number of bytes in the body of the message part. - pub size: i32, + pub size: Option<i32>, } impl ResponseResult for MessagePartBody {} @@ -431,14 +431,14 @@ impl ResponseResult for MessagePartBody {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Thread { /// A short part of the message text. - pub snippet: String, + pub snippet: Option<String>, /// The list of messages in the thread. - pub messages: Vec<Message>, + pub messages: Option<Vec<Message>>, /// The unique ID of the thread. - pub id: String, + pub id: Option<String>, /// The ID of the last history record that modified this thread. #[serde(rename="historyId")] - pub history_id: String, + pub history_id: Option<String>, } impl ResponseResult for Thread {} @@ -451,7 +451,7 @@ impl ResponseResult for Thread {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HistoryMessageAdded { /// no description provided - pub message: Message, + pub message: Option<Message>, } impl Part for HistoryMessageAdded {} @@ -515,12 +515,12 @@ impl ResponseResult for Label {} pub struct ListHistoryResponse { /// Page token to retrieve the next page of results in the list. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The ID of the mailbox's current history record. #[serde(rename="historyId")] - pub history_id: String, + pub history_id: Option<String>, /// List of history records. Any messages contained in the response will typically only have id and threadId fields populated. - pub history: Vec<History>, + pub history: Option<Vec<History>>, } impl ResponseResult for ListHistoryResponse {} @@ -557,19 +557,19 @@ impl ResponseResult for Draft {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MessagePart { /// The message part body for this part, which may be empty for container MIME message parts. - pub body: MessagePartBody, + pub body: Option<MessagePartBody>, /// The MIME type of the message part. #[serde(rename="mimeType")] - pub mime_type: String, + pub mime_type: Option<String>, /// The child MIME message parts of this part. This only applies to container MIME message parts, for example multipart/*. For non- container MIME message part types, such as text/plain, this field is empty. For more information, see RFC 1521. - pub parts: Vec<MessagePart>, + pub parts: Option<Vec<MessagePart>>, /// The immutable ID of the message part. #[serde(rename="partId")] - pub part_id: String, + pub part_id: Option<String>, /// List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To, From, and Subject. - pub headers: Vec<MessagePartHeader>, + pub headers: Option<Vec<MessagePartHeader>>, /// The filename of the attachment. Only present if this message part represents an attachment. - pub filename: String, + pub filename: Option<String>, } impl Part for MessagePart {} @@ -610,12 +610,12 @@ impl RequestValue for ModifyMessageRequest {} pub struct ListDraftsResponse { /// Token to retrieve the next page of results in the list. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Estimated total number of results. #[serde(rename="resultSizeEstimate")] - pub result_size_estimate: u32, + pub result_size_estimate: Option<u32>, /// List of drafts. - pub drafts: Vec<Draft>, + pub drafts: Option<Vec<Draft>>, } impl ResponseResult for ListDraftsResponse {} @@ -628,7 +628,7 @@ impl ResponseResult for ListDraftsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HistoryMessageDeleted { /// no description provided - pub message: Message, + pub message: Option<Message>, } impl Part for HistoryMessageDeleted {} @@ -642,20 +642,20 @@ impl Part for HistoryMessageDeleted {} pub struct History { /// Labels removed from messages in this history record. #[serde(rename="labelsRemoved")] - pub labels_removed: Vec<HistoryLabelRemoved>, + pub labels_removed: Option<Vec<HistoryLabelRemoved>>, /// Messages deleted (not Trashed) from the mailbox in this history record. #[serde(rename="messagesDeleted")] - pub messages_deleted: Vec<HistoryMessageDeleted>, + pub messages_deleted: Option<Vec<HistoryMessageDeleted>>, /// Labels added to messages in this history record. #[serde(rename="labelsAdded")] - pub labels_added: Vec<HistoryLabelAdded>, + pub labels_added: Option<Vec<HistoryLabelAdded>>, /// List of messages changed in this history record. The fields for specific change types, such as messagesAdded may duplicate messages in this field. We recommend using the specific change-type fields instead of this. - pub messages: Vec<Message>, + pub messages: Option<Vec<Message>>, /// The mailbox sequence ID. - pub id: String, + pub id: Option<String>, /// Messages added to the mailbox in this history record. #[serde(rename="messagesAdded")] - pub messages_added: Vec<HistoryMessageAdded>, + pub messages_added: Option<Vec<HistoryMessageAdded>>, } impl Part for History {} @@ -674,16 +674,16 @@ impl Part for History {} pub struct Profile { /// The total number of messages in the mailbox. #[serde(rename="messagesTotal")] - pub messages_total: i32, + pub messages_total: Option<i32>, /// The user's email address. #[serde(rename="emailAddress")] - pub email_address: String, + pub email_address: Option<String>, /// The ID of the mailbox's current history record. #[serde(rename="historyId")] - pub history_id: String, + pub history_id: Option<String>, /// The total number of threads in the mailbox. #[serde(rename="threadsTotal")] - pub threads_total: i32, + pub threads_total: Option<i32>, } impl ResponseResult for Profile {} @@ -697,9 +697,9 @@ impl ResponseResult for Profile {} pub struct HistoryLabelAdded { /// Label IDs added to the message. #[serde(rename="labelIds")] - pub label_ids: Vec<String>, + pub label_ids: Option<Vec<String>>, /// no description provided - pub message: Message, + pub message: Option<Message>, } impl Part for HistoryLabelAdded {} @@ -718,12 +718,12 @@ impl Part for HistoryLabelAdded {} pub struct ListThreadsResponse { /// Page token to retrieve the next page of results in the list. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Estimated total number of results. #[serde(rename="resultSizeEstimate")] - pub result_size_estimate: u32, + pub result_size_estimate: Option<u32>, /// List of threads. - pub threads: Vec<Thread>, + pub threads: Option<Vec<Thread>>, } impl ResponseResult for ListThreadsResponse {} @@ -764,12 +764,12 @@ impl RequestValue for ModifyThreadRequest {} pub struct ListMessagesResponse { /// Token to retrieve the next page of results in the list. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Estimated total number of results. #[serde(rename="resultSizeEstimate")] - pub result_size_estimate: u32, + pub result_size_estimate: Option<u32>, /// List of messages. - pub messages: Vec<Message>, + pub messages: Option<Vec<Message>>, } impl ResponseResult for ListMessagesResponse {} @@ -787,7 +787,7 @@ impl ResponseResult for ListMessagesResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListLabelsResponse { /// List of labels. - pub labels: Vec<Label>, + pub labels: Option<Vec<Label>>, } impl ResponseResult for ListLabelsResponse {} @@ -848,9 +848,9 @@ impl ResponseResult for Message {} pub struct HistoryLabelRemoved { /// Label IDs removed from the message. #[serde(rename="labelIds")] - pub label_ids: Vec<String>, + pub label_ids: Option<Vec<String>>, /// no description provided - pub message: Message, + pub message: Option<Message>, } impl Part for HistoryLabelRemoved {} @@ -1533,7 +1533,7 @@ impl<'a, C, A> UserMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Message = Default::default(); +/// let mut req = Message::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -1656,16 +1656,20 @@ impl<'a, C, A> UserMessageImportCall<'a, C, A> where C: BorrowMut<hyper::Client> let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -2050,16 +2054,20 @@ impl<'a, C, A> UserHistoryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2228,7 +2236,7 @@ impl<'a, C, A> UserHistoryListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Draft = Default::default(); +/// let mut req = Draft::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -2331,16 +2339,20 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -2596,7 +2608,7 @@ impl<'a, C, A> UserDraftCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Label = Default::default(); +/// let mut req = Label::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2688,16 +2700,20 @@ impl<'a, C, A> UserLabelCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2932,16 +2948,20 @@ impl<'a, C, A> UserLabelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3164,16 +3184,20 @@ impl<'a, C, A> UserLabelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3406,16 +3430,20 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3566,7 +3594,7 @@ impl<'a, C, A> UserMessageTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Draft = Default::default(); +/// let mut req = Draft::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -3669,16 +3697,20 @@ impl<'a, C, A> UserDraftSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -4017,16 +4049,20 @@ impl<'a, C, A> UserMessageUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4257,16 +4293,20 @@ impl<'a, C, A> UserLabelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4488,16 +4528,20 @@ impl<'a, C, A> UserMessageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4638,7 +4682,7 @@ impl<'a, C, A> UserMessageDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Draft = Default::default(); +/// let mut req = Draft::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -4743,16 +4787,20 @@ impl<'a, C, A> UserDraftUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -5106,16 +5154,20 @@ impl<'a, C, A> UserDraftGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5272,7 +5324,7 @@ impl<'a, C, A> UserDraftGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Label = Default::default(); +/// let mut req = Label::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5366,16 +5418,20 @@ impl<'a, C, A> UserLabelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5621,16 +5677,20 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5780,7 +5840,7 @@ impl<'a, C, A> UserThreadUntrashCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Label = Default::default(); +/// let mut req = Label::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5874,16 +5934,20 @@ impl<'a, C, A> UserLabelPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6128,16 +6192,20 @@ impl<'a, C, A> UserDraftDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6387,16 +6455,20 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6572,7 +6644,7 @@ impl<'a, C, A> UserThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ModifyThreadRequest = Default::default(); +/// let mut req = ModifyThreadRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6666,16 +6738,20 @@ impl<'a, C, A> UserThreadModifyCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6920,16 +6996,20 @@ impl<'a, C, A> UserThreadDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7154,16 +7234,20 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7323,7 +7407,7 @@ impl<'a, C, A> UserMessageAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ModifyMessageRequest = Default::default(); +/// let mut req = ModifyMessageRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7417,16 +7501,20 @@ impl<'a, C, A> UserMessageModifyCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7672,16 +7760,20 @@ impl<'a, C, A> UserThreadTrashCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7922,16 +8014,20 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8086,7 +8182,7 @@ impl<'a, C, A> UserDraftListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Message = Default::default(); +/// let mut req = Message::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -8189,16 +8285,20 @@ impl<'a, C, A> UserMessageSendCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -8551,16 +8651,20 @@ impl<'a, C, A> UserMessageGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8835,16 +8939,20 @@ impl<'a, C, A> UserMessageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9101,16 +9209,20 @@ impl<'a, C, A> UserGetProfileCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9347,16 +9459,20 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9522,7 +9638,7 @@ impl<'a, C, A> UserThreadGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Message = Default::default(); +/// let mut req = Message::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -9635,16 +9751,20 @@ impl<'a, C, A> UserMessageInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { diff --git a/gen/groupsmigration1-cli/Cargo.toml b/gen/groupsmigration1-cli/Cargo.toml index 0d434d0f59..a5346db386 100644 --- a/gen/groupsmigration1-cli/Cargo.toml +++ b/gen/groupsmigration1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-groupsmigration1-cli" version = "0.0.1+20140416" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/groups-migration/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/groupsmigration1-cli/src/cmn.rs b/gen/groupsmigration1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/groupsmigration1-cli/src/cmn.rs +++ b/gen/groupsmigration1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/groupsmigration1-cli/src/main.rs b/gen/groupsmigration1-cli/src/main.rs index d172162d9e..a324d36057 100644 --- a/gen/groupsmigration1-cli/src/main.rs +++ b/gen/groupsmigration1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -32,6 +33,12 @@ Configuration: 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. "); mod cmn; @@ -55,7 +62,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.archive().insert(&self.opt.arg_group_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -97,8 +104,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -136,21 +142,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "groupsmigration1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "groupsmigration1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "groupsmigration1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "groupsmigration1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::GroupsMigration::new(hyper::Client::new(), auth), + hub: api::GroupsMigration::new(client, auth), }; match engine._doit(true) { @@ -170,12 +192,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/groupsmigration1/Cargo.toml b/gen/groupsmigration1/Cargo.toml index 4161462a5e..fd43b4e73a 100644 --- a/gen/groupsmigration1/Cargo.toml +++ b/gen/groupsmigration1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-groupsmigration1" version = "0.1.5+20140416" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/groups-migration/" diff --git a/gen/groupsmigration1/src/cmn.rs b/gen/groupsmigration1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/groupsmigration1/src/cmn.rs +++ b/gen/groupsmigration1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/groupsmigration1/src/lib.rs b/gen/groupsmigration1/src/lib.rs index a227a3d5a3..c60920de86 100644 --- a/gen/groupsmigration1/src/lib.rs +++ b/gen/groupsmigration1/src/lib.rs @@ -338,10 +338,10 @@ impl<'a, C, A> GroupsMigration<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Groups { /// The kind of insert resource this is. - pub kind: String, + pub kind: Option<String>, /// The status of the insert request. #[serde(rename="responseCode")] - pub response_code: String, + pub response_code: Option<String>, } impl ResponseResult for Groups {} @@ -536,16 +536,20 @@ impl<'a, C, A> ArchiveInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; diff --git a/gen/groupssettings1-cli/Cargo.toml b/gen/groupssettings1-cli/Cargo.toml index 40122940ae..939f966a96 100644 --- a/gen/groupssettings1-cli/Cargo.toml +++ b/gen/groupssettings1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-groupssettings1-cli" version = "0.0.1+20140428" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/groups-settings/get_started" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/groupssettings1-cli/src/cmn.rs b/gen/groupssettings1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/groupssettings1-cli/src/cmn.rs +++ b/gen/groupssettings1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/groupssettings1-cli/src/main.rs b/gen/groupssettings1-cli/src/main.rs index 83b6b8ad3a..adfaeb5d42 100644 --- a/gen/groupssettings1-cli/src/main.rs +++ b/gen/groupssettings1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -34,6 +35,12 @@ Configuration: 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. "); mod cmn; @@ -57,7 +64,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.groups().get(&self.opt.arg_group_unique_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -89,8 +96,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -99,10 +105,10 @@ impl Engine { fn _groups_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Groups = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -122,9 +128,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -230,8 +237,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -240,10 +246,10 @@ impl Engine { fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Groups = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -263,9 +269,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -371,8 +378,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -414,21 +420,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "groupssettings1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "groupssettings1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "groupssettings1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "groupssettings1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Groupssettings::new(hyper::Client::new(), auth), + hub: api::Groupssettings::new(client, auth), }; match engine._doit(true) { @@ -448,12 +470,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/groupssettings1/Cargo.toml b/gen/groupssettings1/Cargo.toml index e99445e40b..08805a8c0b 100644 --- a/gen/groupssettings1/Cargo.toml +++ b/gen/groupssettings1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-groupssettings1" version = "0.1.5+20140428" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/groups-settings/get_started" diff --git a/gen/groupssettings1/README.md b/gen/groupssettings1/README.md index edf539b012..236f74a1d6 100644 --- a/gen/groupssettings1/README.md +++ b/gen/groupssettings1/README.md @@ -95,7 +95,7 @@ let mut hub = Groupssettings::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Groups = Default::default(); +let mut req = Groups::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/groupssettings1/src/cmn.rs b/gen/groupssettings1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/groupssettings1/src/cmn.rs +++ b/gen/groupssettings1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/groupssettings1/src/lib.rs b/gen/groupssettings1/src/lib.rs index bac369f576..3ccd1ea981 100644 --- a/gen/groupssettings1/src/lib.rs +++ b/gen/groupssettings1/src/lib.rs @@ -96,7 +96,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Groups = Default::default(); +//! let mut req = Groups::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -271,7 +271,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Groups = Default::default(); +/// let mut req = Groups::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -567,7 +567,7 @@ impl<'a, C, A> GroupMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Groups = Default::default(); +/// let mut req = Groups::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -659,16 +659,20 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -821,7 +825,7 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Groups = Default::default(); +/// let mut req = Groups::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -913,16 +917,20 @@ impl<'a, C, A> GroupPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1156,16 +1164,20 @@ impl<'a, C, A> GroupGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/identitytoolkit3-cli/Cargo.toml b/gen/identitytoolkit3-cli/Cargo.toml deleted file mode 100644 index 1fdbeb65a9..0000000000 --- a/gen/identitytoolkit3-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-identitytoolkit3-cli" -version = "0.0.1+20141009" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with Identity Toolkit (protocol v3)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3-cli" -homepage = "https://developers.google.com/identity-toolkit/v3/" -documentation = "http://byron.github.io/google-apis-rs/google_identitytoolkit3_cli" -license = "MIT" -keywords = ["identitytoolkit", "google", "cli"] - -[[bin]] -name = "identitytoolkit3" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-identitytoolkit3] -path = "../identitytoolkit3" diff --git a/gen/identitytoolkit3-cli/LICENSE.md b/gen/identitytoolkit3-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/identitytoolkit3-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/identitytoolkit3-cli/README.md b/gen/identitytoolkit3-cli/README.md deleted file mode 100644 index e5bc6ba8ca..0000000000 --- a/gen/identitytoolkit3-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO IDENTITYTOOLKIT:V3 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/identitytoolkit3-cli/mkdocs.yml b/gen/identitytoolkit3-cli/mkdocs.yml deleted file mode 100644 index afcfb7a785..0000000000 --- a/gen/identitytoolkit3-cli/mkdocs.yml +++ /dev/null @@ -1,27 +0,0 @@ -site_name: Identity Toolkit v0.0.1+20141009 -site_url: http://byron.github.io/google-apis-rs/google-identitytoolkit3-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/identitytoolkit3-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['relyingparty_create-auth-uri.md', 'Relyingparty', 'Create Auth Uri'] -- ['relyingparty_delete-account.md', 'Relyingparty', 'Delete Account'] -- ['relyingparty_download-account.md', 'Relyingparty', 'Download Account'] -- ['relyingparty_get-account-info.md', 'Relyingparty', 'Get Account Info'] -- ['relyingparty_get-oob-confirmation-code.md', 'Relyingparty', 'Get Oob Confirmation Code'] -- ['relyingparty_get-public-keys.md', 'Relyingparty', 'Get Public Keys'] -- ['relyingparty_reset-password.md', 'Relyingparty', 'Reset Password'] -- ['relyingparty_set-account-info.md', 'Relyingparty', 'Set Account Info'] -- ['relyingparty_upload-account.md', 'Relyingparty', 'Upload Account'] -- ['relyingparty_verify-assertion.md', 'Relyingparty', 'Verify Assertion'] -- ['relyingparty_verify-password.md', 'Relyingparty', 'Verify Password'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/identitytoolkit3-cli/src/cmn.rs b/gen/identitytoolkit3-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/identitytoolkit3-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/identitytoolkit3-cli/src/main.rs b/gen/identitytoolkit3-cli/src/main.rs deleted file mode 100644 index c9862194bb..0000000000 --- a/gen/identitytoolkit3-cli/src/main.rs +++ /dev/null @@ -1,928 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_identitytoolkit3 as api; - -use std::env; -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 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> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::IdentityToolkit<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _relyingparty_create_auth_uri(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyCreateAuthUriRequest = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "identifier" => { - request.identifier = Some(value.unwrap_or("").to_string()); - }, - "client-id" => { - request.client_id = Some(value.unwrap_or("").to_string()); - }, - "ota-app" => { - request.ota_app = Some(value.unwrap_or("").to_string()); - }, - "provider-id" => { - request.provider_id = Some(value.unwrap_or("").to_string()); - }, - "context" => { - request.context = Some(value.unwrap_or("").to_string()); - }, - "app-id" => { - request.app_id = Some(value.unwrap_or("").to_string()); - }, - "continue-uri" => { - request.continue_uri = Some(value.unwrap_or("").to_string()); - }, - "openid-realm" => { - request.openid_realm = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_delete_account(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyDeleteAccountRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_download_account(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyDownloadAccountRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_get_account_info(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyGetAccountInfoRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_get_oob_confirmation_code(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Relyingparty = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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-type" => { - request.request_type = Some(value.unwrap_or("").to_string()); - }, - "id-token" => { - request.id_token = Some(value.unwrap_or("").to_string()); - }, - "challenge" => { - request.challenge = Some(value.unwrap_or("").to_string()); - }, - "new-email" => { - request.new_email = Some(value.unwrap_or("").to_string()); - }, - "user-ip" => { - request.user_ip = Some(value.unwrap_or("").to_string()); - }, - "email" => { - request.email = Some(value.unwrap_or("").to_string()); - }, - "captcha-resp" => { - request.captcha_resp = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_get_public_keys(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.relyingparty().get_public_keys(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_reset_password(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyResetPasswordRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_set_account_info(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartySetAccountInfoRequest = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "display-name" => { - request.display_name = Some(value.unwrap_or("").to_string()); - }, - "local-id" => { - request.local_id = Some(value.unwrap_or("").to_string()); - }, - "upgrade-to-federated-login" => { - request.upgrade_to_federated_login = Some(arg_from_str(value.unwrap_or("false"), err, "upgrade-to-federated-login", "boolean")); - }, - "captcha-response" => { - request.captcha_response = Some(value.unwrap_or("").to_string()); - }, - "id-token" => { - request.id_token = Some(value.unwrap_or("").to_string()); - }, - "provider" => { - if request.provider.is_none() { - request.provider = Some(Default::default()); - } - request.provider.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "captcha-challenge" => { - request.captcha_challenge = Some(value.unwrap_or("").to_string()); - }, - "email-verified" => { - request.email_verified = Some(arg_from_str(value.unwrap_or("false"), err, "email-verified", "boolean")); - }, - "oob-code" => { - request.oob_code = Some(value.unwrap_or("").to_string()); - }, - "password" => { - request.password = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_upload_account(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyUploadAccountRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_verify_assertion(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyVerifyAssertionRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _relyingparty_verify_password(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::IdentitytoolkitRelyingpartyVerifyPasswordRequest = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 - } 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_relyingparty { - if self.opt.cmd_create_auth_uri { - call_result = self._relyingparty_create_auth_uri(dry_run, &mut err); - } else if self.opt.cmd_delete_account { - call_result = self._relyingparty_delete_account(dry_run, &mut err); - } else if self.opt.cmd_download_account { - call_result = self._relyingparty_download_account(dry_run, &mut err); - } else if self.opt.cmd_get_account_info { - call_result = self._relyingparty_get_account_info(dry_run, &mut err); - } else if self.opt.cmd_get_oob_confirmation_code { - call_result = self._relyingparty_get_oob_confirmation_code(dry_run, &mut err); - } else if self.opt.cmd_get_public_keys { - call_result = self._relyingparty_get_public_keys(dry_run, &mut err); - } else if self.opt.cmd_reset_password { - call_result = self._relyingparty_reset_password(dry_run, &mut err); - } else if self.opt.cmd_set_account_info { - call_result = self._relyingparty_set_account_info(dry_run, &mut err); - } else if self.opt.cmd_upload_account { - call_result = self._relyingparty_upload_account(dry_run, &mut err); - } else if self.opt.cmd_verify_assertion { - call_result = self._relyingparty_verify_assertion(dry_run, &mut err); - } else if self.opt.cmd_verify_password { - call_result = self._relyingparty_verify_password(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "identitytoolkit3-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "identitytoolkit3", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::IdentityToolkit::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/identitytoolkit3/Cargo.toml b/gen/identitytoolkit3/Cargo.toml index bab0771ad0..989c8d4072 100644 --- a/gen/identitytoolkit3/Cargo.toml +++ b/gen/identitytoolkit3/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-identitytoolkit3" -version = "0.1.5+20141009" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/identity-toolkit/v3/" diff --git a/gen/identitytoolkit3/README.md b/gen/identitytoolkit3/README.md index a5a727d618..0c7a161ae7 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+20141009*, where *20141009* 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.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*. Everything else about the *Identity Toolkit* *v3* API can be found at the [official documentation site](https://developers.google.com/identity-toolkit/v3/). @@ -14,7 +14,7 @@ Everything else about the *Identity Toolkit* *v3* API can be found at the Handle the following *Resources* with ease from the central [hub](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.IdentityToolkit.html) ... * [relyingparty](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.Relyingparty.html) - * [*create auth uri*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyCreateAuthUriCall.html), [*delete account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyDeleteAccountCall.html), [*download account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyDownloadAccountCall.html), [*get account info*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetAccountInfoCall.html), [*get oob confirmation code*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetOobConfirmationCodeCall.html), [*get public keys*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetPublicKeyCall.html), [*reset password*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyResetPasswordCall.html), [*set account info*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartySetAccountInfoCall.html), [*upload account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyUploadAccountCall.html), [*verify assertion*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyVerifyAssertionCall.html) and [*verify password*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyVerifyPasswordCall.html) + * [*create auth uri*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyCreateAuthUriCall.html), [*delete account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyDeleteAccountCall.html), [*download account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyDownloadAccountCall.html), [*get account info*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetAccountInfoCall.html), [*get oob confirmation code*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetOobConfirmationCodeCall.html), [*get public keys*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetPublicKeyCall.html), [*get recaptcha param*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyGetRecaptchaParamCall.html), [*reset password*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyResetPasswordCall.html), [*set account info*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartySetAccountInfoCall.html), [*upload account*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyUploadAccountCall.html), [*verify assertion*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyVerifyAssertionCall.html) and [*verify password*](http://byron.github.io/google-apis-rs/google_identitytoolkit3/struct.RelyingpartyVerifyPasswordCall.html) @@ -93,7 +93,7 @@ let mut hub = IdentityToolkit::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: IdentitytoolkitRelyingpartyVerifyAssertionRequest = Default::default(); +let mut req = IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/identitytoolkit3/src/cmn.rs b/gen/identitytoolkit3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/identitytoolkit3/src/cmn.rs +++ b/gen/identitytoolkit3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/identitytoolkit3/src/lib.rs b/gen/identitytoolkit3/src/lib.rs index 85d1a9fa42..83515bf7b1 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+20141009*, where *20141009* 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.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*. //! //! Everything else about the *Identity Toolkit* *v3* API can be found at the //! [official documentation site](https://developers.google.com/identity-toolkit/v3/). @@ -12,7 +12,7 @@ //! Handle the following *Resources* with ease from the central [hub](struct.IdentityToolkit.html) ... //! //! * [relyingparty](struct.Relyingparty.html) -//! * [*create auth uri*](struct.RelyingpartyCreateAuthUriCall.html), [*delete account*](struct.RelyingpartyDeleteAccountCall.html), [*download account*](struct.RelyingpartyDownloadAccountCall.html), [*get account info*](struct.RelyingpartyGetAccountInfoCall.html), [*get oob confirmation code*](struct.RelyingpartyGetOobConfirmationCodeCall.html), [*get public keys*](struct.RelyingpartyGetPublicKeyCall.html), [*reset password*](struct.RelyingpartyResetPasswordCall.html), [*set account info*](struct.RelyingpartySetAccountInfoCall.html), [*upload account*](struct.RelyingpartyUploadAccountCall.html), [*verify assertion*](struct.RelyingpartyVerifyAssertionCall.html) and [*verify password*](struct.RelyingpartyVerifyPasswordCall.html) +//! * [*create auth uri*](struct.RelyingpartyCreateAuthUriCall.html), [*delete account*](struct.RelyingpartyDeleteAccountCall.html), [*download account*](struct.RelyingpartyDownloadAccountCall.html), [*get account info*](struct.RelyingpartyGetAccountInfoCall.html), [*get oob confirmation code*](struct.RelyingpartyGetOobConfirmationCodeCall.html), [*get public keys*](struct.RelyingpartyGetPublicKeyCall.html), [*get recaptcha param*](struct.RelyingpartyGetRecaptchaParamCall.html), [*reset password*](struct.RelyingpartyResetPasswordCall.html), [*set account info*](struct.RelyingpartySetAccountInfoCall.html), [*upload account*](struct.RelyingpartyUploadAccountCall.html), [*verify assertion*](struct.RelyingpartyVerifyAssertionCall.html) and [*verify password*](struct.RelyingpartyVerifyPasswordCall.html) //! //! //! @@ -94,7 +94,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: IdentitytoolkitRelyingpartyVerifyAssertionRequest = Default::default(); +//! let mut req = IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -247,7 +247,7 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyVerifyAssertionRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -359,21 +359,21 @@ impl RequestValue for Relyingparty {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreateAuthUriResponse { /// The fixed string identitytoolkit#CreateAuthUriResponse". - pub kind: String, + pub kind: Option<String>, /// True if captcha is required. #[serde(rename="captchaRequired")] - pub captcha_required: bool, + pub captcha_required: Option<bool>, /// The URI used by the IDP to authenticate the user. #[serde(rename="authUri")] - pub auth_uri: String, + pub auth_uri: Option<String>, /// Whether the user is registered if the identifier is an email. - pub registered: bool, + pub registered: Option<bool>, /// The provider ID of the auth URI. #[serde(rename="providerId")] - pub provider_id: String, + pub provider_id: Option<String>, /// True if the authUri is for user's existing provider. #[serde(rename="forExistingProvider")] - pub for_existing_provider: bool, + pub for_existing_provider: Option<bool>, } impl ResponseResult for CreateAuthUriResponse {} @@ -456,10 +456,10 @@ impl RequestValue for IdentitytoolkitRelyingpartyDeleteAccountRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GetOobConfirmationCodeResponse { /// The fixed string "identitytoolkit#GetOobConfirmationCodeResponse". - pub kind: String, + pub kind: Option<String>, /// The code to be send to the user. #[serde(rename="oobCode")] - pub oob_code: String, + pub oob_code: Option<String>, } impl ResponseResult for GetOobConfirmationCodeResponse {} @@ -502,16 +502,40 @@ impl RequestValue for IdentitytoolkitRelyingpartyGetAccountInfoRequest {} pub struct DownloadAccountResponse { /// The next page token. To be used in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The fixed string "identitytoolkit#DownloadAccountResponse". - pub kind: String, + pub kind: Option<String>, /// The user accounts data. - pub users: Vec<UserInfo>, + pub users: Option<Vec<UserInfo>>, } impl ResponseResult for DownloadAccountResponse {} +/// Response of getting recaptcha param. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get recaptcha param relyingparty](struct.RelyingpartyGetRecaptchaParamCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GetRecaptchaParamResponse { + /// The fixed string "identitytoolkit#GetRecaptchaParamResponse". + pub kind: Option<String>, + /// Site key registered at recaptcha. + #[serde(rename="recaptchaSiteKey")] + pub recaptcha_site_key: Option<String>, + /// The stoken field for the recaptcha widget, used to request captcha challenge. + #[serde(rename="recaptchaStoken")] + pub recaptcha_stoken: Option<String>, +} + +impl ResponseResult for GetRecaptchaParamResponse {} + + /// Request to reset the password. /// /// # Activities @@ -552,80 +576,89 @@ impl RequestValue for IdentitytoolkitRelyingpartyResetPasswordRequest {} pub struct VerifyAssertionResponse { /// The unique ID identifies the IdP account. #[serde(rename="federatedId")] - pub federated_id: String, + pub federated_id: Option<String>, /// The RP local ID if it's already been mapped to the IdP account identified by the federated ID. #[serde(rename="localId")] - pub local_id: String, + pub local_id: Option<String>, /// The URI of the public accessible profiel picture. #[serde(rename="photoUrl")] - pub photo_url: String, + pub photo_url: Option<String>, /// It's the identifier param in the createAuthUri request if the identifier is an email. It can be used to check whether the user input email is different from the asserted email. #[serde(rename="inputEmail")] - pub input_email: String, - /// The value is true if the IDP is also the email provider. It means the user owns the email. - #[serde(rename="emailVerified")] - pub email_verified: bool, - /// Whether the assertion is from a non-trusted IDP and need account linking confirmation. - #[serde(rename="needConfirmation")] - pub need_confirmation: bool, - /// The custom scheme used by mobile app. - #[serde(rename="appScheme")] - pub app_scheme: String, - /// The full name of the user. - #[serde(rename="fullName")] - pub full_name: String, - /// URL for OTA app installation. - #[serde(rename="appInstallationUrl")] - pub app_installation_url: String, - /// The fixed string "identitytoolkit#VerifyAssertionResponse". - pub kind: String, - /// The display name of the user. - #[serde(rename="displayName")] - pub display_name: String, - /// The first name of the user. - #[serde(rename="firstName")] - pub first_name: String, - /// The language preference of the user. - pub language: String, - /// The ID token. - #[serde(rename="idToken")] - pub id_token: String, - /// When action is 'map', contains the idps which can be used for confirmation. - #[serde(rename="verifiedProvider")] - pub verified_provider: Vec<String>, + pub input_email: Option<String>, /// The scope for the OpenID OAuth extension. #[serde(rename="oauthScope")] - pub oauth_scope: String, + pub oauth_scope: Option<String>, + /// The value is true if the IDP is also the email provider. It means the user owns the email. + #[serde(rename="emailVerified")] + pub email_verified: Option<bool>, + /// Whether the assertion is from a non-trusted IDP and need account linking confirmation. + #[serde(rename="needConfirmation")] + pub need_confirmation: Option<bool>, + /// The custom scheme used by mobile app. + #[serde(rename="appScheme")] + pub app_scheme: Option<String>, + /// The full name of the user. + #[serde(rename="fullName")] + pub full_name: Option<String>, + /// URL for OTA app installation. + #[serde(rename="appInstallationUrl")] + pub app_installation_url: Option<String>, + /// The fixed string "identitytoolkit#VerifyAssertionResponse". + pub kind: Option<String>, + /// The display name of the user. + #[serde(rename="displayName")] + pub display_name: Option<String>, + /// The language preference of the user. + pub language: Option<String>, + /// The first name of the user. + #[serde(rename="firstName")] + pub first_name: Option<String>, + /// The OAuth2 authorization code. + #[serde(rename="oauthAuthorizationCode")] + pub oauth_authorization_code: Option<String>, + /// The lifetime in seconds of the OAuth2 access token. + #[serde(rename="oauthExpireIn")] + pub oauth_expire_in: Option<i32>, + /// The ID token. + #[serde(rename="idToken")] + pub id_token: Option<String>, + /// When action is 'map', contains the idps which can be used for confirmation. + #[serde(rename="verifiedProvider")] + pub verified_provider: Option<Vec<String>>, + /// The OAuth2 access token. + #[serde(rename="oauthAccessToken")] + pub oauth_access_token: Option<String>, /// The user approved request token for the OpenID OAuth extension. #[serde(rename="oauthRequestToken")] - pub oauth_request_token: String, + pub oauth_request_token: Option<String>, /// The birth date of the IdP account. #[serde(rename="dateOfBirth")] - pub date_of_birth: String, + pub date_of_birth: Option<String>, /// The original email stored in the mapping storage. It's returned when the federated ID is associated to a different email. #[serde(rename="originalEmail")] - pub original_email: String, + pub original_email: Option<String>, /// The IdP ID. For white listed IdPs it's a short domain name e.g. google.com, aol.com, live.net and yahoo.com. If the "providerId" param is set to OpenID OP identifer other than the whilte listed IdPs the OP identifier is returned. If the "identifier" param is federated ID in the createAuthUri request. The domain part of the federated ID is returned. #[serde(rename="providerId")] - pub provider_id: String, + pub provider_id: Option<String>, /// The opaque value used by the client to maintain context info between the authentication request and the IDP callback. - pub context: String, + pub context: Option<String>, /// The last name of the user. #[serde(rename="lastName")] - pub last_name: String, + pub last_name: Option<String>, /// The action code. - pub action: String, + pub action: Option<String>, /// The timezone of the user. #[serde(rename="timeZone")] - pub time_zone: String, + pub time_zone: Option<String>, /// The nick name of the user. #[serde(rename="nickName")] - pub nick_name: String, + pub nick_name: Option<String>, /// The email returned by the IdP. NOTE: The federated login user may not own the email. - pub email: String, + pub email: Option<String>, /// It's true if the email is recycled. #[serde(rename="emailRecycled")] - pub email_recycled: bool, + pub email_recycled: Option<bool>, } impl ResponseResult for VerifyAssertionResponse {} @@ -638,9 +671,9 @@ impl ResponseResult for VerifyAssertionResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadAccountResponseError { /// The index of the malformed account, starting from 0. - pub index: i32, + pub index: Option<i32>, /// Detailed error message for the account info. - pub message: String, + pub message: Option<String>, } impl NestedType for UploadAccountResponseError {} @@ -659,9 +692,9 @@ impl Part for UploadAccountResponseError {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadAccountResponse { /// The fixed string "identitytoolkit#UploadAccountResponse". - pub kind: String, + pub kind: Option<String>, /// The error encountered while processing the account info. - pub error: Vec<UploadAccountResponseError>, + pub error: Option<Vec<UploadAccountResponseError>>, } impl ResponseResult for UploadAccountResponse {} @@ -711,23 +744,23 @@ impl RequestValue for IdentitytoolkitRelyingpartyUploadAccountRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VerifyPasswordResponse { /// The fixed string "identitytoolkit#VerifyPasswordResponse". - pub kind: String, + pub kind: Option<String>, /// The name of the user. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The RP local ID if it's already been mapped to the IdP account identified by the federated ID. #[serde(rename="localId")] - pub local_id: String, + pub local_id: Option<String>, /// The URI of the user's photo at IdP #[serde(rename="photoUrl")] - pub photo_url: String, + pub photo_url: Option<String>, /// The GITKit token for authenticated user. #[serde(rename="idToken")] - pub id_token: String, + pub id_token: Option<String>, /// Whether the email is registered. - pub registered: bool, + pub registered: Option<bool>, /// The email returned by the IdP. NOTE: The federated login user may not own the email. - pub email: String, + pub email: Option<String>, } impl ResponseResult for VerifyPasswordResponse {} @@ -745,9 +778,9 @@ impl ResponseResult for VerifyPasswordResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResetPasswordResponse { /// The fixed string "identitytoolkit#ResetPasswordResponse". - pub kind: String, + pub kind: Option<String>, /// The user's email. - pub email: String, + pub email: Option<String>, } impl ResponseResult for ResetPasswordResponse {} @@ -765,7 +798,7 @@ impl ResponseResult for ResetPasswordResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeleteAccountResponse { /// The fixed string "identitytoolkit#DeleteAccountResponse". - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for DeleteAccountResponse {} @@ -782,15 +815,20 @@ impl ResponseResult for DeleteAccountResponse {} /// #[derive(Default, Clone, Debug, Serialize)] pub struct IdentitytoolkitRelyingpartyCreateAuthUriRequest { - /// Optional realm for OpenID protocol. The sub string "scheme://domain:port" of the param "continueUri" is used if this is not set. - #[serde(rename="openidRealm")] - pub openid_realm: Option<String>, + /// The email or federated ID of the user. + pub identifier: Option<String>, + /// Additional oauth scopes, beyond the basid user profile, that the user would be prompted to grant + #[serde(rename="oauthScope")] + pub oauth_scope: Option<String>, /// The relying party OAuth client ID. #[serde(rename="clientId")] pub client_id: Option<String>, /// The native app package for OTA installation. #[serde(rename="otaApp")] pub ota_app: Option<String>, + /// The developer's consumer key for OpenId OAuth Extension + #[serde(rename="oauthConsumerKey")] + pub oauth_consumer_key: Option<String>, /// The IdP ID. For white listed IdPs it's a short domain name e.g. google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. #[serde(rename="providerId")] pub provider_id: Option<String>, @@ -802,52 +840,14 @@ pub struct IdentitytoolkitRelyingpartyCreateAuthUriRequest { /// The URI to which the IDP redirects the user after the federated login flow. #[serde(rename="continueUri")] pub continue_uri: Option<String>, - /// The email or federated ID of the user. - pub identifier: Option<String>, + /// Optional realm for OpenID protocol. The sub string "scheme://domain:port" of the param "continueUri" is used if this is not set. + #[serde(rename="openidRealm")] + pub openid_realm: Option<String>, } impl RequestValue for IdentitytoolkitRelyingpartyCreateAuthUriRequest {} -/// The IDP of the user. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UserInfoProviderUserInfo { - /// User's identifier at IDP. - #[serde(rename="federatedId")] - pub federated_id: String, - /// The IdP ID. For white listed IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. - #[serde(rename="providerId")] - pub provider_id: String, - /// The user's display name at the IDP. - #[serde(rename="displayName")] - pub display_name: String, - /// The user's photo url at the IDP. - #[serde(rename="photoUrl")] - pub photo_url: String, -} - -impl NestedType for UserInfoProviderUserInfo {} -impl Part for UserInfoProviderUserInfo {} - - -/// Respone of getting public keys. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [get public keys relyingparty](struct.RelyingpartyGetPublicKeyCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct IdentitytoolkitRelyingpartyGetPublicKeysResponse(HashMap<String, String>); - -impl ResponseResult for IdentitytoolkitRelyingpartyGetPublicKeysResponse {} - - /// Request to verify the password. /// /// # Activities @@ -877,6 +877,83 @@ pub struct IdentitytoolkitRelyingpartyVerifyPasswordRequest { impl RequestValue for IdentitytoolkitRelyingpartyVerifyPasswordRequest {} +/// The IDP of the user. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserInfoProviderUserInfo { + /// User's identifier at IDP. + #[serde(rename="federatedId")] + pub federated_id: Option<String>, + /// The IdP ID. For white listed IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. + #[serde(rename="providerId")] + pub provider_id: Option<String>, + /// The user's display name at the IDP. + #[serde(rename="displayName")] + pub display_name: Option<String>, + /// The user's photo url at the IDP. + #[serde(rename="photoUrl")] + pub photo_url: Option<String>, +} + +impl NestedType for UserInfoProviderUserInfo {} +impl Part for UserInfoProviderUserInfo {} + + +/// Respone of getting public keys. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [get public keys relyingparty](struct.RelyingpartyGetPublicKeyCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct IdentitytoolkitRelyingpartyGetPublicKeysResponse(Option<HashMap<String, String>>); + +impl ResponseResult for IdentitytoolkitRelyingpartyGetPublicKeysResponse {} + + +/// Template for an individual account info. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct UserInfo { + /// The name of the user. + #[serde(rename="displayName")] + pub display_name: Option<String>, + /// The local ID of the user. + #[serde(rename="localId")] + pub local_id: Option<String>, + /// The URL of the user profile photo. + #[serde(rename="photoUrl")] + pub photo_url: Option<String>, + /// Whether the email has been verified. + #[serde(rename="emailVerified")] + pub email_verified: Option<bool>, + /// The user's hashed password. + #[serde(rename="passwordHash")] + pub password_hash: Option<String>, + /// Version of the user's password. + pub version: Option<i32>, + /// The IDP of the user. + #[serde(rename="providerUserInfo")] + pub provider_user_info: Option<Vec<UserInfoProviderUserInfo>>, + /// The timestamp when the password was last updated. + #[serde(rename="passwordUpdatedAt")] + pub password_updated_at: Option<f64>, + /// The user's password salt. + pub salt: Option<String>, + /// The email of the user. + pub email: Option<String>, +} + +impl Part for UserInfo {} + + /// Request to download user account in batch. /// /// # Activities @@ -907,13 +984,13 @@ impl RequestValue for IdentitytoolkitRelyingpartyDownloadAccountRequest {} pub struct SetAccountInfoResponseProviderUserInfo { /// The IdP ID. For whitelisted IdPs it's a short domain name, e.g., google.com, aol.com, live.net and yahoo.com. For other OpenID IdPs it's the OP identifier. #[serde(rename="providerId")] - pub provider_id: String, + pub provider_id: Option<String>, /// The user's display name at the IDP. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The user's photo url at the IDP. #[serde(rename="photoUrl")] - pub photo_url: String, + pub photo_url: Option<String>, } impl NestedType for SetAccountInfoResponseProviderUserInfo {} @@ -932,14 +1009,43 @@ impl Part for SetAccountInfoResponseProviderUserInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GetAccountInfoResponse { /// The fixed string "identitytoolkit#GetAccountInfoResponse". - pub kind: String, + pub kind: Option<String>, /// The info of the users. - pub users: Vec<UserInfo>, + pub users: Option<Vec<UserInfo>>, } impl ResponseResult for GetAccountInfoResponse {} +/// Respone of setting the account information. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [set account info relyingparty](struct.RelyingpartySetAccountInfoCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct SetAccountInfoResponse { + /// The Gitkit id token to login the newly sign up user. + #[serde(rename="idToken")] + pub id_token: Option<String>, + /// The fixed string "identitytoolkit#SetAccountInfoResponse". + pub kind: Option<String>, + /// The name of the user. + #[serde(rename="displayName")] + pub display_name: Option<String>, + /// The email of the user. + pub email: Option<String>, + /// The user's profiles at the associated IdPs. + #[serde(rename="providerUserInfo")] + pub provider_user_info: Option<Vec<SetAccountInfoResponseProviderUserInfo>>, +} + +impl ResponseResult for SetAccountInfoResponse {} + + /// Request to verify the IDP assertion. /// /// # Activities @@ -957,6 +1063,9 @@ pub struct IdentitytoolkitRelyingpartyVerifyAssertionRequest { /// The post body if the request is a HTTP POST. #[serde(rename="postBody")] pub post_body: Option<String>, + /// Whether to return refresh tokens. + #[serde(rename="returnRefreshToken")] + pub return_refresh_token: Option<bool>, /// The GITKit token for the non-trusted IDP pending to be confirmed by the user. #[serde(rename="pendingIdToken")] pub pending_id_token: Option<String>, @@ -965,73 +1074,6 @@ pub struct IdentitytoolkitRelyingpartyVerifyAssertionRequest { impl RequestValue for IdentitytoolkitRelyingpartyVerifyAssertionRequest {} -/// Respone of setting the account information. -/// -/// # Activities -/// -/// This type is used in activities, which are methods you may call on this type or where this type is involved in. -/// The list links the activity name, along with information about where it is used (one of *request* and *response*). -/// -/// * [set account info relyingparty](struct.RelyingpartySetAccountInfoCall.html) (response) -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct SetAccountInfoResponse { - /// The Gitkit id token to login the newly sign up user. - #[serde(rename="idToken")] - pub id_token: String, - /// The fixed string "identitytoolkit#SetAccountInfoResponse". - pub kind: String, - /// The name of the user. - #[serde(rename="displayName")] - pub display_name: String, - /// The email of the user. - pub email: String, - /// The user's profiles at the associated IdPs. - #[serde(rename="providerUserInfo")] - pub provider_user_info: Vec<SetAccountInfoResponseProviderUserInfo>, -} - -impl ResponseResult for SetAccountInfoResponse {} - - -/// Template for an individual account info. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct UserInfo { - /// The name of the user. - #[serde(rename="displayName")] - pub display_name: String, - /// The local ID of the user. - #[serde(rename="localId")] - pub local_id: String, - /// The URL of the user profile photo. - #[serde(rename="photoUrl")] - pub photo_url: String, - /// Whether the email has been verified. - #[serde(rename="emailVerified")] - pub email_verified: bool, - /// The user's hashed password. - #[serde(rename="passwordHash")] - pub password_hash: String, - /// Version of the user's password. - pub version: i32, - /// The IDP of the user. - #[serde(rename="providerUserInfo")] - pub provider_user_info: Vec<UserInfoProviderUserInfo>, - /// The timestamp when the password was last updated. - #[serde(rename="passwordUpdatedAt")] - pub password_updated_at: f64, - /// The user's password salt. - pub salt: String, - /// The email of the user. - pub email: String, -} - -impl Part for UserInfo {} - - // ################### // MethodBuilders ### @@ -1060,7 +1102,7 @@ impl Part for UserInfo {} /// <MemoryStorage as Default>::default(), None); /// let mut hub = IdentityToolkit::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `create_auth_uri(...)`, `delete_account(...)`, `download_account(...)`, `get_account_info(...)`, `get_oob_confirmation_code(...)`, `get_public_keys(...)`, `reset_password(...)`, `set_account_info(...)`, `upload_account(...)`, `verify_assertion(...)` and `verify_password(...)` +/// // like `create_auth_uri(...)`, `delete_account(...)`, `download_account(...)`, `get_account_info(...)`, `get_oob_confirmation_code(...)`, `get_public_keys(...)`, `get_recaptcha_param(...)`, `reset_password(...)`, `set_account_info(...)`, `upload_account(...)`, `verify_assertion(...)` and `verify_password(...)` /// // to build up your call. /// let rb = hub.relyingparty(); /// # } @@ -1230,6 +1272,17 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Get recaptcha secure param. + pub fn get_recaptcha_param(&self) -> RelyingpartyGetRecaptchaParamCall<'a, C, A> { + RelyingpartyGetRecaptchaParamCall { + hub: self.hub, + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Verifies the user entered password. @@ -1282,7 +1335,7 @@ impl<'a, C, A> RelyingpartyMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Relyingparty = Default::default(); +/// let mut req = Relyingparty::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1656,7 +1709,7 @@ impl<'a, C, A> RelyingpartyGetPublicKeyCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyCreateAuthUriRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyCreateAuthUriRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1855,7 +1908,7 @@ impl<'a, C, A> RelyingpartyCreateAuthUriCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyVerifyAssertionRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyVerifyAssertionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2054,7 +2107,7 @@ impl<'a, C, A> RelyingpartyVerifyAssertionCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyUploadAccountRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyUploadAccountRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2253,7 +2306,7 @@ impl<'a, C, A> RelyingpartyUploadAccountCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyGetAccountInfoRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyGetAccountInfoRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2452,7 +2505,7 @@ impl<'a, C, A> RelyingpartyGetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyResetPasswordRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyResetPasswordRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2651,7 +2704,7 @@ impl<'a, C, A> RelyingpartyResetPasswordCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyDownloadAccountRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyDownloadAccountRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2850,7 +2903,7 @@ impl<'a, C, A> RelyingpartyDownloadAccountCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartySetAccountInfoRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartySetAccountInfoRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3049,7 +3102,7 @@ impl<'a, C, A> RelyingpartySetAccountInfoCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyDeleteAccountRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyDeleteAccountRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3221,6 +3274,181 @@ impl<'a, C, A> RelyingpartyDeleteAccountCall<'a, C, A> where C: BorrowMut<hyper: } +/// Get recaptcha secure param. +/// +/// A builder for the *getRecaptchaParam* method supported by a *relyingparty* resource. +/// It is not used directly, but through a `RelyingpartyMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_identitytoolkit3 as identitytoolkit3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use identitytoolkit3::IdentityToolkit; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = IdentityToolkit::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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_recaptcha_param() +/// .doit(); +/// # } +/// ``` +pub struct RelyingpartyGetRecaptchaParamCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a IdentityToolkit<C, A>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, +} + +impl<'a, C, A> CallBuilder for RelyingpartyGetRecaptchaParamCall<'a, C, A> {} + +impl<'a, C, A> RelyingpartyGetRecaptchaParamCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, GetRecaptchaParamResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "identitytoolkit.relyingparty.getRecaptchaParam", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + for &field in ["alt"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getRecaptchaParam".to_string(); + + let mut key = self.hub.auth.borrow_mut().api_key(); + if key.is_none() { + key = dlg.api_key(); + } + match key { + Some(value) => params.push(("key", value)), + None => { + dlg.finished(false); + return Err(Error::MissingAPIKey) + } + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> RelyingpartyGetRecaptchaParamCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> RelyingpartyGetRecaptchaParamCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + /// Verifies the user entered password. /// /// A builder for the *verifyPassword* method supported by a *relyingparty* resource. @@ -3248,7 +3476,7 @@ impl<'a, C, A> RelyingpartyDeleteAccountCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: IdentitytoolkitRelyingpartyVerifyPasswordRequest = Default::default(); +/// let mut req = IdentitytoolkitRelyingpartyVerifyPasswordRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. diff --git a/gen/licensing1-cli/Cargo.toml b/gen/licensing1-cli/Cargo.toml index bdc169d9b6..20cce1b59d 100644 --- a/gen/licensing1-cli/Cargo.toml +++ b/gen/licensing1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-licensing1-cli" version = "0.0.1+20140122" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/licensing/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/licensing1-cli/src/cmn.rs b/gen/licensing1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/licensing1-cli/src/cmn.rs +++ b/gen/licensing1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/licensing1-cli/src/main.rs b/gen/licensing1-cli/src/main.rs index f354884e32..a2d085e819 100644 --- a/gen/licensing1-cli/src/main.rs +++ b/gen/licensing1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -38,6 +39,12 @@ Configuration: 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. "); mod cmn; @@ -61,7 +68,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.license_assignments().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -92,7 +99,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -103,7 +109,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.license_assignments().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -135,8 +141,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -145,10 +150,10 @@ impl Engine { fn _license_assignments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LicenseAssignmentInsert = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -168,9 +173,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -195,8 +201,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -207,7 +212,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.license_assignments().list_for_product(&self.opt.arg_product_id, &self.opt.arg_customer_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -245,8 +250,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -257,7 +261,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.license_assignments().list_for_product_and_sku(&self.opt.arg_product_id, &self.opt.arg_sku_id, &self.opt.arg_customer_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -295,8 +299,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -305,10 +308,10 @@ impl Engine { fn _license_assignments_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LicenseAssignment = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -328,9 +331,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -370,8 +374,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -380,10 +383,10 @@ impl Engine { fn _license_assignments_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LicenseAssignment = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -403,9 +406,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -445,8 +449,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -496,21 +499,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "licensing1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "licensing1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "licensing1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "licensing1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Licensing::new(hyper::Client::new(), auth), + hub: api::Licensing::new(client, auth), }; match engine._doit(true) { @@ -530,12 +549,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/licensing1/Cargo.toml b/gen/licensing1/Cargo.toml index 4c9206979f..e336d0683b 100644 --- a/gen/licensing1/Cargo.toml +++ b/gen/licensing1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-licensing1" version = "0.1.5+20140122" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/licensing/" diff --git a/gen/licensing1/src/cmn.rs b/gen/licensing1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/licensing1/src/cmn.rs +++ b/gen/licensing1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/licensing1/src/lib.rs b/gen/licensing1/src/lib.rs index 869f51501b..01f374d12e 100644 --- a/gen/licensing1/src/lib.rs +++ b/gen/licensing1/src/lib.rs @@ -403,13 +403,13 @@ impl RequestValue for LicenseAssignmentInsert {} pub struct LicenseAssignmentList { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The LicenseAssignments in this page of results. - pub items: Vec<LicenseAssignment>, + pub items: Option<Vec<LicenseAssignment>>, /// Identifies the resource as a collection of LicenseAssignments. - pub kind: String, + pub kind: Option<String>, /// ETag of the resource. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for LicenseAssignmentList {} @@ -731,16 +731,20 @@ impl<'a, C, A> LicenseAssignmentDeleteCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -983,16 +987,20 @@ impl<'a, C, A> LicenseAssignmentListForProductCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1241,16 +1249,20 @@ impl<'a, C, A> LicenseAssignmentGetCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1505,16 +1517,20 @@ impl<'a, C, A> LicenseAssignmentListForProductAndSkuCall<'a, C, A> where C: Borr loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1688,7 +1704,7 @@ impl<'a, C, A> LicenseAssignmentListForProductAndSkuCall<'a, C, A> where C: Borr /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LicenseAssignment = Default::default(); +/// let mut req = LicenseAssignment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1784,16 +1800,20 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1966,7 +1986,7 @@ impl<'a, C, A> LicenseAssignmentUpdateCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LicenseAssignment = Default::default(); +/// let mut req = LicenseAssignment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2062,16 +2082,20 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2244,7 +2268,7 @@ impl<'a, C, A> LicenseAssignmentPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LicenseAssignmentInsert = Default::default(); +/// let mut req = LicenseAssignmentInsert::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2338,16 +2362,20 @@ impl<'a, C, A> LicenseAssignmentInsertCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/logging1_beta3-cli/Cargo.toml b/gen/logging1_beta3-cli/Cargo.toml deleted file mode 100644 index 1fd9615297..0000000000 --- a/gen/logging1_beta3-cli/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-logging1_beta3-cli" -version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with logging (protocol v1beta3)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/logging1_beta3-cli" -documentation = "http://byron.github.io/google-apis-rs/google_logging1_beta3_cli" -license = "MIT" -keywords = ["logging", "google", "cli"] - -[[bin]] -name = "logging1-beta3" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-logging1_beta3] -path = "../logging1_beta3" diff --git a/gen/logging1_beta3-cli/LICENSE.md b/gen/logging1_beta3-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/logging1_beta3-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/logging1_beta3-cli/README.md b/gen/logging1_beta3-cli/README.md deleted file mode 100644 index 205b79138c..0000000000 --- a/gen/logging1_beta3-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO LOGGING:V1BETA3 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/logging1_beta3-cli/mkdocs.yml b/gen/logging1_beta3-cli/mkdocs.yml deleted file mode 100644 index 942f91e6da..0000000000 --- a/gen/logging1_beta3-cli/mkdocs.yml +++ /dev/null @@ -1,31 +0,0 @@ -site_name: logging v0.0.1+20150326 -site_url: http://byron.github.io/google-apis-rs/google-logging1_beta3-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/logging1_beta3-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['projects_log-services-indexes-list.md', 'Projects', 'Log Services Indexes List'] -- ['projects_log-services-list.md', 'Projects', 'Log Services List'] -- ['projects_log-services-sinks-create.md', 'Projects', 'Log Services Sinks Create'] -- ['projects_log-services-sinks-delete.md', 'Projects', 'Log Services Sinks Delete'] -- ['projects_log-services-sinks-get.md', 'Projects', 'Log Services Sinks Get'] -- ['projects_log-services-sinks-list.md', 'Projects', 'Log Services Sinks List'] -- ['projects_log-services-sinks-update.md', 'Projects', 'Log Services Sinks Update'] -- ['projects_logs-delete.md', 'Projects', 'Logs Delete'] -- ['projects_logs-entries-write.md', 'Projects', 'Logs Entries Write'] -- ['projects_logs-list.md', 'Projects', 'Logs List'] -- ['projects_logs-sinks-create.md', 'Projects', 'Logs Sinks Create'] -- ['projects_logs-sinks-delete.md', 'Projects', 'Logs Sinks Delete'] -- ['projects_logs-sinks-get.md', 'Projects', 'Logs Sinks Get'] -- ['projects_logs-sinks-list.md', 'Projects', 'Logs Sinks List'] -- ['projects_logs-sinks-update.md', 'Projects', 'Logs Sinks Update'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/logging1_beta3-cli/src/cmn.rs b/gen/logging1_beta3-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/logging1_beta3-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/logging1_beta3-cli/src/main.rs b/gen/logging1_beta3-cli/src/main.rs deleted file mode 100644 index 9e01ffde13..0000000000 --- a/gen/logging1_beta3-cli/src/main.rs +++ /dev/null @@ -1,1052 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_logging1_beta3 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Logging<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _projects_log_services_indexes_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().log_services_indexes_list(&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); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - "log" => { - call = call.log(value.unwrap_or("")); - }, - "index-prefix" => { - call = call.index_prefix(value.unwrap_or("")); - }, - "depth" => { - call = call.depth(arg_from_str(value.unwrap_or("-0"), err, "depth", "integer")); - }, - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().log_services_list(&self.opt.arg_projects_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - "log" => { - call = call.log(value.unwrap_or("")); - }, - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_sinks_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::LogSink = Default::default(); - 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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_sinks_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().log_services_sinks_delete(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_sinks_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().log_services_sinks_get(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_sinks_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().log_services_sinks_list(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_log_services_sinks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::LogSink = Default::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); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().logs_delete(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_entries_write(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::WriteLogEntriesRequest = Default::default(); - 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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - } - request.common_labels.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().logs_list(&self.opt.arg_projects_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "service-name" => { - call = call.service_name(value.unwrap_or("")); - }, - "service-index-prefix" => { - call = call.service_index_prefix(value.unwrap_or("")); - }, - "page-token" => { - call = call.page_token(value.unwrap_or("")); - }, - "page-size" => { - call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer")); - }, - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_sinks_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::LogSink = Default::default(); - 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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_sinks_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().logs_sinks_delete(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_sinks_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().logs_sinks_get(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_sinks_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.projects().logs_sinks_list(&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); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _projects_logs_sinks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::LogSink = Default::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); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "$-xgafv" - |"access-token" - |"alt" - |"bearer-token" - |"callback" - |"fields" - |"key" - |"oauth-token" - |"pp" - |"pretty-print" - |"quota-user" => { - let map = [ - ("$-xgafv", "$.xgafv"), - ("access-token", "access_token"), - ("bearer-token", "bearer_token"), - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_projects { - if self.opt.cmd_log_services_indexes_list { - call_result = self._projects_log_services_indexes_list(dry_run, &mut err); - } else if self.opt.cmd_log_services_list { - call_result = self._projects_log_services_list(dry_run, &mut err); - } else if self.opt.cmd_log_services_sinks_create { - call_result = self._projects_log_services_sinks_create(dry_run, &mut err); - } else if self.opt.cmd_log_services_sinks_delete { - call_result = self._projects_log_services_sinks_delete(dry_run, &mut err); - } else if self.opt.cmd_log_services_sinks_get { - call_result = self._projects_log_services_sinks_get(dry_run, &mut err); - } else if self.opt.cmd_log_services_sinks_list { - call_result = self._projects_log_services_sinks_list(dry_run, &mut err); - } else if self.opt.cmd_log_services_sinks_update { - call_result = self._projects_log_services_sinks_update(dry_run, &mut err); - } else if self.opt.cmd_logs_delete { - call_result = self._projects_logs_delete(dry_run, &mut err); - } else if self.opt.cmd_logs_entries_write { - call_result = self._projects_logs_entries_write(dry_run, &mut err); - } else if self.opt.cmd_logs_list { - call_result = self._projects_logs_list(dry_run, &mut err); - } else if self.opt.cmd_logs_sinks_create { - call_result = self._projects_logs_sinks_create(dry_run, &mut err); - } else if self.opt.cmd_logs_sinks_delete { - call_result = self._projects_logs_sinks_delete(dry_run, &mut err); - } else if self.opt.cmd_logs_sinks_get { - call_result = self._projects_logs_sinks_get(dry_run, &mut err); - } else if self.opt.cmd_logs_sinks_list { - call_result = self._projects_logs_sinks_list(dry_run, &mut err); - } else if self.opt.cmd_logs_sinks_update { - call_result = self._projects_logs_sinks_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "logging1-beta3-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "logging1-beta3", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Logging::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/logging1_beta3/Cargo.toml b/gen/logging1_beta3/Cargo.toml index f13e63e450..86c8dc7a6d 100644 --- a/gen/logging1_beta3/Cargo.toml +++ b/gen/logging1_beta3/Cargo.toml @@ -5,7 +5,7 @@ name = "google-logging1_beta3" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" documentation = "http://byron.github.io/google-apis-rs/google_logging1_beta3" diff --git a/gen/logging1_beta3/README.md b/gen/logging1_beta3/README.md index bb83f44c58..4f6ab7503c 100644 --- a/gen/logging1_beta3/README.md +++ b/gen/logging1_beta3/README.md @@ -95,7 +95,7 @@ let mut hub = Logging::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: LogSink = Default::default(); +let mut req = LogSink::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/logging1_beta3/src/cmn.rs b/gen/logging1_beta3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/logging1_beta3/src/cmn.rs +++ b/gen/logging1_beta3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/logging1_beta3/src/lib.rs b/gen/logging1_beta3/src/lib.rs index 4d48bc8bfb..d4107a7561 100644 --- a/gen/logging1_beta3/src/lib.rs +++ b/gen/logging1_beta3/src/lib.rs @@ -96,7 +96,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: LogSink = Default::default(); +//! let mut req = LogSink::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -271,7 +271,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LogSink = Default::default(); +/// let mut req = LogSink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -341,11 +341,11 @@ impl<'a, C, A> Logging<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Status { /// A developer-facing error message, which should be in English. The user-facing error message should be localized and stored in the [google.rpc.Status.details][google.rpc.Status.details] field. - pub message: String, + pub message: Option<String>, /// The status code, which should be an enum value of [google.rpc.Code][]. - pub code: i32, + pub code: Option<i32>, /// A list of messages that carry the error details. There will be a common set of message types for APIs to use. - pub details: Vec<HashMap<String, String>>, + pub details: Option<Vec<HashMap<String, String>>>, } impl Part for Status {} @@ -358,12 +358,12 @@ impl Part for Status {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LogError { /// The description of the last error observed. - pub status: Status, + pub status: Option<Status>, /// The last time the error was observed, in nanoseconds since the Unix epoch. #[serde(rename="timeNanos")] - pub time_nanos: String, + pub time_nanos: Option<String>, /// The resource associated with the error. It may be different from the sink destination. For example, the sink may point to a BigQuery dataset, but the error may refer to a table resource inside the dataset. - pub resource: String, + pub resource: Option<String>, } impl Part for LogError {} @@ -377,12 +377,12 @@ impl Part for LogError {} pub struct Log { /// Type URL describing the expected payload type for the log. #[serde(rename="payloadType")] - pub payload_type: String, + pub payload_type: Option<String>, /// Name used when displaying the log to the user (for example, in a UI). Example: `"activity_log"` #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// REQUIRED: The log's name name. Example: `"compute.googleapis.com/activity_log"`. - pub name: String, + pub name: Option<String>, } impl Part for Log {} @@ -401,9 +401,9 @@ impl Part for Log {} pub struct ListLogsResponse { /// If there are more results, then `nextPageToken` is returned in the response. To get the next batch of logs, use the value of `nextPageToken` as `pageToken` in the next call of `ListLogs`. If `nextPageToken` is empty, then there are no more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of log resources. - pub logs: Vec<Log>, + pub logs: Option<Vec<Log>>, } impl ResponseResult for ListLogsResponse {} @@ -417,9 +417,9 @@ impl ResponseResult for ListLogsResponse {} pub struct LogService { /// Label keys used when labeling log entries for this service. The order of the keys is significant, with higher priority keys coming earlier in the list. #[serde(rename="indexKeys")] - pub index_keys: Vec<String>, + pub index_keys: Option<Vec<String>>, /// The service's name. - pub name: String, + pub name: Option<String>, } impl Part for LogService {} @@ -452,7 +452,7 @@ impl ResponseResult for WriteLogEntriesResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListLogSinksResponse { /// The requested log sinks. If any of the returned `LogSink` objects have an empty `destination` field, then call `logServices.sinks.get` to retrieve the complete `LogSink` object. - pub sinks: Vec<LogSink>, + pub sinks: Option<Vec<LogSink>>, } impl ResponseResult for ListLogSinksResponse {} @@ -492,10 +492,10 @@ impl RequestValue for WriteLogEntriesRequest {} pub struct ListLogServicesResponse { /// If there are more results, then `nextPageToken` is returned in the response. To get the next batch of services, use the value of `nextPageToken` as `pageToken` in the next call of `ListLogServices`. If `nextPageToken` is empty, then there are no more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of log services. #[serde(rename="logServices")] - pub log_services: Vec<LogService>, + pub log_services: Option<Vec<LogService>>, } impl ResponseResult for ListLogServicesResponse {} @@ -509,20 +509,20 @@ impl ResponseResult for ListLogServicesResponse {} pub struct LogEntry { /// The log entry payload, represented as a protocol buffer that is expressed as a JSON object. You can only pass `protoPayload` values that belong to a set of approved types. #[serde(rename="protoPayload")] - pub proto_payload: HashMap<String, String>, + pub proto_payload: Option<HashMap<String, String>>, /// The log to which this entry belongs. When a log entry is ingested, the value of this field is set by the logging system. - pub log: String, + pub log: Option<String>, /// The log entry payload, represented as a text string. #[serde(rename="textPayload")] - pub text_payload: String, + pub text_payload: Option<String>, /// A unique ID for the log entry. If you provide this field, the logging service considers other log entries in the same log with the same ID as duplicates which can be removed. #[serde(rename="insertId")] - pub insert_id: String, + pub insert_id: Option<String>, /// The log entry payload, represented as a structure that is expressed as a JSON object. #[serde(rename="structPayload")] - pub struct_payload: HashMap<String, String>, + pub struct_payload: Option<HashMap<String, String>>, /// Information about the log entry. - pub metadata: LogEntryMetadata, + pub metadata: Option<LogEntryMetadata>, } impl Part for LogEntry {} @@ -535,24 +535,24 @@ impl Part for LogEntry {} #[derive(Default, Clone, Debug, Serialize)] pub struct LogEntryMetadata { /// The severity of the log entry. - pub severity: String, + pub severity: Option<String>, /// The zone of the Google Cloud Platform service that created the log entry. For example, `"us-central1-a"`. - pub zone: String, + pub zone: Option<String>, /// The time the event described by the log entry occurred. Timestamps must be later than January 1, 1970. - pub timestamp: String, + pub timestamp: Option<String>, /// The region name of the Google Cloud Platform service that created the log entry. For example, `"us-central1"`. - pub region: String, + pub region: Option<String>, /// A set of (key, value) data that provides additional information about the log entry. If the log entry is from one of the Google Cloud Platform sources listed below, the indicated (key, value) information must be provided: Google App Engine, service_name `appengine.googleapis.com`: "appengine.googleapis.com/module_id", "appengine.googleapis.com/version_id", and one of: "appengine.googleapis.com/replica_index", "appengine.googleapis.com/clone_id", or else provide the following Compute Engine labels: Google Compute Engine, service_name `compute.googleapis.com`: "compute.googleapis.com/resource_type", "instance" "compute.googleapis.com/resource_id", - pub labels: HashMap<String, String>, + pub labels: Option<HashMap<String, String>>, /// The fully-qualified email address of the authenticated user that performed or requested the action represented by the log entry. If the log entry does not apply to an action taken by an authenticated user, then the field should be empty. #[serde(rename="userId")] - pub user_id: String, + pub user_id: Option<String>, /// The API name of the Google Cloud Platform service that created the log entry. For example, `"compute.googleapis.com"`. #[serde(rename="serviceName")] - pub service_name: String, + pub service_name: Option<String>, /// The project ID of the Google Cloud Platform service that created the log entry. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option<String>, } impl Part for LogEntryMetadata {} @@ -571,10 +571,10 @@ impl Part for LogEntryMetadata {} pub struct ListLogServiceIndexesResponse { /// If there are more results, then `nextPageToken` is returned in the response. To get the next batch of indexes, use the value of `nextPageToken` as `pageToken` in the next call of `ListLogServiceIndexess`. If `nextPageToken` is empty, then there are no more results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of log service index prefixes. #[serde(rename="serviceIndexPrefixes")] - pub service_index_prefixes: Vec<String>, + pub service_index_prefixes: Option<Vec<String>>, } impl ResponseResult for ListLogServiceIndexesResponse {} @@ -637,7 +637,7 @@ impl ResponseResult for Empty {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListLogServiceSinksResponse { /// The requested log service sinks. If any of the returned `LogSink` objects have an empty `destination` field, then call `logServices.sinks.get` to retrieve the complete `LogSink` object. - pub sinks: Vec<LogSink>, + pub sinks: Option<Vec<LogSink>>, } impl ResponseResult for ListLogServiceSinksResponse {} @@ -1133,16 +1133,20 @@ impl<'a, C, A> ProjectLogServiceListCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1408,16 +1412,20 @@ impl<'a, C, A> ProjectLogListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1674,16 +1682,20 @@ impl<'a, C, A> ProjectLogSinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1847,7 +1859,7 @@ impl<'a, C, A> ProjectLogSinkGetCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LogSink = Default::default(); +/// let mut req = LogSink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1943,16 +1955,20 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2129,7 +2145,7 @@ impl<'a, C, A> ProjectLogServiceSinkUpdateCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: WriteLogEntriesRequest = Default::default(); +/// let mut req = WriteLogEntriesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2223,16 +2239,20 @@ impl<'a, C, A> ProjectLogEntryWriteCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2484,16 +2504,20 @@ impl<'a, C, A> ProjectLogServiceSinkDeleteCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2765,16 +2789,20 @@ impl<'a, C, A> ProjectLogServiceIndexeListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3046,16 +3074,20 @@ impl<'a, C, A> ProjectLogSinkListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3209,7 +3241,7 @@ impl<'a, C, A> ProjectLogSinkListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LogSink = Default::default(); +/// let mut req = LogSink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3305,16 +3337,20 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3491,7 +3527,7 @@ impl<'a, C, A> ProjectLogSinkUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LogSink = Default::default(); +/// let mut req = LogSink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3585,16 +3621,20 @@ impl<'a, C, A> ProjectLogServiceSinkCreateCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3846,16 +3886,20 @@ impl<'a, C, A> ProjectLogSinkDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4019,7 +4063,7 @@ impl<'a, C, A> ProjectLogSinkDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LogSink = Default::default(); +/// let mut req = LogSink::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4113,16 +4157,20 @@ impl<'a, C, A> ProjectLogSinkCreateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4374,16 +4422,20 @@ impl<'a, C, A> ProjectLogServiceSinkGetCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4630,16 +4682,20 @@ impl<'a, C, A> ProjectLogServiceSinkListCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4876,16 +4932,20 @@ impl<'a, C, A> ProjectLogDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) diff --git a/gen/manager1_beta2-cli/Cargo.toml b/gen/manager1_beta2-cli/Cargo.toml index 1106476183..134b17c3ee 100644 --- a/gen/manager1_beta2-cli/Cargo.toml +++ b/gen/manager1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-manager1_beta2-cli" version = "0.0.1+20140915" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/deployment-manager/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/manager1_beta2-cli/src/cmn.rs b/gen/manager1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/manager1_beta2-cli/src/cmn.rs +++ b/gen/manager1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/manager1_beta2-cli/src/main.rs b/gen/manager1_beta2-cli/src/main.rs index 3eb3c6412c..66490a2e60 100644 --- a/gen/manager1_beta2-cli/src/main.rs +++ b/gen/manager1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -39,6 +40,12 @@ Configuration: 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. "); mod cmn; @@ -62,7 +69,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().delete(&self.opt.arg_project_id, &self.opt.arg_region, &self.opt.arg_deployment_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -93,7 +100,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -104,7 +110,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().get(&self.opt.arg_project_id, &self.opt.arg_region, &self.opt.arg_deployment_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -136,8 +142,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -146,10 +151,10 @@ impl Engine { fn _deployments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Deployment = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -169,9 +174,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -184,11 +190,11 @@ impl Engine { match &field_name.to_string()[..] { "state.status" => { request_state_init(&mut request); - request.state.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.state.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "state.details" => { request_state_init(&mut request); - request.state.as_mut().unwrap().details = value.unwrap_or("").to_string(); + request.state.as_mut().unwrap().details = Some(value.unwrap_or("").to_string()); }, "creation-date" => { request_state_init(&mut request); @@ -223,8 +229,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -235,7 +240,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.deployments().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -273,8 +278,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -285,7 +289,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.templates().delete(&self.opt.arg_project_id, &self.opt.arg_template_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -316,7 +320,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -327,7 +330,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.templates().get(&self.opt.arg_project_id, &self.opt.arg_template_name); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -359,8 +362,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -369,10 +371,10 @@ impl Engine { fn _templates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Template = Default::default(); + let mut request = api::Template::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -392,9 +394,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -422,8 +425,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -434,7 +436,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.templates().list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -472,8 +474,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -497,7 +498,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_templates { + } + else if self.opt.cmd_templates { if self.opt.cmd_delete { call_result = self._templates_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -529,21 +531,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "manager1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "manager1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "manager1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "manager1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Manager::new(hyper::Client::new(), auth), + hub: api::Manager::new(client, auth), }; match engine._doit(true) { @@ -563,12 +581,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 2844c31fa6..ff33a67d6a 100644 --- a/gen/manager1_beta2/Cargo.toml +++ b/gen/manager1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-manager1_beta2" version = "0.1.5+20140915" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/deployment-manager/" diff --git a/gen/manager1_beta2/src/cmn.rs b/gen/manager1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/manager1_beta2/src/cmn.rs +++ b/gen/manager1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/manager1_beta2/src/lib.rs b/gen/manager1_beta2/src/lib.rs index 36c2940fed..51a0992bcd 100644 --- a/gen/manager1_beta2/src/lib.rs +++ b/gen/manager1_beta2/src/lib.rs @@ -360,24 +360,24 @@ impl<'a, C, A> Manager<C, A> pub struct AutoscalingModule { /// no description provided #[serde(rename="maxNumReplicas")] - pub max_num_replicas: i32, + pub max_num_replicas: Option<i32>, /// no description provided - pub description: String, + pub description: Option<String>, /// no description provided #[serde(rename="targetModule")] - pub target_module: String, + pub target_module: Option<String>, /// target_utilization should be in range [0,1]. #[serde(rename="targetUtilization")] - pub target_utilization: f64, + pub target_utilization: Option<f64>, /// no description provided #[serde(rename="signalType")] - pub signal_type: String, + pub signal_type: Option<String>, /// no description provided #[serde(rename="minNumReplicas")] - pub min_num_replicas: i32, + pub min_num_replicas: Option<i32>, /// no description provided #[serde(rename="coolDownPeriodSec")] - pub cool_down_period_sec: i32, + pub cool_down_period_sec: Option<i32>, } impl Part for AutoscalingModule {} @@ -390,20 +390,20 @@ impl Part for AutoscalingModule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FirewallModule { /// The description of the firewall (optional) - pub description: String, + pub description: Option<String>, /// Target Tags to apply this firewall to, see the GCE Spec for details on syntax #[serde(rename="targetTags")] - pub target_tags: Vec<String>, + pub target_tags: Option<Vec<String>>, /// The allowed ports or port ranges. - pub allowed: Vec<AllowedRule>, + pub allowed: Option<Vec<AllowedRule>>, /// Source Tags to apply this firewall to, see the GCE Spec for details on syntax #[serde(rename="sourceTags")] - pub source_tags: Vec<String>, + pub source_tags: Option<Vec<String>>, /// Source IP ranges to apply this firewall to, see the GCE Spec for details on syntax #[serde(rename="sourceRanges")] - pub source_ranges: Vec<String>, + pub source_ranges: Option<Vec<String>>, /// The NetworkModule to which this firewall should apply. If not specified, or if specified as 'default', this firewall will be applied to the 'default' network. - pub network: String, + pub network: Option<String>, } impl Part for FirewallModule {} @@ -417,12 +417,12 @@ impl Part for FirewallModule {} pub struct AccessConfig { /// Type of this access configuration file. (Currently only ONE_TO_ONE_NAT is legal.) #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Name of this access configuration. - pub name: String, + pub name: Option<String>, /// An external IP address associated with this instance. #[serde(rename="natIp")] - pub nat_ip: String, + pub nat_ip: Option<String>, } impl Part for AccessConfig {} @@ -436,25 +436,25 @@ impl Part for AccessConfig {} pub struct Module { /// no description provided #[serde(rename="lbModule")] - pub lb_module: LbModule, + pub lb_module: Option<LbModule>, /// no description provided #[serde(rename="replicaPoolModule")] - pub replica_pool_module: ReplicaPoolModule, + pub replica_pool_module: Option<ReplicaPoolModule>, /// no description provided #[serde(rename="firewallModule")] - pub firewall_module: FirewallModule, + pub firewall_module: Option<FirewallModule>, /// no description provided #[serde(rename="healthCheckModule")] - pub health_check_module: HealthCheckModule, + pub health_check_module: Option<HealthCheckModule>, /// no description provided #[serde(rename="autoscalingModule")] - pub autoscaling_module: AutoscalingModule, + pub autoscaling_module: Option<AutoscalingModule>, /// no description provided #[serde(rename="networkModule")] - pub network_module: NetworkModule, + pub network_module: Option<NetworkModule>, /// The type of this module. Valid values ("AUTOSCALING", "FIREWALL", "HEALTH_CHECK", "LOAD_BALANCING", "NETWORK", "REPLICA_POOL") #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for Module {} @@ -503,9 +503,9 @@ pub struct DeployState { /// - DELETING /// - DELETED /// - DELETE_FAILED - pub status: String, + pub status: Option<String>, /// [Output Only] Human readable details about the current state. - pub details: String, + pub details: Option<String>, } impl Part for DeployState {} @@ -519,7 +519,7 @@ impl Part for DeployState {} pub struct FirewallModuleStatus { /// [Output Only] The URL of the corresponding Firewall resource. #[serde(rename="firewallUrl")] - pub firewall_url: String, + pub firewall_url: Option<String>, } impl Part for FirewallModuleStatus {} @@ -532,10 +532,10 @@ impl Part for FirewallModuleStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metadata { /// A list of metadata items. - pub items: Vec<MetadataItem>, + pub items: Option<Vec<MetadataItem>>, /// The fingerprint of the metadata. #[serde(rename="fingerPrint")] - pub finger_print: String, + pub finger_print: Option<String>, } impl Part for Metadata {} @@ -549,27 +549,27 @@ impl Part for Metadata {} pub struct ModuleStatus { /// [Output Only] The status of the HealthCheckModule, set for type HEALTH_CHECK. #[serde(rename="healthCheckModuleStatus")] - pub health_check_module_status: HealthCheckModuleStatus, + pub health_check_module_status: Option<HealthCheckModuleStatus>, /// [Output Only] The status of the NetworkModule, set for type NETWORK. #[serde(rename="networkModuleStatus")] - pub network_module_status: NetworkModuleStatus, + pub network_module_status: Option<NetworkModuleStatus>, /// [Output Only] The status of the ReplicaPoolModule, set for type VM. #[serde(rename="replicaPoolModuleStatus")] - pub replica_pool_module_status: ReplicaPoolModuleStatus, + pub replica_pool_module_status: Option<ReplicaPoolModuleStatus>, /// [Output Only] The current state of the module. - pub state: DeployState, + pub state: Option<DeployState>, /// [Output Only] The status of the AutoscalingModule, set for type AUTOSCALING. #[serde(rename="autoscalingModuleStatus")] - pub autoscaling_module_status: AutoscalingModuleStatus, + pub autoscaling_module_status: Option<AutoscalingModuleStatus>, /// [Output Only] The status of the FirewallModule, set for type FIREWALL. #[serde(rename="firewallModuleStatus")] - pub firewall_module_status: FirewallModuleStatus, + pub firewall_module_status: Option<FirewallModuleStatus>, /// [Output Only] The type of the module. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// [Output Only] The status of the LbModule, set for type LOAD_BALANCING. #[serde(rename="lbModuleStatus")] - pub lb_module_status: LbModuleStatus, + pub lb_module_status: Option<LbModuleStatus>, } impl Part for ModuleStatus {} @@ -583,7 +583,7 @@ impl Part for ModuleStatus {} pub struct NetworkModuleStatus { /// [Output Only] The URL of the corresponding Network resource. #[serde(rename="networkUrl")] - pub network_url: String, + pub network_url: Option<String>, } impl Part for NetworkModuleStatus {} @@ -596,9 +596,9 @@ impl Part for NetworkModuleStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EnvVariable { /// Whether this variable is hidden or visible. - pub hidden: bool, + pub hidden: Option<bool>, /// Value of the environment variable. - pub value: String, + pub value: Option<String>, } impl Part for EnvVariable {} @@ -611,9 +611,9 @@ impl Part for EnvVariable {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExistingDisk { /// The fully-qualified URL of the Persistent Disk resource. It must be in the same zone as the Pool. - pub source: String, + pub source: Option<String>, /// Optional. How the disk will be attached to the Replica. - pub attachment: DiskAttachment, + pub attachment: Option<DiskAttachment>, } impl Part for ExistingDisk {} @@ -626,7 +626,7 @@ impl Part for ExistingDisk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReplicaPoolParams { /// ReplicaPoolParams specifications for use with ReplicaPools v1beta1. - pub v1beta1: ReplicaPoolParamsV1Beta1, + pub v1beta1: Option<ReplicaPoolParamsV1Beta1>, } impl Part for ReplicaPoolParams {} @@ -645,9 +645,9 @@ impl Part for ReplicaPoolParams {} pub struct TemplatesListResponse { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// no description provided - pub resources: Vec<Template>, + pub resources: Option<Vec<Template>>, } impl ResponseResult for TemplatesListResponse {} @@ -666,9 +666,9 @@ impl ResponseResult for TemplatesListResponse {} pub struct DeploymentsListResponse { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// no description provided - pub resources: Vec<Deployment>, + pub resources: Option<Vec<Deployment>>, } impl ResponseResult for DeploymentsListResponse {} @@ -719,13 +719,13 @@ impl ResponseResult for Deployment {} pub struct NewDiskInitializeParams { /// The size of the created disk in gigabytes. #[serde(rename="diskSizeGb")] - pub disk_size_gb: String, + pub disk_size_gb: Option<String>, /// The fully-qualified URL of a source image to use to create this disk. #[serde(rename="sourceImage")] - pub source_image: String, + pub source_image: Option<String>, /// Name of the disk type resource describing which disk type to use to create the disk. For example 'pd-ssd' or 'pd-standard'. Default is 'pd-standard' #[serde(rename="diskType")] - pub disk_type: String, + pub disk_type: Option<String>, } impl Part for NewDiskInitializeParams {} @@ -739,12 +739,12 @@ impl Part for NewDiskInitializeParams {} pub struct NetworkModule { /// Required; The range of internal addresses that are legal on this network. This range is a CIDR specification, for example: 192.168.0.0/16. #[serde(rename="IPv4Range")] - pub i_pv4_range: String, + pub i_pv4_range: Option<String>, /// An optional address that is used for default routing to other networks. This must be within the range specified by IPv4Range, and is typicall the first usable address in that range. If not specified, the default value is the first usable address in IPv4Range. #[serde(rename="gatewayIPv4")] - pub gateway_i_pv4: String, + pub gateway_i_pv4: Option<String>, /// The description of the network. - pub description: String, + pub description: Option<String>, } impl Part for NetworkModule {} @@ -758,42 +758,42 @@ impl Part for NetworkModule {} pub struct ReplicaPoolParamsV1Beta1 { /// A list of Disk resources to create and attach to each Replica in the Pool. Currently, you can only define one disk and it must be a root persistent disk. Note that Replica Pool will create a root persistent disk for each replica. #[serde(rename="disksToCreate")] - pub disks_to_create: Vec<NewDisk>, + pub disks_to_create: Option<Vec<NewDisk>>, /// Whether these replicas should be restarted if they experience a failure. The default value is true. #[serde(rename="autoRestart")] - pub auto_restart: bool, + pub auto_restart: Option<bool>, /// Enables IP Forwarding #[serde(rename="canIpForward")] - pub can_ip_forward: bool, + pub can_ip_forward: Option<bool>, /// An optional textual description of the resource. - pub description: String, + pub description: Option<String>, /// The zone for this ReplicaPool. - pub zone: String, + pub zone: Option<String>, /// A list of tags to apply to the Google Compute Engine instance to identify resources. - pub tags: Tag, + pub tags: Option<Tag>, /// no description provided #[serde(rename="onHostMaintenance")] - pub on_host_maintenance: String, + pub on_host_maintenance: Option<String>, /// A list of existing Persistent Disk resources to attach to each replica in the pool. Each disk will be attached in read-only mode to every replica. #[serde(rename="disksToAttach")] - pub disks_to_attach: Vec<ExistingDisk>, + pub disks_to_attach: Option<Vec<ExistingDisk>>, /// The machine type for this instance. Either a complete URL, or the resource name (e.g. n1-standard-1). #[serde(rename="machineType")] - pub machine_type: String, + pub machine_type: Option<String>, /// The base name for instances within this ReplicaPool. #[serde(rename="baseInstanceName")] - pub base_instance_name: String, + pub base_instance_name: Option<String>, /// Name of the Action to be run during initialization of a ReplicaPoolModule. #[serde(rename="initAction")] - pub init_action: String, + pub init_action: Option<String>, /// The metadata key/value pairs assigned to this instance. - pub metadata: Metadata, + pub metadata: Option<Metadata>, /// A list of Service Accounts to enable for this instance. #[serde(rename="serviceAccounts")] - pub service_accounts: Vec<ServiceAccount>, + pub service_accounts: Option<Vec<ServiceAccount>>, /// A list of network interfaces for the instance. Currently only one interface is supported by Google Compute Engine. #[serde(rename="networkInterfaces")] - pub network_interfaces: Vec<NetworkInterface>, + pub network_interfaces: Option<Vec<NetworkInterface>>, } impl Part for ReplicaPoolParamsV1Beta1 {} @@ -806,9 +806,9 @@ impl Part for ReplicaPoolParamsV1Beta1 {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ParamOverride { /// A JSON Path expression that specifies which parameter should be overridden. - pub path: String, + pub path: Option<String>, /// The new value to assign to the overridden parameter. - pub value: String, + pub value: Option<String>, } impl Part for ParamOverride {} @@ -822,10 +822,10 @@ impl Part for ParamOverride {} pub struct ReplicaPoolModuleStatus { /// [Output Only] The URL of the Resource Group associated with this ReplicaPool. #[serde(rename="resourceViewUrl")] - pub resource_view_url: String, + pub resource_view_url: Option<String>, /// [Output Only] The URL of the associated ReplicaPool resource. #[serde(rename="replicaPoolUrl")] - pub replica_pool_url: String, + pub replica_pool_url: Option<String>, } impl Part for ReplicaPoolModuleStatus {} @@ -838,9 +838,9 @@ impl Part for ReplicaPoolModuleStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ServiceAccount { /// List of OAuth2 scopes to obtain for the service account. - pub scopes: Vec<String>, + pub scopes: Option<Vec<String>>, /// Service account email address. - pub email: String, + pub email: Option<String>, } impl Part for ServiceAccount {} @@ -854,14 +854,14 @@ impl Part for ServiceAccount {} pub struct NetworkInterface { /// An array of configurations for this interface. This specifies how this interface is configured to interact with other network services #[serde(rename="accessConfigs")] - pub access_configs: Vec<AccessConfig>, + pub access_configs: Option<Vec<AccessConfig>>, /// An optional IPV4 internal network address to assign to the instance for this network interface. #[serde(rename="networkIp")] - pub network_ip: String, + pub network_ip: Option<String>, /// Name of the interface. - pub name: String, + pub name: Option<String>, /// The name of the NetworkModule to which this interface applies. If not specified, or specified as 'default', this will use the 'default' network. - pub network: String, + pub network: Option<String>, } impl Part for NetworkInterface {} @@ -875,9 +875,9 @@ impl Part for NetworkInterface {} pub struct Action { /// The timeout in milliseconds for this action to run. #[serde(rename="timeoutMs")] - pub timeout_ms: i32, + pub timeout_ms: Option<i32>, /// A list of commands to run sequentially for this action. - pub commands: Vec<String>, + pub commands: Option<Vec<String>>, } impl Part for Action {} @@ -891,7 +891,7 @@ impl Part for Action {} pub struct AutoscalingModuleStatus { /// [Output Only] The URL of the corresponding Autoscaling configuration. #[serde(rename="autoscalingConfigUrl")] - pub autoscaling_config_url: String, + pub autoscaling_config_url: Option<String>, } impl Part for AutoscalingModuleStatus {} @@ -905,10 +905,10 @@ impl Part for AutoscalingModuleStatus {} pub struct LbModuleStatus { /// [Output Only] The URL of the corresponding ForwardingRule in GCE. #[serde(rename="forwardingRuleUrl")] - pub forwarding_rule_url: String, + pub forwarding_rule_url: Option<String>, /// [Output Only] The URL of the corresponding TargetPool resource in GCE. #[serde(rename="targetPoolUrl")] - pub target_pool_url: String, + pub target_pool_url: Option<String>, } impl Part for LbModuleStatus {} @@ -921,25 +921,25 @@ impl Part for LbModuleStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LbModule { /// no description provided - pub description: String, + pub description: Option<String>, /// no description provided #[serde(rename="healthChecks")] - pub health_checks: Vec<String>, + pub health_checks: Option<Vec<String>>, /// no description provided #[serde(rename="portRange")] - pub port_range: String, + pub port_range: Option<String>, /// no description provided #[serde(rename="targetModules")] - pub target_modules: Vec<String>, + pub target_modules: Option<Vec<String>>, /// no description provided #[serde(rename="ipAddress")] - pub ip_address: String, + pub ip_address: Option<String>, /// no description provided #[serde(rename="ipProtocol")] - pub ip_protocol: String, + pub ip_protocol: Option<String>, /// no description provided #[serde(rename="sessionAffinity")] - pub session_affinity: String, + pub session_affinity: Option<String>, } impl Part for LbModule {} @@ -953,7 +953,7 @@ impl Part for LbModule {} pub struct HealthCheckModuleStatus { /// [Output Only] The HealthCheck URL. #[serde(rename="healthCheckUrl")] - pub health_check_url: String, + pub health_check_url: Option<String>, } impl Part for HealthCheckModuleStatus {} @@ -966,25 +966,25 @@ impl Part for HealthCheckModuleStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct HealthCheckModule { /// no description provided - pub description: String, + pub description: Option<String>, /// no description provided #[serde(rename="timeoutSec")] - pub timeout_sec: i32, + pub timeout_sec: Option<i32>, /// no description provided #[serde(rename="checkIntervalSec")] - pub check_interval_sec: i32, + pub check_interval_sec: Option<i32>, /// no description provided #[serde(rename="unhealthyThreshold")] - pub unhealthy_threshold: i32, + pub unhealthy_threshold: Option<i32>, /// no description provided #[serde(rename="healthyThreshold")] - pub healthy_threshold: i32, + pub healthy_threshold: Option<i32>, /// no description provided - pub host: String, + pub host: Option<String>, /// no description provided - pub path: String, + pub path: Option<String>, /// no description provided - pub port: i32, + pub port: Option<i32>, } impl Part for HealthCheckModule {} @@ -997,15 +997,15 @@ impl Part for HealthCheckModule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NewDisk { /// If true, indicates that this is the root persistent disk. - pub boot: bool, + pub boot: Option<bool>, /// Create the new disk using these parameters. The name of the disk will be <instance_name>-<five_random_charactersgt;. #[serde(rename="initializeParams")] - pub initialize_params: NewDiskInitializeParams, + pub initialize_params: Option<NewDiskInitializeParams>, /// How the disk will be attached to the Replica. - pub attachment: DiskAttachment, + pub attachment: Option<DiskAttachment>, /// If true, then this disk will be deleted when the instance is deleted. #[serde(rename="autoDelete")] - pub auto_delete: bool, + pub auto_delete: Option<bool>, } impl Part for NewDisk {} @@ -1019,9 +1019,9 @@ impl Part for NewDisk {} pub struct AllowedRule { /// ?tcp?, ?udp? or ?icmp? #[serde(rename="IPProtocol")] - pub ip_protocol: String, + pub ip_protocol: Option<String>, /// List of ports or port ranges (Example inputs include: ["22"], [?33?, "12345-12349"]. - pub ports: Vec<String>, + pub ports: Option<Vec<String>>, } impl Part for AllowedRule {} @@ -1034,10 +1034,10 @@ impl Part for AllowedRule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Tag { /// Items contained in this tag. - pub items: Vec<String>, + pub items: Option<Vec<String>>, /// The fingerprint of the tag. #[serde(rename="fingerPrint")] - pub finger_print: String, + pub finger_print: Option<String>, } impl Part for Tag {} @@ -1051,19 +1051,19 @@ impl Part for Tag {} pub struct ReplicaPoolModule { /// The Health Checks to configure for the ReplicaPoolModule #[serde(rename="healthChecks")] - pub health_checks: Vec<String>, + pub health_checks: Option<Vec<String>>, /// Information for a ReplicaPoolModule. #[serde(rename="replicaPoolParams")] - pub replica_pool_params: ReplicaPoolParams, + pub replica_pool_params: Option<ReplicaPoolParams>, /// [Output Only] The name of the Resource View associated with a ReplicaPoolModule. This field will be generated by the service. #[serde(rename="resourceView")] - pub resource_view: String, + pub resource_view: Option<String>, /// Number of replicas in this module. #[serde(rename="numReplicas")] - pub num_replicas: i32, + pub num_replicas: Option<i32>, /// A list of environment variables. #[serde(rename="envVariables")] - pub env_variables: HashMap<String, EnvVariable>, + pub env_variables: Option<HashMap<String, EnvVariable>>, } impl Part for ReplicaPoolModule {} @@ -1076,9 +1076,9 @@ impl Part for ReplicaPoolModule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetadataItem { /// A metadata key. - pub key: String, + pub key: Option<String>, /// A metadata value. - pub value: String, + pub value: Option<String>, } impl Part for MetadataItem {} @@ -1092,9 +1092,9 @@ impl Part for MetadataItem {} pub struct DiskAttachment { /// The device name of this disk. #[serde(rename="deviceName")] - pub device_name: String, + pub device_name: Option<String>, /// A zero-based index to assign to this disk, where 0 is reserved for the boot disk. If not specified, this is assigned by the server. - pub index: u32, + pub index: Option<u32>, } impl Part for DiskAttachment {} @@ -1471,16 +1471,20 @@ impl<'a, C, A> TemplateListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1715,16 +1719,20 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1862,7 +1870,7 @@ impl<'a, C, A> TemplateDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Template = Default::default(); +/// let mut req = Template::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1954,16 +1962,20 @@ impl<'a, C, A> TemplateInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2198,16 +2210,20 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2355,7 +2371,7 @@ impl<'a, C, A> TemplateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Deployment = Default::default(); +/// let mut req = Deployment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2449,16 +2465,20 @@ impl<'a, C, A> DeploymentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2704,16 +2724,20 @@ impl<'a, C, A> DeploymentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2963,16 +2987,20 @@ impl<'a, C, A> DeploymentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3218,16 +3246,20 @@ impl<'a, C, A> DeploymentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) diff --git a/gen/mapsengine1-cli/Cargo.toml b/gen/mapsengine1-cli/Cargo.toml index b6c88d6374..fba749cdfe 100644 --- a/gen/mapsengine1-cli/Cargo.toml +++ b/gen/mapsengine1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-mapsengine1-cli" -version = "0.0.1+20150225" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/maps-engine/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/mapsengine1-cli/mkdocs.yml b/gen/mapsengine1-cli/mkdocs.yml index 206f5871f5..9d65a5c3d0 100644 --- a/gen/mapsengine1-cli/mkdocs.yml +++ b/gen/mapsengine1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Maps Engine v0.0.1+20150225 +site_name: Maps Engine v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/mapsengine1-cli/src/cmn.rs +++ b/gen/mapsengine1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/mapsengine1-cli/src/main.rs b/gen/mapsengine1-cli/src/main.rs index 882ff7e4b8..f23f5248ee 100644 --- a/gen/mapsengine1-cli/src/main.rs +++ b/gen/mapsengine1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -108,6 +109,12 @@ Configuration: 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. "); mod cmn; @@ -131,7 +138,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.assets().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -163,8 +170,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -175,7 +181,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.assets().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); @@ -246,8 +252,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -258,7 +263,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.assets().parents_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -296,8 +301,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -308,7 +312,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.assets().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -340,8 +344,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -352,7 +355,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().cancel_processing(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -384,8 +387,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -394,10 +396,10 @@ impl Engine { fn _layers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Layer = Default::default(); + 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); + 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")); @@ -420,12 +422,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_style_feature_info_init(request: &mut api::Layer) { + request_style_init(request); + if request.style.as_mut().unwrap().feature_info.is_none() { + request.style.as_mut().unwrap().feature_info = Some(Default::default()); + } + } + fn request_style_init(request: &mut api::Layer) { if request.style.is_none() { request.style = Some(Default::default()); @@ -434,12 +444,12 @@ impl Engine { match &field_name.to_string()[..] { "style.feature-info.content" => { - request_style_init(&mut request); - request.style.as_mut().unwrap().feature_info.content = value.unwrap_or("").to_string(); + request_style_feature_info_init(&mut request); + request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "style.type" => { - request_style_init(&mut request); - request.style.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request_style_feature_info_init(&mut request); + request.style.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "description" => { request_style_init(&mut request); @@ -480,9 +490,9 @@ impl Engine { "bbox" => { request_style_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "layer-type" => { request_style_init(&mut request); @@ -529,8 +539,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -541,7 +550,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -572,7 +581,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -583,7 +591,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); @@ -618,8 +626,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -630,7 +637,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().get_published(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -662,8 +669,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -674,7 +680,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -745,8 +751,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -757,7 +762,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().list_published(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "project-id" => { call = call.project_id(value.unwrap_or("")); @@ -798,8 +803,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -810,7 +814,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().parents_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -848,8 +852,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -858,10 +861,10 @@ impl Engine { fn _layers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Layer = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -881,12 +884,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_style_feature_info_init(request: &mut api::Layer) { + request_style_init(request); + if request.style.as_mut().unwrap().feature_info.is_none() { + request.style.as_mut().unwrap().feature_info = Some(Default::default()); + } + } + fn request_style_init(request: &mut api::Layer) { if request.style.is_none() { request.style = Some(Default::default()); @@ -895,12 +906,12 @@ impl Engine { match &field_name.to_string()[..] { "style.feature-info.content" => { - request_style_init(&mut request); - request.style.as_mut().unwrap().feature_info.content = value.unwrap_or("").to_string(); + request_style_feature_info_init(&mut request); + request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "style.type" => { - request_style_init(&mut request); - request.style.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request_style_feature_info_init(&mut request); + request.style.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "description" => { request_style_init(&mut request); @@ -941,9 +952,9 @@ impl Engine { "bbox" => { request_style_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "layer-type" => { request_style_init(&mut request); @@ -989,7 +1000,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -998,10 +1008,10 @@ impl Engine { fn _layers_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchDeleteRequest = Default::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1021,18 +1031,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1051,8 +1062,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1061,10 +1071,10 @@ impl Engine { fn _layers_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchUpdateRequest = Default::default(); + let mut request = api::PermissionsBatchUpdateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1084,9 +1094,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1108,8 +1119,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1120,7 +1130,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1152,8 +1162,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1164,7 +1173,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().process(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1196,8 +1205,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1208,7 +1216,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().publish(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "force" => { call = call.force(arg_from_str(value.unwrap_or("false"), err, "force", "boolean")); @@ -1243,8 +1251,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1255,7 +1262,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.layers().unpublish(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1287,8 +1294,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1297,10 +1303,10 @@ impl Engine { fn _maps_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Map = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1320,9 +1326,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1341,9 +1348,9 @@ impl Engine { }, "versions" => { if request.versions.is_none() { - request.versions = Some(Default::default()); + request.versions = Some(Default::default()); } - request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); @@ -1362,9 +1369,9 @@ impl Engine { }, "bbox" => { if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); @@ -1398,8 +1405,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1410,7 +1416,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1441,7 +1447,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1452,7 +1457,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); @@ -1487,8 +1492,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1499,7 +1503,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().get_published(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1531,8 +1535,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1543,7 +1546,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -1614,8 +1617,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1626,7 +1628,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().list_published(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "project-id" => { call = call.project_id(value.unwrap_or("")); @@ -1667,8 +1669,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1677,10 +1678,10 @@ impl Engine { fn _maps_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Map = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1700,9 +1701,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1721,9 +1723,9 @@ impl Engine { }, "versions" => { if request.versions.is_none() { - request.versions = Some(Default::default()); + request.versions = Some(Default::default()); } - request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); @@ -1742,9 +1744,9 @@ impl Engine { }, "bbox" => { if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); @@ -1777,7 +1779,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1786,10 +1787,10 @@ impl Engine { fn _maps_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchDeleteRequest = Default::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1809,18 +1810,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -1839,8 +1841,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1849,10 +1850,10 @@ impl Engine { fn _maps_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchUpdateRequest = Default::default(); + let mut request = api::PermissionsBatchUpdateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1872,9 +1873,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1896,8 +1898,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1908,7 +1909,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1940,8 +1941,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1952,7 +1952,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().publish(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "force" => { call = call.force(arg_from_str(value.unwrap_or("false"), err, "force", "boolean")); @@ -1987,8 +1987,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1999,7 +1998,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.maps().unpublish(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2031,8 +2030,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2041,10 +2039,10 @@ impl Engine { fn _projects_icons_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Icon = Default::default(); + let mut request = api::Icon::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2064,9 +2062,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2107,8 +2106,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2120,7 +2118,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.projects().icons_get(&self.opt.arg_project_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2155,9 +2153,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -2171,7 +2168,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().icons_list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2209,8 +2206,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2221,7 +2217,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2253,8 +2249,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2265,7 +2260,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().cancel_processing(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2297,8 +2292,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2307,10 +2301,10 @@ impl Engine { fn _raster_collections_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RasterCollection = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2330,9 +2324,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2369,9 +2364,9 @@ impl Engine { }, "bbox" => { if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); @@ -2405,8 +2400,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2417,7 +2411,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2448,7 +2442,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2459,7 +2452,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2491,8 +2484,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2503,7 +2495,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -2574,8 +2566,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2586,7 +2577,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().parents_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2624,8 +2615,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2634,10 +2624,10 @@ impl Engine { fn _raster_collections_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RasterCollection = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2657,9 +2647,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2696,9 +2687,9 @@ impl Engine { }, "bbox" => { if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); @@ -2731,7 +2722,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2740,10 +2730,10 @@ impl Engine { fn _raster_collections_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchDeleteRequest = Default::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2763,18 +2753,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -2793,8 +2784,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2803,10 +2793,10 @@ impl Engine { fn _raster_collections_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchUpdateRequest = Default::default(); + let mut request = api::PermissionsBatchUpdateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2826,9 +2816,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2850,8 +2841,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2862,7 +2852,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2894,8 +2884,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2906,7 +2895,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().process(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2938,8 +2927,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2948,10 +2936,10 @@ impl Engine { fn _raster_collections_rasters_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RasterCollectionsRasterBatchDeleteRequest = Default::default(); + let mut request = api::RasterCollectionsRasterBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2971,18 +2959,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -3001,8 +2990,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3011,10 +2999,10 @@ impl Engine { fn _raster_collections_rasters_batch_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RasterCollectionsRastersBatchInsertRequest = Default::default(); + let mut request = api::RasterCollectionsRastersBatchInsertRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3034,18 +3022,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -3064,8 +3053,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3076,7 +3064,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.raster_collections().rasters_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -3141,8 +3129,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3153,7 +3140,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3184,7 +3171,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3195,7 +3181,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().files_insert(&self.opt.arg_id, &self.opt.arg_filename); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3236,7 +3222,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3247,7 +3232,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3279,8 +3264,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3291,7 +3275,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().list(&self.opt.arg_project_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -3359,8 +3343,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3371,7 +3354,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().parents_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -3409,8 +3392,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3419,10 +3401,10 @@ impl Engine { fn _rasters_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Raster = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3442,9 +3424,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3457,15 +3440,15 @@ impl Engine { match &field_name.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "acquisition-time.end" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "acquisition-time.precision" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().precision = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().precision = Some(value.unwrap_or("").to_string()); }, "attribution" => { request_acquisition_time_init(&mut request); @@ -3510,9 +3493,9 @@ impl Engine { "bbox" => { request_acquisition_time_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_acquisition_time_init(&mut request); @@ -3550,7 +3533,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3559,10 +3541,10 @@ impl Engine { fn _rasters_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchDeleteRequest = Default::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3582,18 +3564,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -3612,8 +3595,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3622,10 +3604,10 @@ impl Engine { fn _rasters_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchUpdateRequest = Default::default(); + let mut request = api::PermissionsBatchUpdateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3645,9 +3627,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3669,8 +3652,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3681,7 +3663,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3713,8 +3695,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3725,7 +3706,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rasters().process(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3757,8 +3738,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3767,10 +3747,10 @@ impl Engine { fn _rasters_upload(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Raster = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3790,9 +3770,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3805,15 +3786,15 @@ impl Engine { match &field_name.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().start = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "acquisition-time.end" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().end = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "acquisition-time.precision" => { request_acquisition_time_init(&mut request); - request.acquisition_time.as_mut().unwrap().precision = value.unwrap_or("").to_string(); + request.acquisition_time.as_mut().unwrap().precision = Some(value.unwrap_or("").to_string()); }, "attribution" => { request_acquisition_time_init(&mut request); @@ -3858,9 +3839,9 @@ impl Engine { "bbox" => { request_acquisition_time_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_acquisition_time_init(&mut request); @@ -3899,8 +3880,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3909,10 +3889,10 @@ impl Engine { fn _tables_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + let mut request = api::Table::default(); let mut call = self.hub.tables().create(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3932,9 +3912,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3947,11 +3928,11 @@ impl Engine { match &field_name.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_geometry = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_key = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); @@ -3992,9 +3973,9 @@ impl Engine { "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); @@ -4033,8 +4014,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4045,7 +4025,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4076,7 +4056,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4085,10 +4064,10 @@ impl Engine { fn _tables_features_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FeaturesBatchDeleteRequest = Default::default(); + let mut request = api::FeaturesBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4108,24 +4087,25 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.gx_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = Some(Default::default()); } - request.primary_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.primary_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -4143,7 +4123,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4152,10 +4131,10 @@ impl Engine { fn _tables_features_batch_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FeaturesBatchInsertRequest = Default::default(); + let mut request = api::FeaturesBatchInsertRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4175,9 +4154,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4201,7 +4181,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4210,10 +4189,10 @@ impl Engine { fn _tables_features_batch_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::FeaturesBatchPatchRequest = Default::default(); + let mut request = api::FeaturesBatchPatchRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4233,9 +4212,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4259,7 +4239,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4270,7 +4249,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().features_get(&self.opt.arg_table_id, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); @@ -4308,8 +4287,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4320,7 +4298,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().features_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "where" => { call = call.where_(value.unwrap_or("")); @@ -4379,8 +4357,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4391,7 +4368,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().files_insert(&self.opt.arg_id, &self.opt.arg_filename); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4432,7 +4409,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4443,7 +4419,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); @@ -4478,8 +4454,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4490,7 +4465,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); @@ -4561,8 +4536,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4573,7 +4547,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().parents_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4611,8 +4585,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4621,10 +4594,10 @@ impl Engine { fn _tables_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4644,9 +4617,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4659,11 +4633,11 @@ impl Engine { match &field_name.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_geometry = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_key = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); @@ -4704,9 +4678,9 @@ impl Engine { "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); @@ -4744,7 +4718,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4753,10 +4726,10 @@ impl Engine { fn _tables_permissions_batch_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchDeleteRequest = Default::default(); + let mut request = api::PermissionsBatchDeleteRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4776,18 +4749,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -4806,8 +4780,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4816,10 +4789,10 @@ impl Engine { fn _tables_permissions_batch_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PermissionsBatchUpdateRequest = Default::default(); + let mut request = api::PermissionsBatchUpdateRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4839,9 +4812,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4863,8 +4837,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4875,7 +4848,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().permissions_list(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4907,8 +4880,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4919,7 +4891,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tables().process(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4951,8 +4923,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4961,10 +4932,10 @@ impl Engine { fn _tables_upload(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Table = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4984,9 +4955,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4999,11 +4971,11 @@ impl Engine { match &field_name.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_geometry = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); - request.schema.as_mut().unwrap().primary_key = value.unwrap_or("").to_string(); + request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); @@ -5044,9 +5016,9 @@ impl Engine { "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { - request.bbox = Some(Default::default()); + request.bbox = Some(Default::default()); } - request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); + request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); @@ -5085,8 +5057,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5110,7 +5081,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_layers { + } + else if self.opt.cmd_layers { if self.opt.cmd_cancel_processing { call_result = self._layers_cancel_processing(dry_run, &mut err); } else if self.opt.cmd_create { @@ -5144,7 +5116,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_maps { + } + else if self.opt.cmd_maps { if self.opt.cmd_create { call_result = self._maps_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -5172,7 +5145,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_projects { + } + else if self.opt.cmd_projects { if self.opt.cmd_icons_create { call_result = self._projects_icons_create(dry_run, &mut err); } else if self.opt.cmd_icons_get { @@ -5184,7 +5158,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_raster_collections { + } + else if self.opt.cmd_raster_collections { if self.opt.cmd_cancel_processing { call_result = self._raster_collections_cancel_processing(dry_run, &mut err); } else if self.opt.cmd_create { @@ -5216,7 +5191,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_rasters { + } + else if self.opt.cmd_rasters { if self.opt.cmd_delete { call_result = self._rasters_delete(dry_run, &mut err); } else if self.opt.cmd_files_insert { @@ -5242,7 +5218,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_tables { + } + else if self.opt.cmd_tables { if self.opt.cmd_create { call_result = self._tables_create(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -5300,21 +5277,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "mapsengine1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "mapsengine1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "mapsengine1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "mapsengine1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::MapsEngine::new(hyper::Client::new(), auth), + hub: api::MapsEngine::new(client, auth), }; match engine._doit(true) { @@ -5334,12 +5327,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/mapsengine1/Cargo.toml b/gen/mapsengine1/Cargo.toml index 23be3b803c..10ba781eda 100644 --- a/gen/mapsengine1/Cargo.toml +++ b/gen/mapsengine1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-mapsengine1" -version = "0.1.5+20150225" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/maps-engine/" diff --git a/gen/mapsengine1/README.md b/gen/mapsengine1/README.md index e0c014be14..4067e4db4e 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+20150225*, where *20150225* 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.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*. Everything else about the *Maps Engine* *v1* API can be found at the [official documentation site](https://developers.google.com/maps-engine/). diff --git a/gen/mapsengine1/src/cmn.rs b/gen/mapsengine1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/mapsengine1/src/cmn.rs +++ b/gen/mapsengine1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/mapsengine1/src/lib.rs b/gen/mapsengine1/src/lib.rs index 8d921b8a90..9ae89c4829 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+20150225*, where *20150225* 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.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*. //! //! Everything else about the *Maps Engine* *v1* API can be found at the //! [official documentation site](https://developers.google.com/maps-engine/). @@ -413,27 +413,27 @@ impl<'a, C, A> MapsEngine<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RasterCollectionsRaster { /// The description of this Raster, supplied by the author. - pub description: String, + pub description: Option<String>, /// Tags of this Raster. - pub tags: Vec<String>, + pub tags: Option<Vec<String>>, /// The ID of the project that this Raster is in. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option<String>, /// The creation time of this raster. The value is an RFC 3339 formatted date-time value (e.g. 1970-01-01T00:00:00Z). #[serde(rename="creationTime")] - pub creation_time: String, + pub creation_time: Option<String>, /// The name of this Raster, supplied by the author. - pub name: String, + pub name: Option<String>, /// A rectangular bounding box which contains all of the data in this Raster. The box is expressed as \"west, south, east, north\". The numbers represent latitudes and longitudes in decimal degrees. - pub bbox: Vec<f64>, + pub bbox: Option<Vec<f64>>, /// The last modified time of this raster. The value is an RFC 3339 formatted date-time value (e.g. 1970-01-01T00:00:00Z). #[serde(rename="lastModifiedTime")] - pub last_modified_time: String, + pub last_modified_time: Option<String>, /// A globally unique ID, used to refer to this Raster. - pub id: String, + pub id: Option<String>, /// The type of this Raster. Always "image" today. #[serde(rename="rasterType")] - pub raster_type: String, + pub raster_type: Option<String>, } impl Part for RasterCollectionsRaster {} @@ -447,20 +447,20 @@ impl Part for RasterCollectionsRaster {} pub struct DisplayRule { /// The zoom levels that this display rule apply. #[serde(rename="zoomLevels")] - pub zoom_levels: ZoomLevels, + pub zoom_levels: Option<ZoomLevels>, /// Style applied to points. Required for Point Geometry. #[serde(rename="pointOptions")] - pub point_options: PointStyle, + pub point_options: Option<PointStyle>, /// Display rule name. Name is not unique and cannot be used for identification purpose. - pub name: String, + pub name: Option<String>, /// Style applied to polygons. Required for Polygon Geometry. #[serde(rename="polygonOptions")] - pub polygon_options: PolygonStyle, + pub polygon_options: Option<PolygonStyle>, /// Style applied to lines. Required for LineString Geometry. #[serde(rename="lineOptions")] - pub line_options: LineStyle, + pub line_options: Option<LineStyle>, /// This display rule will only be applied to features that match all of the filters here. If filters is empty, then the rule applies to all features. - pub filters: Vec<Filter>, + pub filters: Option<Vec<Filter>>, } impl Part for DisplayRule {} @@ -522,40 +522,40 @@ impl RequestValue for RasterCollectionsRasterBatchDeleteRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Asset { /// The URL to query to retrieve the asset's complete object. The assets endpoint only returns high-level information about a resource. - pub resource: String, + pub resource: Option<String>, /// The asset's description. - pub description: String, + pub description: Option<String>, /// An array of text strings, with each string representing a tag. More information about tags can be found in the Tagging data article of the Maps Engine help center. - pub tags: Vec<String>, + pub tags: Option<Vec<String>>, /// The ID of the project to which the asset belongs. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option<String>, /// The creation time of this asset. The value is an RFC 3339-formatted date-time value (for example, 1970-01-01T00:00:00Z). #[serde(rename="creationTime")] - pub creation_time: String, + pub creation_time: Option<String>, /// If true, WRITERs of the asset are able to edit the asset permissions. #[serde(rename="writersCanEditPermissions")] - pub writers_can_edit_permissions: bool, + pub writers_can_edit_permissions: Option<bool>, /// The ETag, used to refer to the current version of the asset. - pub etag: String, + pub etag: Option<String>, /// The email address of the creator of this asset. This is only returned on GET requests and not LIST requests. #[serde(rename="creatorEmail")] - pub creator_email: String, + pub creator_email: Option<String>, /// A rectangular bounding box which contains all of the data in this asset. The box is expressed as \"west, south, east, north\". The numbers represent latitude and longitude in decimal degrees. - pub bbox: Vec<f64>, + pub bbox: Option<Vec<f64>>, /// The email address of the last modifier of this asset. This is only returned on GET requests and not LIST requests. #[serde(rename="lastModifierEmail")] - pub last_modifier_email: String, + pub last_modifier_email: Option<String>, /// The last modified time of this asset. The value is an RFC 3339-formatted date-time value (for example, 1970-01-01T00:00:00Z). #[serde(rename="lastModifiedTime")] - pub last_modified_time: String, + pub last_modified_time: Option<String>, /// The type of asset. One of raster, rasterCollection, table, map, or layer. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The asset's globally unique ID. - pub id: String, + pub id: Option<String>, /// The asset's name. - pub name: String, + pub name: Option<String>, } impl Resource for Asset {} @@ -575,10 +575,10 @@ impl ResponseResult for Asset {} pub struct RasterCollectionsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. #[serde(rename="rasterCollections")] - pub raster_collections: Vec<RasterCollection>, + pub raster_collections: Option<Vec<RasterCollection>>, } impl ResponseResult for RasterCollectionsListResponse {} @@ -592,9 +592,9 @@ impl ResponseResult for RasterCollectionsListResponse {} pub struct GeoJsonMultiPoint { /// Identifies this object as a GeoJsonMultiPoint. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of at least two GeoJsonPoint coordinate arrays. - pub coordinates: Vec<GeoJsonPosition>, + pub coordinates: Option<Vec<GeoJsonPosition>>, } impl Part for GeoJsonMultiPoint {} @@ -608,9 +608,9 @@ impl Part for GeoJsonMultiPoint {} pub struct GeoJsonMultiLineString { /// Identifies this object as a GeoJsonMultiLineString. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of at least two GeoJsonLineString coordinate arrays. - pub coordinates: Vec<Vec<GeoJsonPosition>>, + pub coordinates: Option<Vec<Vec<GeoJsonPosition>>>, } impl Part for GeoJsonMultiLineString {} @@ -623,7 +623,7 @@ impl Part for GeoJsonMultiLineString {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Parent { /// The ID of this parent. - pub id: String, + pub id: Option<String>, } impl Part for Parent {} @@ -652,9 +652,9 @@ impl ResponseResult for RasterCollectionsRastersBatchDeleteResponse {} pub struct TableColumn { /// The type of data stored in this column. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The column name. - pub name: String, + pub name: Option<String>, } impl Part for TableColumn {} @@ -672,7 +672,7 @@ impl Part for TableColumn {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProjectsListResponse { /// Projects returned. - pub projects: Vec<Project>, + pub projects: Option<Vec<Project>>, } impl ResponseResult for ProjectsListResponse {} @@ -691,17 +691,17 @@ impl ResponseResult for ProjectsListResponse {} pub struct FeaturesListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// An indicator of the maximum rate at which queries may be made, if all queries were as expensive as this query. #[serde(rename="allowedQueriesPerSecond")] - pub allowed_queries_per_second: f64, + pub allowed_queries_per_second: Option<f64>, /// no description provided #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Resources returned. - pub features: Vec<Feature>, + pub features: Option<Vec<Feature>>, /// The feature schema. - pub schema: Schema, + pub schema: Option<Schema>, } impl ResponseResult for FeaturesListResponse {} @@ -760,9 +760,9 @@ impl RequestValue for FeaturesBatchInsertRequest {} pub struct RastersListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub rasters: Vec<Raster>, + pub rasters: Option<Vec<Raster>>, } impl ResponseResult for RastersListResponse {} @@ -776,9 +776,9 @@ impl ResponseResult for RastersListResponse {} pub struct GeoJsonLineString { /// Identifies this object as a GeoJsonLineString. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of two or more positions, representing a line. - pub coordinates: Vec<GeoJsonPosition>, + pub coordinates: Option<Vec<GeoJsonPosition>>, } impl Part for GeoJsonLineString {} @@ -792,13 +792,13 @@ impl Part for GeoJsonLineString {} pub enum MapItem { /// no description provided #[serde(rename="folder")] - Folder(MapFolder), + Folder(Option<MapFolder>), /// no description provided #[serde(rename="kmlLink")] - KmlLink(MapKmlLink), + KmlLink(Option<MapKmlLink>), /// no description provided #[serde(rename="layer")] - Layer(MapLayer), + Layer(Option<MapLayer>), } impl Default for MapItem { @@ -894,21 +894,21 @@ impl ResponseResult for Raster {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MapFolder { /// A user defined alias for this MapFolder, specific to this Map. - pub key: String, + pub key: Option<String>, /// The name of this MapFolder. - pub name: String, + pub name: Option<String>, /// An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees. #[serde(rename="defaultViewport")] - pub default_viewport: Vec<f64>, + pub default_viewport: Option<Vec<f64>>, /// no description provided - pub contents: Vec<MapItem>, + pub contents: Option<Vec<MapItem>>, /// The expandability setting of this MapFolder. If true, the folder can be expanded. - pub expandable: bool, + pub expandable: Option<bool>, /// Identifies this object as a MapFolder. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The visibility setting of this MapFolder. One of "defaultOn" or "defaultOff". - pub visibility: String, + pub visibility: Option<String>, } impl Part for MapFolder {} @@ -922,9 +922,9 @@ impl Part for MapFolder {} pub struct GeoJsonMultiPolygon { /// Identifies this object as a GeoJsonMultiPolygon. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of at least two GeoJsonPolygon coordinate arrays. - pub coordinates: Vec<Vec<Vec<GeoJsonPosition>>>, + pub coordinates: Option<Vec<Vec<Vec<GeoJsonPosition>>>>, } impl Part for GeoJsonMultiPolygon {} @@ -947,7 +947,7 @@ impl Part for GeoJsonMultiPolygon {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PermissionsListResponse { /// The set of permissions associated with this asset. - pub permissions: Vec<Permission>, + pub permissions: Option<Vec<Permission>>, } impl ResponseResult for PermissionsListResponse {} @@ -960,19 +960,19 @@ impl ResponseResult for PermissionsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MapLayer { /// A user defined alias for this MapLayer, specific to this Map. - pub key: String, + pub key: Option<String>, /// The name of this MapLayer. - pub name: String, + pub name: Option<String>, /// An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees. #[serde(rename="defaultViewport")] - pub default_viewport: Vec<f64>, + pub default_viewport: Option<Vec<f64>>, /// Identifies this object as a MapLayer. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The ID of this MapLayer. This ID can be used to request more details about the layer. - pub id: String, + pub id: Option<String>, /// The visibility setting of this MapLayer. One of "defaultOn" or "defaultOff". - pub visibility: String, + pub visibility: Option<String>, } impl Part for MapLayer {} @@ -1060,9 +1060,9 @@ impl ResponseResult for RasterCollection {} pub struct GeoJsonPolygon { /// Identifies this object as a GeoJsonPolygon. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of LinearRings. A LinearRing is a GeoJsonLineString which is closed (that is, the first and last GeoJsonPositions are equal), and which contains at least four GeoJsonPositions. For polygons with multiple rings, the first LinearRing is the exterior ring, and any subsequent rings are interior rings (that is, holes). - pub coordinates: Vec<Vec<GeoJsonPosition>>, + pub coordinates: Option<Vec<Vec<GeoJsonPosition>>>, } impl Part for GeoJsonPolygon {} @@ -1075,19 +1075,19 @@ impl Part for GeoJsonPolygon {} #[derive(Clone, Debug, Serialize, Deserialize)] pub enum GeoJsonGeometry { /// no description provided - GeometryCollection(GeoJsonGeometryCollection), + GeometryCollection(Option<GeoJsonGeometryCollection>), /// no description provided - LineString(GeoJsonLineString), + LineString(Option<GeoJsonLineString>), /// no description provided - MultiLineString(GeoJsonMultiLineString), + MultiLineString(Option<GeoJsonMultiLineString>), /// no description provided - MultiPoint(GeoJsonMultiPoint), + MultiPoint(Option<GeoJsonMultiPoint>), /// no description provided - MultiPolygon(GeoJsonMultiPolygon), + MultiPolygon(Option<GeoJsonMultiPolygon>), /// no description provided - Point(GeoJsonPoint), + Point(Option<GeoJsonPoint>), /// no description provided - Polygon(GeoJsonPolygon), + Polygon(Option<GeoJsonPolygon>), } impl Default for GeoJsonGeometry { @@ -1111,12 +1111,12 @@ impl Part for GeoJsonGeometry {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Feature { /// The geometry member of this Feature. - pub geometry: GeoJsonGeometry, + pub geometry: Option<GeoJsonGeometry>, /// Identifies this object as a feature. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Key/value pairs of this Feature. - pub properties: GeoJsonProperties, + pub properties: Option<GeoJsonProperties>, } impl ResponseResult for Feature {} @@ -1129,11 +1129,11 @@ impl ResponseResult for Feature {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Filter { /// The column name to filter on. - pub column: String, + pub column: Option<String>, /// Operation used to evaluate the filter. - pub operator: String, + pub operator: Option<String>, /// Value to be evaluated against attribute. - pub value: String, + pub value: Option<String>, } impl Part for Filter {} @@ -1146,11 +1146,11 @@ impl Part for Filter {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AcquisitionTime { /// The acquisition time, or start time if acquisition time is a range. The value is an RFC 3339 formatted date-time value (1970-01-01T00:00:00Z). - pub start: String, + pub start: Option<String>, /// The end time if acquisition time is a range. The value is an RFC 3339 formatted date-time value (1970-01-01T00:00:00Z). - pub end: String, + pub end: Option<String>, /// The precision of acquisition time. - pub precision: String, + pub precision: Option<String>, } impl Part for AcquisitionTime {} @@ -1163,7 +1163,7 @@ impl Part for AcquisitionTime {} /// The contained type is `Option<Vec<f64>>`. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GeoJsonPosition(Vec<f64>); +pub struct GeoJsonPosition(Option<Vec<f64>>); impl Part for GeoJsonPosition {} @@ -1180,10 +1180,10 @@ impl Part for GeoJsonPosition {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LayersListResponse { /// Resources returned. - pub layers: Vec<Layer>, + pub layers: Option<Vec<Layer>>, /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, } impl ResponseResult for LayersListResponse {} @@ -1197,9 +1197,9 @@ impl ResponseResult for LayersListResponse {} pub struct GeoJsonGeometryCollection { /// Identifies this object as a GeoJsonGeometryCollection. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An array of geometry objects. There must be at least 2 different types of geometries in the array. - pub geometries: Vec<GeoJsonGeometry>, + pub geometries: Option<Vec<GeoJsonGeometry>>, } impl Part for GeoJsonGeometryCollection {} @@ -1213,17 +1213,17 @@ impl Part for GeoJsonGeometryCollection {} pub struct MapKmlLink { /// An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees. #[serde(rename="defaultViewport")] - pub default_viewport: Vec<f64>, + pub default_viewport: Option<Vec<f64>>, /// Identifies this object as a MapKmlLink. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The URL to the KML file represented by this MapKmlLink. #[serde(rename="kmlUrl")] - pub kml_url: String, + pub kml_url: Option<String>, /// The visibility setting of this MapKmlLink. One of "defaultOn" or "defaultOff". - pub visibility: String, + pub visibility: Option<String>, /// The name of this MapKmlLink. - pub name: String, + pub name: Option<String>, } impl Part for MapKmlLink {} @@ -1330,9 +1330,9 @@ impl ResponseResult for Layer {} pub struct ParentsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The parent assets. - pub parents: Vec<Parent>, + pub parents: Option<Vec<Parent>>, } impl ResponseResult for ParentsListResponse {} @@ -1346,13 +1346,13 @@ impl ResponseResult for ParentsListResponse {} pub struct VectorStyle { /// Individual feature info, this is called Info Window in Maps Engine UI. If not provided, a default template with all attributes will be generated. #[serde(rename="featureInfo")] - pub feature_info: FeatureInfo, + pub feature_info: Option<FeatureInfo>, /// The type of the vector style. Currently, only displayRule is supported. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// no description provided #[serde(rename="displayRules")] - pub display_rules: Vec<DisplayRule>, + pub display_rules: Option<Vec<DisplayRule>>, } impl Part for VectorStyle {} @@ -1371,9 +1371,9 @@ impl Part for VectorStyle {} pub struct RasterCollectionsRastersListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub rasters: Vec<RasterCollectionsRaster>, + pub rasters: Option<Vec<RasterCollectionsRaster>>, } impl ResponseResult for RasterCollectionsRastersListResponse {} @@ -1410,9 +1410,9 @@ impl ResponseResult for PublishResponse {} pub struct AssetsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Assets returned. - pub assets: Vec<Asset>, + pub assets: Option<Vec<Asset>>, } impl ResponseResult for AssetsListResponse {} @@ -1483,7 +1483,7 @@ impl ResponseResult for RasterCollectionsRastersBatchInsertResponse {} /// The contained type is `Option<Vec<MapItem>>`. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct MapContents(Vec<MapItem>); +pub struct MapContents(Option<Vec<MapItem>>); impl Part for MapContents {} @@ -1495,7 +1495,7 @@ impl Part for MapContents {} /// The contained type is `Option<Vec<String>>`. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Tags(Vec<String>); +pub struct Tags(Option<Vec<String>>); impl Part for Tags {} @@ -1554,19 +1554,19 @@ impl ResponseResult for ProcessResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PublishedMap { /// The description of this Map, supplied by the author. - pub description: String, + pub description: Option<String>, /// An array of four numbers (west, south, east, north) which defines the rectangular bounding box of the default viewport. The numbers represent latitude and longitude in decimal degrees. #[serde(rename="defaultViewport")] - pub default_viewport: LatLngBox, + pub default_viewport: Option<LatLngBox>, /// The ID of the project that this Map is in. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option<String>, /// A globally unique ID, used to refer to this Map. - pub id: String, + pub id: Option<String>, /// The contents of this Map. - pub contents: MapContents, + pub contents: Option<MapContents>, /// The name of this Map, supplied by the author. - pub name: String, + pub name: Option<String>, } impl ResponseResult for PublishedMap {} @@ -1585,16 +1585,16 @@ impl ResponseResult for PublishedMap {} pub struct PublishedLayer { /// The ID of the project that this Layer is in. #[serde(rename="projectId")] - pub project_id: String, + pub project_id: Option<String>, /// The name of this Layer, supplied by the author. - pub name: String, + pub name: Option<String>, /// The description of this Layer, supplied by the author. - pub description: String, + pub description: Option<String>, /// The type of the datasources used to build this Layer. This should be used instead of datasourceType. At least one of layerType and datasourceType and must be specified, but layerType takes precedence. #[serde(rename="layerType")] - pub layer_type: String, + pub layer_type: Option<String>, /// A globally unique ID, used to refer to this Layer. - pub id: String, + pub id: Option<String>, } impl ResponseResult for PublishedLayer {} @@ -1605,7 +1605,7 @@ impl ResponseResult for PublishedLayer {} /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct GeoJsonProperties(HashMap<String, String>); +pub struct GeoJsonProperties(Option<HashMap<String, String>>); impl Part for GeoJsonProperties {} @@ -1638,13 +1638,13 @@ impl RequestValue for FeaturesBatchPatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LineStyle { /// Dash defines the pattern of the line, the values are pixel lengths of alternating dash and gap. If dash is not provided, then it means a solid line. Dash can contain up to 10 values and must contain even number of values. - pub dash: Vec<f64>, + pub dash: Option<Vec<f64>>, /// Stroke of the line. - pub stroke: LineStyleStroke, + pub stroke: Option<LineStyleStroke>, /// Border of the line. 0 < border.width <= 5. - pub border: Border, + pub border: Option<Border>, /// Label style for the line. - pub label: LabelStyle, + pub label: Option<LabelStyle>, } impl Part for LineStyle {} @@ -1658,12 +1658,12 @@ impl Part for LineStyle {} pub struct Schema { /// The name of the column that contains a feature's geometry. This field can be omitted during table create; Google Maps Engine supports only a single geometry column, which must be named geometry and be the first object in the columns array. #[serde(rename="primaryGeometry")] - pub primary_geometry: String, + pub primary_geometry: Option<String>, /// The name of the column that contains the unique identifier of a Feature. #[serde(rename="primaryKey")] - pub primary_key: String, + pub primary_key: Option<String>, /// An array of TableColumn objects. The first object in the array must be named geometry and be of type points, lineStrings, polygons, or mixedGeometry. - pub columns: Vec<TableColumn>, + pub columns: Option<Vec<TableColumn>>, } impl Part for Schema {} @@ -1754,7 +1754,7 @@ impl ResponseResult for Map {} /// The contained type is `Option<Vec<Datasource>>`. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Datasources(Vec<Datasource>); +pub struct Datasources(Option<Vec<Datasource>>); impl Part for Datasources {} @@ -1766,14 +1766,14 @@ impl Part for Datasources {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Permission { /// The type of access granted to this user or group. - pub role: String, + pub role: Option<String>, /// The account type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Indicates whether a public asset is listed and can be found via a web search (value true), or is visible only to people who have a link to the asset (value false). - pub discoverable: bool, + pub discoverable: Option<bool>, /// The unique identifier of the permission. This could be the email address of the user or group this permission refers to, or the string "anyone" for public permissions. - pub id: String, + pub id: Option<String>, } impl Part for Permission {} @@ -1786,11 +1786,11 @@ impl Part for Permission {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ScaledShape { /// Name of the shape. - pub shape: String, + pub shape: Option<String>, /// Border color/width of the shape. If not specified the shape won't have a border. - pub border: Border, + pub border: Option<Border>, /// The fill color of the shape. If not specified the shape will be transparent (although the borders may not be). - pub fill: Color, + pub fill: Option<Color>, } impl Part for ScaledShape {} @@ -1803,9 +1803,9 @@ impl Part for ScaledShape {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ZoomLevels { /// Maximum zoom level. - pub max: i32, + pub max: Option<i32>, /// Minimum zoom level. - pub min: i32, + pub min: Option<i32>, } impl Part for ZoomLevels {} @@ -1824,9 +1824,9 @@ impl Part for ZoomLevels {} pub struct IconsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub icons: Vec<Icon>, + pub icons: Option<Vec<Icon>>, } impl ResponseResult for IconsListResponse {} @@ -1839,16 +1839,16 @@ impl ResponseResult for IconsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ScalingFunction { /// Name of the numeric column used to scale a shape. - pub column: String, + pub column: Option<String>, /// The range of values to display across the size range. #[serde(rename="valueRange")] - pub value_range: ValueRange, + pub value_range: Option<ValueRange>, /// The range of shape sizes, in pixels. For circles, the size corresponds to the diameter. #[serde(rename="sizeRange")] - pub size_range: SizeRange, + pub size_range: Option<SizeRange>, /// The type of scaling function to use. Defaults to SQRT. Currently only linear and square root scaling are supported. #[serde(rename="scalingType")] - pub scaling_type: String, + pub scaling_type: Option<String>, } impl Part for ScalingFunction {} @@ -1861,11 +1861,11 @@ impl Part for ScalingFunction {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PolygonStyle { /// Border of the polygon. 0 < border.width <= 10. - pub stroke: Border, + pub stroke: Option<Border>, /// Fill color of the polygon. If not provided, the polygon will be transparent and not visible if there is no border. - pub fill: Color, + pub fill: Option<Color>, /// Label style for the polygon. - pub label: LabelStyle, + pub label: Option<LabelStyle>, } impl Part for PolygonStyle {} @@ -1878,7 +1878,7 @@ impl Part for PolygonStyle {} /// The contained type is `Option<Vec<f64>>`. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct LatLngBox(Vec<f64>); +pub struct LatLngBox(Option<Vec<f64>>); impl Part for LatLngBox {} @@ -1930,7 +1930,7 @@ impl RequestValue for RasterCollectionsRastersBatchInsertRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FeatureInfo { /// HTML template of the info window. If not provided, a default template with all attributes will be generated. - pub content: String, + pub content: Option<String>, } impl Part for FeatureInfo {} @@ -1943,9 +1943,9 @@ impl Part for FeatureInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SizeRange { /// Maximum size, in pixels. - pub max: f64, + pub max: Option<f64>, /// Minimum size, in pixels. - pub min: f64, + pub min: Option<f64>, } impl Part for SizeRange {} @@ -1964,9 +1964,9 @@ impl Part for SizeRange {} pub struct TablesListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub tables: Vec<Table>, + pub tables: Option<Vec<Table>>, } impl ResponseResult for TablesListResponse {} @@ -1979,11 +1979,11 @@ impl ResponseResult for TablesListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LineStyleStroke { /// Color of the line. - pub color: String, + pub color: Option<String>, /// Opacity of the line. - pub opacity: f64, + pub opacity: Option<f64>, /// Width of the line, in pixels. 0 <= width <= 10. If width is set to 0, the line will be invisible. - pub width: f64, + pub width: Option<f64>, } impl NestedType for LineStyleStroke {} @@ -2020,9 +2020,9 @@ impl Resource for Project {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PointStyle { /// Icon for the point; if it isn't null, exactly one of 'name', 'id' or 'scaledShape' must be set. - pub icon: IconStyle, + pub icon: Option<IconStyle>, /// Label style for the point. - pub label: LabelStyle, + pub label: Option<LabelStyle>, } impl Part for PointStyle {} @@ -2035,9 +2035,9 @@ impl Part for PointStyle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Color { /// The CSS style color, can be in format of "red" or "#7733EE". - pub color: String, + pub color: Option<String>, /// Opacity ranges from 0 to 1, inclusive. If not provided, default to 1. - pub opacity: f64, + pub opacity: Option<f64>, } impl Part for Color {} @@ -2050,11 +2050,11 @@ impl Part for Color {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Border { /// Color of the border. - pub color: String, + pub color: Option<String>, /// Opacity of the border. - pub opacity: f64, + pub opacity: Option<f64>, /// Width of the border, in pixels. - pub width: f64, + pub width: Option<f64>, } impl Part for Border {} @@ -2072,10 +2072,10 @@ impl Part for Border {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PublishedLayersListResponse { /// Resources returned. - pub layers: Vec<PublishedLayer>, + pub layers: Option<Vec<PublishedLayer>>, /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, } impl ResponseResult for PublishedLayersListResponse {} @@ -2088,21 +2088,21 @@ impl ResponseResult for PublishedLayersListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LabelStyle { /// Opacity of the text. - pub opacity: f64, + pub opacity: Option<f64>, /// Font weight of the label, defaults to 'normal'. #[serde(rename="fontWeight")] - pub font_weight: String, + pub font_weight: Option<String>, /// Font style of the label, defaults to 'normal'. #[serde(rename="fontStyle")] - pub font_style: String, + pub font_style: Option<String>, /// Outline color of the text. - pub outline: Color, + pub outline: Option<Color>, /// The column value of the feature to be displayed. - pub column: String, + pub column: Option<String>, /// Color of the text. If not provided, default to black. - pub color: String, + pub color: Option<String>, /// Font size of the label, in pixels. 8 <= size <= 15. If not provided, a default size will be provided. - pub size: f64, + pub size: Option<f64>, } impl Part for LabelStyle {} @@ -2116,9 +2116,9 @@ impl Part for LabelStyle {} pub struct GeoJsonPoint { /// Identifies this object as a GeoJsonPoint. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// A single GeoJsonPosition, specifying the location of the point. - pub coordinates: GeoJsonPosition, + pub coordinates: Option<GeoJsonPosition>, } impl Part for GeoJsonPoint {} @@ -2132,14 +2132,14 @@ impl Part for GeoJsonPoint {} pub struct IconStyle { /// The function used to scale shapes. Required when a scaledShape is specified. #[serde(rename="scalingFunction")] - pub scaling_function: ScalingFunction, + pub scaling_function: Option<ScalingFunction>, /// Custom icon id. - pub id: String, + pub id: Option<String>, /// A scalable shape. #[serde(rename="scaledShape")] - pub scaled_shape: ScaledShape, + pub scaled_shape: Option<ScaledShape>, /// Stock icon name. To use a stock icon, prefix it with 'gx_'. See Stock icon names for valid icon names. For example, to specify small_red, set name to 'gx_small_red'. - pub name: String, + pub name: Option<String>, } impl Part for IconStyle {} @@ -2152,9 +2152,9 @@ impl Part for IconStyle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ValueRange { /// Maximum value. - pub max: f64, + pub max: Option<f64>, /// Minimum value. - pub min: f64, + pub min: Option<f64>, } impl Part for ValueRange {} @@ -2167,12 +2167,12 @@ impl Part for ValueRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct File { /// The name of the file. - pub filename: String, + pub filename: Option<String>, /// The upload status of the file. #[serde(rename="uploadStatus")] - pub upload_status: String, + pub upload_status: Option<String>, /// The size of the file in bytes. - pub size: String, + pub size: Option<String>, } impl Part for File {} @@ -2191,9 +2191,9 @@ impl Part for File {} pub struct PublishedMapsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub maps: Vec<PublishedMap>, + pub maps: Option<Vec<PublishedMap>>, } impl ResponseResult for PublishedMapsListResponse {} @@ -2292,9 +2292,9 @@ impl ResponseResult for Table {} pub struct MapsListResponse { /// Next page token. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Resources returned. - pub maps: Vec<Map>, + pub maps: Option<Vec<Map>>, } impl ResponseResult for MapsListResponse {} @@ -2307,7 +2307,7 @@ impl ResponseResult for MapsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Datasource { /// The ID of a datasource. - pub id: String, + pub id: Option<String>, } impl Part for Datasource {} @@ -4200,16 +4200,20 @@ impl<'a, C, A> LayerUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4435,16 +4439,20 @@ impl<'a, C, A> LayerPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4661,16 +4669,20 @@ impl<'a, C, A> LayerListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4821,7 +4833,7 @@ impl<'a, C, A> LayerListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Layer = Default::default(); +/// let mut req = Layer::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4892,16 +4904,20 @@ impl<'a, C, A> LayerCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5132,16 +5148,20 @@ impl<'a, C, A> LayerGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5361,16 +5381,20 @@ impl<'a, C, A> LayerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5586,16 +5610,20 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5742,7 +5770,7 @@ impl<'a, C, A> LayerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchDeleteRequest = Default::default(); +/// let mut req = PermissionsBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5834,16 +5862,20 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5998,7 +6030,7 @@ impl<'a, C, A> LayerPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchUpdateRequest = Default::default(); +/// let mut req = PermissionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6090,16 +6122,20 @@ impl<'a, C, A> LayerPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6372,16 +6408,20 @@ impl<'a, C, A> LayerListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6692,16 +6732,20 @@ impl<'a, C, A> LayerParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6936,16 +6980,20 @@ impl<'a, C, A> LayerCancelProcessingCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7085,7 +7133,7 @@ impl<'a, C, A> LayerCancelProcessingCall<'a, C, A> where C: BorrowMut<hyper::Cli /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Layer = Default::default(); +/// let mut req = Layer::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7176,16 +7224,20 @@ impl<'a, C, A> LayerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7409,16 +7461,20 @@ impl<'a, C, A> LayerPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7639,16 +7695,20 @@ impl<'a, C, A> LayerProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -7790,7 +7850,7 @@ impl<'a, C, A> LayerProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchUpdateRequest = Default::default(); +/// let mut req = PermissionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7882,16 +7942,20 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8044,7 +8108,7 @@ impl<'a, C, A> RasterPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Raster = Default::default(); +/// let mut req = Raster::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8135,16 +8199,20 @@ impl<'a, C, A> RasterPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8368,16 +8436,20 @@ impl<'a, C, A> RasterPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8597,16 +8669,20 @@ impl<'a, C, A> RasterDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8736,7 +8812,7 @@ impl<'a, C, A> RasterDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchDeleteRequest = Default::default(); +/// let mut req = PermissionsBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8828,16 +8904,20 @@ impl<'a, C, A> RasterPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9084,16 +9164,20 @@ impl<'a, C, A> RasterFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -9412,16 +9496,20 @@ impl<'a, C, A> RasterProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -9642,16 +9730,20 @@ impl<'a, C, A> RasterGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9908,16 +10000,20 @@ impl<'a, C, A> RasterListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10140,7 +10236,7 @@ impl<'a, C, A> RasterListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Raster = Default::default(); +/// let mut req = Raster::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10206,16 +10302,20 @@ impl<'a, C, A> RasterUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10449,16 +10549,20 @@ impl<'a, C, A> RasterParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10693,16 +10797,20 @@ impl<'a, C, A> AssetPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10962,16 +11070,20 @@ impl<'a, C, A> AssetListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11273,16 +11385,20 @@ impl<'a, C, A> AssetGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11513,16 +11629,20 @@ impl<'a, C, A> AssetParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11756,16 +11876,20 @@ impl<'a, C, A> TableDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11990,16 +12114,20 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -12245,7 +12373,7 @@ impl<'a, C, A> TableFileInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FeaturesBatchInsertRequest = Default::default(); +/// let mut req = FeaturesBatchInsertRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12336,16 +12464,20 @@ impl<'a, C, A> TableFeatureBatchInsertCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12608,16 +12740,20 @@ impl<'a, C, A> TableListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12923,16 +13059,20 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13078,7 +13218,7 @@ impl<'a, C, A> TableGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FeaturesBatchDeleteRequest = Default::default(); +/// let mut req = FeaturesBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13169,16 +13309,20 @@ impl<'a, C, A> TableFeatureBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13447,16 +13591,20 @@ impl<'a, C, A> TableFeatureListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13740,16 +13888,20 @@ impl<'a, C, A> TableProcesCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -13980,16 +14132,20 @@ impl<'a, C, A> TableParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14145,7 +14301,7 @@ impl<'a, C, A> TableParentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchUpdateRequest = Default::default(); +/// let mut req = PermissionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14237,16 +14393,20 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14401,7 +14561,7 @@ impl<'a, C, A> TablePermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14467,16 +14627,20 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14633,7 +14797,7 @@ impl<'a, C, A> TableUploadCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: FeaturesBatchPatchRequest = Default::default(); +/// let mut req = FeaturesBatchPatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14724,16 +14888,20 @@ impl<'a, C, A> TableFeatureBatchPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14876,7 +15044,7 @@ impl<'a, C, A> TableFeatureBatchPatchCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -14967,16 +15135,20 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15119,7 +15291,7 @@ impl<'a, C, A> TablePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchDeleteRequest = Default::default(); +/// let mut req = PermissionsBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15211,16 +15383,20 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15373,7 +15549,7 @@ impl<'a, C, A> TablePermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Table = Default::default(); +/// let mut req = Table::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -15439,16 +15615,20 @@ impl<'a, C, A> TableCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15672,16 +15852,20 @@ impl<'a, C, A> TablePermissionListCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15914,16 +16098,20 @@ impl<'a, C, A> TableFeatureGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16207,16 +16395,20 @@ impl<'a, C, A> MapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16506,16 +16698,20 @@ impl<'a, C, A> MapListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -16666,7 +16862,7 @@ impl<'a, C, A> MapListPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Map = Default::default(); +/// let mut req = Map::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -16757,16 +16953,20 @@ impl<'a, C, A> MapPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16911,7 +17111,7 @@ impl<'a, C, A> MapPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchUpdateRequest = Default::default(); +/// let mut req = PermissionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -17003,16 +17203,20 @@ impl<'a, C, A> MapPermissionBatchUpdateCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17245,16 +17449,20 @@ impl<'a, C, A> MapDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -17465,16 +17673,20 @@ impl<'a, C, A> MapUnpublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -17700,16 +17912,20 @@ impl<'a, C, A> MapPublishCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -17937,16 +18153,20 @@ impl<'a, C, A> MapPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18086,7 +18306,7 @@ impl<'a, C, A> MapPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Map = Default::default(); +/// let mut req = Map::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -18152,16 +18372,20 @@ impl<'a, C, A> MapCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -18385,16 +18609,20 @@ impl<'a, C, A> MapGetPublishedCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18620,16 +18848,20 @@ impl<'a, C, A> MapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -18776,7 +19008,7 @@ impl<'a, C, A> MapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchDeleteRequest = Default::default(); +/// let mut req = PermissionsBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -18868,16 +19100,20 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19030,7 +19266,7 @@ impl<'a, C, A> MapPermissionBatchDeleteCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RasterCollection = Default::default(); +/// let mut req = RasterCollection::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19096,16 +19332,20 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19248,7 +19488,7 @@ impl<'a, C, A> RasterCollectionCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchDeleteRequest = Default::default(); +/// let mut req = PermissionsBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19340,16 +19580,20 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19502,7 +19746,7 @@ impl<'a, C, A> RasterCollectionPermissionBatchDeleteCall<'a, C, A> where C: Borr /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RasterCollection = Default::default(); +/// let mut req = RasterCollection::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -19593,16 +19837,20 @@ impl<'a, C, A> RasterCollectionPatchCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -19826,16 +20074,20 @@ impl<'a, C, A> RasterCollectionCancelProcessingCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -20056,16 +20308,20 @@ impl<'a, C, A> RasterCollectionProcesCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -20207,7 +20463,7 @@ impl<'a, C, A> RasterCollectionProcesCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PermissionsBatchUpdateRequest = Default::default(); +/// let mut req = PermissionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -20299,16 +20555,20 @@ impl<'a, C, A> RasterCollectionPermissionBatchUpdateCall<'a, C, A> where C: Borr loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -20541,16 +20801,20 @@ impl<'a, C, A> RasterCollectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -20771,16 +21035,20 @@ impl<'a, C, A> RasterCollectionParentListCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21054,16 +21322,20 @@ impl<'a, C, A> RasterCollectionListCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -21285,7 +21557,7 @@ impl<'a, C, A> RasterCollectionListCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RasterCollectionsRastersBatchInsertRequest = Default::default(); +/// let mut req = RasterCollectionsRastersBatchInsertRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -21377,16 +21649,20 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21541,7 +21817,7 @@ impl<'a, C, A> RasterCollectionRasterBatchInsertCall<'a, C, A> where C: BorrowMu /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RasterCollectionsRasterBatchDeleteRequest = Default::default(); +/// let mut req = RasterCollectionsRasterBatchDeleteRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -21633,16 +21909,20 @@ impl<'a, C, A> RasterCollectionRasterBatchDeleteCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -21876,16 +22156,20 @@ impl<'a, C, A> RasterCollectionPermissionListCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22106,16 +22390,20 @@ impl<'a, C, A> RasterCollectionGetCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22391,16 +22679,20 @@ impl<'a, C, A> RasterCollectionRasterListCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22721,16 +23013,20 @@ impl<'a, C, A> ProjectIconGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -22881,7 +23177,7 @@ impl<'a, C, A> ProjectIconGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Icon = Default::default(); +/// let mut req = Icon::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -22984,16 +23280,20 @@ impl<'a, C, A> ProjectIconCreateCall<'a, C, A> where C: BorrowMut<hyper::Client> let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -23304,16 +23604,20 @@ impl<'a, C, A> ProjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -23534,16 +23838,20 @@ impl<'a, C, A> ProjectIconListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/mirror1-cli/Cargo.toml b/gen/mirror1-cli/Cargo.toml index 209eb7067a..b279ad7773 100644 --- a/gen/mirror1-cli/Cargo.toml +++ b/gen/mirror1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-mirror1-cli" version = "0.0.1+20150220" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/glass" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/mirror1-cli/src/cmn.rs b/gen/mirror1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/mirror1-cli/src/cmn.rs +++ b/gen/mirror1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/mirror1-cli/src/main.rs b/gen/mirror1-cli/src/main.rs index a2efab9c96..7281e4d8d7 100644 --- a/gen/mirror1-cli/src/main.rs +++ b/gen/mirror1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -55,6 +56,12 @@ Configuration: 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. "); mod cmn; @@ -76,10 +83,10 @@ struct Engine { impl Engine { fn _accounts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Account = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -99,9 +106,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -111,9 +119,9 @@ impl Engine { }, "features" => { if request.features.is_none() { - request.features = Some(Default::default()); + request.features = Some(Default::default()); } - request.features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -132,8 +140,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -144,7 +151,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.contacts().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -175,7 +182,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -186,7 +192,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.contacts().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -218,8 +224,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -228,10 +233,10 @@ impl Engine { fn _contacts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Contact = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -251,9 +256,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -266,15 +272,15 @@ impl Engine { }, "accept-types" => { if request.accept_types.is_none() { - request.accept_types = Some(Default::default()); + request.accept_types = Some(Default::default()); } - request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "image-urls" => { if request.image_urls.is_none() { - request.image_urls = Some(Default::default()); + request.image_urls = Some(Default::default()); } - request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "priority" => { request.priority = Some(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer")); @@ -287,9 +293,9 @@ impl Engine { }, "sharing-features" => { if request.sharing_features.is_none() { - request.sharing_features = Some(Default::default()); + request.sharing_features = Some(Default::default()); } - request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "type" => { request.type_ = Some(value.unwrap_or("").to_string()); @@ -317,8 +323,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -329,7 +334,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.contacts().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -361,8 +366,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -371,10 +375,10 @@ impl Engine { fn _contacts_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Contact = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -394,9 +398,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -409,15 +414,15 @@ impl Engine { }, "accept-types" => { if request.accept_types.is_none() { - request.accept_types = Some(Default::default()); + request.accept_types = Some(Default::default()); } - request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "image-urls" => { if request.image_urls.is_none() { - request.image_urls = Some(Default::default()); + request.image_urls = Some(Default::default()); } - request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "priority" => { request.priority = Some(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer")); @@ -430,9 +435,9 @@ impl Engine { }, "sharing-features" => { if request.sharing_features.is_none() { - request.sharing_features = Some(Default::default()); + request.sharing_features = Some(Default::default()); } - request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "type" => { request.type_ = Some(value.unwrap_or("").to_string()); @@ -460,8 +465,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -470,10 +474,10 @@ impl Engine { fn _contacts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Contact = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -493,9 +497,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -508,15 +513,15 @@ impl Engine { }, "accept-types" => { if request.accept_types.is_none() { - request.accept_types = Some(Default::default()); + request.accept_types = Some(Default::default()); } - request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "image-urls" => { if request.image_urls.is_none() { - request.image_urls = Some(Default::default()); + request.image_urls = Some(Default::default()); } - request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "priority" => { request.priority = Some(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer")); @@ -529,9 +534,9 @@ impl Engine { }, "sharing-features" => { if request.sharing_features.is_none() { - request.sharing_features = Some(Default::default()); + request.sharing_features = Some(Default::default()); } - request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "type" => { request.type_ = Some(value.unwrap_or("").to_string()); @@ -559,8 +564,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -571,7 +575,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.locations().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -603,8 +607,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -615,7 +618,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.locations().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -647,8 +650,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -659,7 +661,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.settings().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -691,8 +693,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -703,7 +704,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subscriptions().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -734,7 +735,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -743,10 +743,10 @@ impl Engine { fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subscription = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -766,9 +766,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -784,23 +785,23 @@ impl Engine { }, "notification.item-id" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().item_id = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().item_id = Some(value.unwrap_or("").to_string()); }, "notification.user-token" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().user_token = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().user_token = Some(value.unwrap_or("").to_string()); }, "notification.operation" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().operation = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().operation = Some(value.unwrap_or("").to_string()); }, "notification.verify-token" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().verify_token = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().verify_token = Some(value.unwrap_or("").to_string()); }, "notification.collection" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().collection = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().collection = Some(value.unwrap_or("").to_string()); }, "updated" => { request_notification_init(&mut request); @@ -821,9 +822,9 @@ impl Engine { "operation" => { request_notification_init(&mut request); if request.operation.is_none() { - request.operation = Some(Default::default()); + request.operation = Some(Default::default()); } - request.operation.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.operation.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_notification_init(&mut request); @@ -850,8 +851,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -862,7 +862,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subscriptions().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -894,8 +894,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -904,10 +903,10 @@ impl Engine { fn _subscriptions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subscription = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -927,9 +926,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -945,23 +945,23 @@ impl Engine { }, "notification.item-id" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().item_id = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().item_id = Some(value.unwrap_or("").to_string()); }, "notification.user-token" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().user_token = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().user_token = Some(value.unwrap_or("").to_string()); }, "notification.operation" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().operation = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().operation = Some(value.unwrap_or("").to_string()); }, "notification.verify-token" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().verify_token = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().verify_token = Some(value.unwrap_or("").to_string()); }, "notification.collection" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().collection = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().collection = Some(value.unwrap_or("").to_string()); }, "updated" => { request_notification_init(&mut request); @@ -982,9 +982,9 @@ impl Engine { "operation" => { request_notification_init(&mut request); if request.operation.is_none() { - request.operation = Some(Default::default()); + request.operation = Some(Default::default()); } - request.operation.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.operation.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "id" => { request_notification_init(&mut request); @@ -1011,8 +1011,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1023,7 +1022,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().attachments_delete(&self.opt.arg_item_id, &self.opt.arg_attachment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1054,7 +1053,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1066,7 +1064,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.timeline().attachments_get(&self.opt.arg_item_id, &self.opt.arg_attachment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1101,9 +1099,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -1117,7 +1114,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().attachments_insert(&self.opt.arg_item_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1159,8 +1156,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1171,7 +1167,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().attachments_list(&self.opt.arg_item_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1203,8 +1199,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1215,7 +1210,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1246,7 +1241,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1257,7 +1251,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1289,8 +1283,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1299,10 +1292,10 @@ impl Engine { fn _timeline_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TimelineItem = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1322,9 +1315,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1361,16 +1355,16 @@ impl Engine { "creator.accept-types" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().accept_types.is_none() { - request.creator.as_mut().unwrap().accept_types = Some(Default::default()); + request.creator.as_mut().unwrap().accept_types = Some(Default::default()); } - request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.image-urls" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().image_urls.is_none() { - request.creator.as_mut().unwrap().image_urls = Some(Default::default()); + request.creator.as_mut().unwrap().image_urls = Some(Default::default()); } - request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.priority" => { request_creator_init(&mut request); @@ -1387,9 +1381,9 @@ impl Engine { "creator.sharing-features" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().sharing_features.is_none() { - request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); + request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); } - request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.type" => { request_creator_init(&mut request); @@ -1449,35 +1443,35 @@ impl Engine { }, "location.kind" => { request_location_init(&mut request); - request.location.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "location.display-name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "location.timestamp" => { request_location_init(&mut request); - request.location.as_mut().unwrap().timestamp = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().timestamp = Some(value.unwrap_or("").to_string()); }, "location.longitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number"); + request.location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number")); }, "location.address" => { request_location_init(&mut request); - request.location.as_mut().unwrap().address = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().address = Some(value.unwrap_or("").to_string()); }, "location.latitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number"); + request.location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number")); }, "location.id" => { request_location_init(&mut request); - request.location.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "location.accuracy" => { request_location_init(&mut request); - request.location.as_mut().unwrap().accuracy = arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number"); + request.location.as_mut().unwrap().accuracy = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number")); }, "source-item-id" => { request_location_init(&mut request); @@ -1505,11 +1499,11 @@ impl Engine { }, "notification.level" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().level = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().level = Some(value.unwrap_or("").to_string()); }, "notification.delivery-time" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().delivery_time = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().delivery_time = Some(value.unwrap_or("").to_string()); }, "speakable-type" => { request_notification_init(&mut request); @@ -1546,8 +1540,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1558,7 +1551,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.timeline().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source-item-id" => { call = call.source_item_id(value.unwrap_or("")); @@ -1611,8 +1604,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1621,10 +1613,10 @@ impl Engine { fn _timeline_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TimelineItem = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1644,9 +1636,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1683,16 +1676,16 @@ impl Engine { "creator.accept-types" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().accept_types.is_none() { - request.creator.as_mut().unwrap().accept_types = Some(Default::default()); + request.creator.as_mut().unwrap().accept_types = Some(Default::default()); } - request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.image-urls" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().image_urls.is_none() { - request.creator.as_mut().unwrap().image_urls = Some(Default::default()); + request.creator.as_mut().unwrap().image_urls = Some(Default::default()); } - request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.priority" => { request_creator_init(&mut request); @@ -1709,9 +1702,9 @@ impl Engine { "creator.sharing-features" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().sharing_features.is_none() { - request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); + request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); } - request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.type" => { request_creator_init(&mut request); @@ -1771,35 +1764,35 @@ impl Engine { }, "location.kind" => { request_location_init(&mut request); - request.location.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "location.display-name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "location.timestamp" => { request_location_init(&mut request); - request.location.as_mut().unwrap().timestamp = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().timestamp = Some(value.unwrap_or("").to_string()); }, "location.longitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number"); + request.location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number")); }, "location.address" => { request_location_init(&mut request); - request.location.as_mut().unwrap().address = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().address = Some(value.unwrap_or("").to_string()); }, "location.latitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number"); + request.location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number")); }, "location.id" => { request_location_init(&mut request); - request.location.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "location.accuracy" => { request_location_init(&mut request); - request.location.as_mut().unwrap().accuracy = arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number"); + request.location.as_mut().unwrap().accuracy = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number")); }, "source-item-id" => { request_location_init(&mut request); @@ -1827,11 +1820,11 @@ impl Engine { }, "notification.level" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().level = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().level = Some(value.unwrap_or("").to_string()); }, "notification.delivery-time" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().delivery_time = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().delivery_time = Some(value.unwrap_or("").to_string()); }, "speakable-type" => { request_notification_init(&mut request); @@ -1858,8 +1851,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1868,10 +1860,10 @@ impl Engine { fn _timeline_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TimelineItem = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1891,9 +1883,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1930,16 +1923,16 @@ impl Engine { "creator.accept-types" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().accept_types.is_none() { - request.creator.as_mut().unwrap().accept_types = Some(Default::default()); + request.creator.as_mut().unwrap().accept_types = Some(Default::default()); } - request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().accept_types.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.image-urls" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().image_urls.is_none() { - request.creator.as_mut().unwrap().image_urls = Some(Default::default()); + request.creator.as_mut().unwrap().image_urls = Some(Default::default()); } - request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().image_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.priority" => { request_creator_init(&mut request); @@ -1956,9 +1949,9 @@ impl Engine { "creator.sharing-features" => { request_creator_init(&mut request); if request.creator.as_mut().unwrap().sharing_features.is_none() { - request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); + request.creator.as_mut().unwrap().sharing_features = Some(Default::default()); } - request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.creator.as_mut().unwrap().sharing_features.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creator.type" => { request_creator_init(&mut request); @@ -2018,35 +2011,35 @@ impl Engine { }, "location.kind" => { request_location_init(&mut request); - request.location.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "location.display-name" => { request_location_init(&mut request); - request.location.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "location.timestamp" => { request_location_init(&mut request); - request.location.as_mut().unwrap().timestamp = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().timestamp = Some(value.unwrap_or("").to_string()); }, "location.longitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number"); + request.location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.longitude", "number")); }, "location.address" => { request_location_init(&mut request); - request.location.as_mut().unwrap().address = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().address = Some(value.unwrap_or("").to_string()); }, "location.latitude" => { request_location_init(&mut request); - request.location.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number"); + request.location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.latitude", "number")); }, "location.id" => { request_location_init(&mut request); - request.location.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.location.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "location.accuracy" => { request_location_init(&mut request); - request.location.as_mut().unwrap().accuracy = arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number"); + request.location.as_mut().unwrap().accuracy = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.accuracy", "number")); }, "source-item-id" => { request_location_init(&mut request); @@ -2074,11 +2067,11 @@ impl Engine { }, "notification.level" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().level = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().level = Some(value.unwrap_or("").to_string()); }, "notification.delivery-time" => { request_notification_init(&mut request); - request.notification.as_mut().unwrap().delivery_time = value.unwrap_or("").to_string(); + request.notification.as_mut().unwrap().delivery_time = Some(value.unwrap_or("").to_string()); }, "speakable-type" => { request_notification_init(&mut request); @@ -2115,8 +2108,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2134,7 +2126,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_contacts { + } + else if self.opt.cmd_contacts { if self.opt.cmd_delete { call_result = self._contacts_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2150,7 +2143,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_locations { + } + else if self.opt.cmd_locations { if self.opt.cmd_get { call_result = self._locations_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2158,13 +2152,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_settings { + } + else if self.opt.cmd_settings { if self.opt.cmd_get { call_result = self._settings_get(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_subscriptions { + } + else if self.opt.cmd_subscriptions { if self.opt.cmd_delete { call_result = self._subscriptions_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -2176,7 +2172,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_timeline { + } + else if self.opt.cmd_timeline { if self.opt.cmd_attachments_delete { call_result = self._timeline_attachments_delete(dry_run, &mut err); } else if self.opt.cmd_attachments_get { @@ -2220,21 +2217,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "mirror1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "mirror1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "mirror1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "mirror1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Mirror::new(hyper::Client::new(), auth), + hub: api::Mirror::new(client, auth), }; match engine._doit(true) { @@ -2254,12 +2267,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/mirror1/Cargo.toml b/gen/mirror1/Cargo.toml index d8053ee17e..bcd163216b 100644 --- a/gen/mirror1/Cargo.toml +++ b/gen/mirror1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-mirror1" version = "0.1.5+20150220" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/glass" diff --git a/gen/mirror1/README.md b/gen/mirror1/README.md index 394b60557a..154b2986e4 100644 --- a/gen/mirror1/README.md +++ b/gen/mirror1/README.md @@ -118,7 +118,7 @@ let mut hub = Mirror::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Contact = Default::default(); +let mut req = Contact::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/mirror1/src/cmn.rs b/gen/mirror1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/mirror1/src/cmn.rs +++ b/gen/mirror1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/mirror1/src/lib.rs b/gen/mirror1/src/lib.rs index 2112c7ea1f..54e4ff8aee 100644 --- a/gen/mirror1/src/lib.rs +++ b/gen/mirror1/src/lib.rs @@ -119,7 +119,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Contact = Default::default(); +//! let mut req = Contact::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -298,7 +298,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Contact = Default::default(); +/// let mut req = Contact::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -392,11 +392,11 @@ pub struct UserAction { /// - UNPIN - the user unpinned the item. /// - LAUNCH - the user initiated a voice command. In the future, additional types may be added. UserActions with unrecognized types should be ignored. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// An optional payload for the action. /// /// For actions of type CUSTOM, this is the ID of the custom menu item that was selected. - pub payload: String, + pub payload: Option<String>, } impl Part for UserAction {} @@ -444,15 +444,15 @@ impl ResponseResult for Account {} pub struct Attachment { /// The URL for the content. #[serde(rename="contentUrl")] - pub content_url: String, + pub content_url: Option<String>, /// The MIME type of the attachment. #[serde(rename="contentType")] - pub content_type: String, + pub content_type: Option<String>, /// The ID of the attachment. - pub id: String, + pub id: Option<String>, /// Indicates that the contentUrl is not available because the attachment content is still being processed. If the caller wishes to retrieve the content, it should try again later. #[serde(rename="isProcessingContent")] - pub is_processing_content: bool, + pub is_processing_content: Option<bool>, } impl ResponseResult for Attachment {} @@ -466,20 +466,20 @@ impl ResponseResult for Attachment {} pub struct Notification { /// The ID of the item that generated the notification. #[serde(rename="itemId")] - pub item_id: String, + pub item_id: Option<String>, /// The secret verify token provided by the service when it subscribed for notifications. #[serde(rename="verifyToken")] - pub verify_token: String, + pub verify_token: Option<String>, /// A list of actions taken by the user that triggered the notification. #[serde(rename="userActions")] - pub user_actions: Vec<UserAction>, + pub user_actions: Option<Vec<UserAction>>, /// The user token provided by the service when it subscribed for notifications. #[serde(rename="userToken")] - pub user_token: String, + pub user_token: Option<String>, /// The type of operation that generated the notification. - pub operation: String, + pub operation: Option<String>, /// The collection that generated the notification. - pub collection: String, + pub collection: Option<String>, } impl Part for Notification {} @@ -498,11 +498,11 @@ impl Part for Notification {} pub struct TimelineListResponse { /// The next page token. Provide this as the pageToken parameter in the request to retrieve the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Items in the timeline. - pub items: Vec<TimelineItem>, + pub items: Option<Vec<TimelineItem>>, /// The type of resource. This is always mirror#timeline. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for TimelineListResponse {} @@ -520,9 +520,9 @@ impl ResponseResult for TimelineListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContactsListResponse { /// Contact list. - pub items: Vec<Contact>, + pub items: Option<Vec<Contact>>, /// The type of resource. This is always mirror#contacts. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for ContactsListResponse {} @@ -712,7 +712,7 @@ pub struct Command { /// - TAKE_A_NOTE - Shares a timeline item with the transcription of user speech from the "Take a note" voice menu command. /// - POST_AN_UPDATE - Shares a timeline item with the transcription of user speech from the "Post an update" voice menu command. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for Command {} @@ -731,22 +731,22 @@ impl Part for Command {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Location { /// The type of resource. This is always mirror#location. - pub kind: String, + pub kind: Option<String>, /// The name to be displayed. This may be a business name or a user-defined place, such as "Home". #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The time at which this location was captured, formatted according to RFC 3339. - pub timestamp: String, + pub timestamp: Option<String>, /// The longitude, in degrees. - pub longitude: f64, + pub longitude: Option<f64>, /// The full address of the location. - pub address: String, + pub address: Option<String>, /// The latitude, in degrees. - pub latitude: f64, + pub latitude: Option<f64>, /// The ID of the location. - pub id: String, + pub id: Option<String>, /// The accuracy of the location fix in meters. - pub accuracy: f64, + pub accuracy: Option<f64>, } impl Resource for Location {} @@ -765,9 +765,9 @@ impl ResponseResult for Location {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SubscriptionsListResponse { /// The list of subscriptions. - pub items: Vec<Subscription>, + pub items: Option<Vec<Subscription>>, /// The type of resource. This is always mirror#subscriptionsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for SubscriptionsListResponse {} @@ -781,10 +781,10 @@ impl ResponseResult for SubscriptionsListResponse {} pub struct AuthToken { /// no description provided #[serde(rename="authToken")] - pub auth_token: String, + pub auth_token: Option<String>, /// no description provided #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for AuthToken {} @@ -797,9 +797,9 @@ impl Part for AuthToken {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserData { /// no description provided - pub key: String, + pub key: Option<String>, /// no description provided - pub value: String, + pub value: Option<String>, } impl Part for UserData {} @@ -817,9 +817,9 @@ impl Part for UserData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AttachmentsListResponse { /// The list of attachments. - pub items: Vec<Attachment>, + pub items: Option<Vec<Attachment>>, /// The type of resource. This is always mirror#attachmentsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for AttachmentsListResponse {} @@ -833,10 +833,10 @@ impl ResponseResult for AttachmentsListResponse {} pub struct NotificationConfig { /// The time at which the notification should be delivered. #[serde(rename="deliveryTime")] - pub delivery_time: String, + pub delivery_time: Option<String>, /// Describes how important the notification is. Allowed values are: /// - DEFAULT - Notifications of default importance. A chime will be played to alert users. - pub level: String, + pub level: Option<String>, } impl Part for NotificationConfig {} @@ -854,13 +854,13 @@ impl Part for NotificationConfig {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Setting { /// The type of resource. This is always mirror#setting. - pub kind: String, + pub kind: Option<String>, /// The setting's ID. The following IDs are valid: /// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content. /// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles. - pub id: String, + pub id: Option<String>, /// The setting value, as a string. - pub value: String, + pub value: Option<String>, } impl Resource for Setting {} @@ -874,12 +874,12 @@ impl ResponseResult for Setting {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MenuItem { /// The ContextualMenus.Command associated with this MenuItem (e.g. READ_ALOUD). The voice label for this command will be displayed in the voice menu and the touch label will be displayed in the touch menu. Note that the default menu value's display name will be overriden if you specify this property. Values that do not correspond to a ContextualMenus.Command name will be ignored. - pub contextual_command: String, + pub contextual_command: Option<String>, /// For CUSTOM items, a list of values controlling the appearance of the menu item in each of its states. A value for the DEFAULT state must be provided. If the PENDING or CONFIRMED states are missing, they will not be shown. - pub values: Vec<MenuValue>, + pub values: Option<Vec<MenuValue>>, /// If set to true on a CUSTOM menu item, that item will be removed from the menu after it is selected. #[serde(rename="removeWhenSelected")] - pub remove_when_selected: bool, + pub remove_when_selected: Option<bool>, /// Controls the behavior when the user picks the menu option. Allowed values are: /// - CUSTOM - Custom action set by the service. When the user selects this menuItem, the API triggers a notification to your callbackUrl with the userActions.type set to CUSTOM and the userActions.payload set to the ID of this menu item. This is the default value. /// - Built-in actions: @@ -897,14 +897,14 @@ pub struct MenuItem { /// - SEND_MESSAGE - Initiate sending a message to the timeline item's creator: /// - If the creator.phoneNumber is set and Glass is connected to an Android phone, the message is an SMS. /// - Otherwise, if the creator.email is set, the message is an email. - pub action: String, + pub action: Option<String>, /// A generic payload whose meaning changes depending on this MenuItem's action. /// - When the action is OPEN_URI, the payload is the URL of the website to view. /// - When the action is PLAY_VIDEO, the payload is the streaming URL of the video /// - When the action is GET_MEDIA_INPUT, the payload is the text transcription of a user's speech input - pub payload: String, + pub payload: Option<String>, /// The ID for this menu item. This is generated by the application and is treated as an opaque token. - pub id: String, + pub id: Option<String>, } impl Part for MenuItem {} @@ -922,9 +922,9 @@ impl Part for MenuItem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocationsListResponse { /// The list of locations. - pub items: Vec<Location>, + pub items: Option<Vec<Location>>, /// The type of resource. This is always mirror#locationsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for LocationsListResponse {} @@ -938,15 +938,15 @@ impl ResponseResult for LocationsListResponse {} pub struct MenuValue { /// URL of an icon to display with the menu item. #[serde(rename="iconUrl")] - pub icon_url: String, + pub icon_url: Option<String>, /// The state that this value applies to. Allowed values are: /// - DEFAULT - Default value shown when displayed in the menuItems list. /// - PENDING - Value shown when the menuItem has been selected by the user but can still be cancelled. /// - CONFIRMED - Value shown when the menuItem has been selected by the user and can no longer be cancelled. - pub state: String, + pub state: Option<String>, /// The name to display for the menu item. If you specify this property for a built-in menu item, the default contextual voice command for that menu item is not shown. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, } impl Part for MenuValue {} @@ -1701,7 +1701,7 @@ impl<'a, C, A> ContactMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subscription = Default::default(); +/// let mut req = Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1767,16 +1767,20 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1999,16 +2003,20 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2138,7 +2146,7 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subscription = Default::default(); +/// let mut req = Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2230,16 +2238,20 @@ impl<'a, C, A> SubscriptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2447,16 +2459,20 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2667,16 +2683,20 @@ impl<'a, C, A> TimelineAttachmentListCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2817,7 +2837,7 @@ impl<'a, C, A> TimelineAttachmentListCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TimelineItem = Default::default(); +/// let mut req = TimelineItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -2894,16 +2914,20 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -3149,7 +3173,7 @@ impl<'a, C, A> TimelineInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TimelineItem = Default::default(); +/// let mut req = TimelineItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3241,16 +3265,20 @@ impl<'a, C, A> TimelinePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3493,16 +3521,20 @@ impl<'a, C, A> TimelineListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3774,16 +3806,20 @@ impl<'a, C, A> TimelineAttachmentInsertCall<'a, C, A> where C: BorrowMut<hyper:: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -4103,16 +4139,20 @@ impl<'a, C, A> TimelineAttachmentDeleteCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4332,16 +4372,20 @@ impl<'a, C, A> TimelineDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4472,7 +4516,7 @@ impl<'a, C, A> TimelineDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TimelineItem = Default::default(); +/// let mut req = TimelineItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -4575,16 +4619,20 @@ impl<'a, C, A> TimelineUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -4944,16 +4992,20 @@ impl<'a, C, A> TimelineAttachmentGetCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5184,16 +5236,20 @@ impl<'a, C, A> TimelineGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5414,16 +5470,20 @@ impl<'a, C, A> SettingGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5646,16 +5706,20 @@ impl<'a, C, A> LocationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5850,16 +5914,20 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5989,7 +6057,7 @@ impl<'a, C, A> LocationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6329,16 +6397,20 @@ impl<'a, C, A> ContactGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6558,16 +6630,20 @@ impl<'a, C, A> ContactDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -6697,7 +6773,7 @@ impl<'a, C, A> ContactDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Contact = Default::default(); +/// let mut req = Contact::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6763,16 +6839,20 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6915,7 +6995,7 @@ impl<'a, C, A> ContactInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Contact = Default::default(); +/// let mut req = Contact::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7007,16 +7087,20 @@ impl<'a, C, A> ContactPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7224,16 +7308,20 @@ impl<'a, C, A> ContactListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7363,7 +7451,7 @@ impl<'a, C, A> ContactListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Contact = Default::default(); +/// let mut req = Contact::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7455,16 +7543,20 @@ impl<'a, C, A> ContactUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/oauth2_v2-cli/Cargo.toml b/gen/oauth2_v2-cli/Cargo.toml index 89a0cf5c2c..e0935cbf17 100644 --- a/gen/oauth2_v2-cli/Cargo.toml +++ b/gen/oauth2_v2-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-oauth2_v2-cli" -version = "0.0.1+20150319" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/accounts/docs/OAuth2" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/oauth2_v2-cli/mkdocs.yml b/gen/oauth2_v2-cli/mkdocs.yml index dd47211a69..09e1f91baf 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+20150319 +site_name: oauth2 v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/oauth2_v2-cli/src/cmn.rs +++ b/gen/oauth2_v2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/oauth2_v2-cli/src/main.rs b/gen/oauth2_v2-cli/src/main.rs index 884051a7d7..92d9e2c929 100644 --- a/gen/oauth2_v2-cli/src/main.rs +++ b/gen/oauth2_v2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -35,6 +36,12 @@ Configuration: 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. "); mod cmn; @@ -58,7 +65,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.methods().get_cert_for_open_id_connect(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -90,8 +97,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -102,7 +108,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.methods().tokeninfo(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "token-handle" => { call = call.token_handle(value.unwrap_or("")); @@ -143,8 +149,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -155,7 +160,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.userinfo().get(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -187,8 +192,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -199,7 +203,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.userinfo().v2_me_get(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -231,8 +235,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -252,7 +255,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_userinfo { + } + else if self.opt.cmd_userinfo { if self.opt.cmd_get { call_result = self._userinfo_get(dry_run, &mut err); } else if self.opt.cmd_v2_me_get { @@ -280,21 +284,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "oauth2-v2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "oauth2-v2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "oauth2-v2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "oauth2-v2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Oauth2::new(hyper::Client::new(), auth), + hub: api::Oauth2::new(client, auth), }; match engine._doit(true) { @@ -314,12 +334,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 4f3ac71071..07b8cf01fd 100644 --- a/gen/oauth2_v2/Cargo.toml +++ b/gen/oauth2_v2/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-oauth2_v2" -version = "0.1.5+20150319" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/accounts/docs/OAuth2" diff --git a/gen/oauth2_v2/README.md b/gen/oauth2_v2/README.md index 7849acfdd0..5e8b0252d3 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+20150319*, where *20150319* 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.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*. Everything else about the *oauth2* *v2* API can be found at the [official documentation site](https://developers.google.com/accounts/docs/OAuth2). diff --git a/gen/oauth2_v2/src/cmn.rs b/gen/oauth2_v2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/oauth2_v2/src/cmn.rs +++ b/gen/oauth2_v2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/oauth2_v2/src/lib.rs b/gen/oauth2_v2/src/lib.rs index f1a02bc9fa..affdcf0831 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+20150319*, where *20150319* 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.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*. //! //! Everything else about the *oauth2* *v2* API can be found at the //! [official documentation site](https://developers.google.com/accounts/docs/OAuth2). @@ -348,17 +348,17 @@ impl<'a, C, A> Oauth2<C, A> pub struct JwkKeys { /// no description provided #[serde(rename="use")] - pub use_: String, + pub use_: Option<String>, /// no description provided - pub e: String, + pub e: Option<String>, /// no description provided - pub kty: String, + pub kty: Option<String>, /// no description provided - pub alg: String, + pub alg: Option<String>, /// no description provided - pub kid: String, + pub kid: Option<String>, /// no description provided - pub n: String, + pub n: Option<String>, } impl NestedType for JwkKeys {} @@ -377,7 +377,7 @@ impl Part for JwkKeys {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Jwk { /// no description provided - pub keys: Vec<JwkKeys>, + pub keys: Option<Vec<JwkKeys>>, } impl ResponseResult for Jwk {} @@ -396,27 +396,27 @@ impl ResponseResult for Jwk {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Userinfoplus { /// The user's last name. - pub family_name: String, + pub family_name: Option<String>, /// The user's full name. - pub name: String, + pub name: Option<String>, /// URL of the user's picture image. - pub picture: String, + pub picture: Option<String>, /// The user's preferred locale. - pub locale: String, + pub locale: Option<String>, /// The user's gender. - pub gender: String, + pub gender: Option<String>, /// The obfuscated ID of the user. - pub id: String, + pub id: Option<String>, /// URL of the profile page. - pub link: String, + pub link: Option<String>, /// The user's first name. - pub given_name: String, + pub given_name: Option<String>, /// The user's email address. - pub email: String, + pub email: Option<String>, /// The hosted domain e.g. example.com if the user is Google apps user. - pub hd: String, + pub hd: Option<String>, /// Boolean flag which is true if the email address is verified. Always verified because we only return the user's primary email address. - pub verified_email: bool, + pub verified_email: Option<bool>, } impl ResponseResult for Userinfoplus {} @@ -434,23 +434,23 @@ impl ResponseResult for Userinfoplus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Tokeninfo { /// To whom was the token issued to. In general the same as audience. - pub issued_to: String, + pub issued_to: Option<String>, /// The token handle associated with this token. - pub token_handle: String, + pub token_handle: Option<String>, /// The expiry time of the token, as number of seconds left until expiry. - pub expires_in: i32, + pub expires_in: Option<i32>, /// The access type granted with this token. It can be offline or online. - pub access_type: String, + pub access_type: Option<String>, /// Who is the intended audience for this token. In general the same as issued_to. - pub audience: String, + pub audience: Option<String>, /// The space separated list of scopes granted to this token. - pub scope: String, + pub scope: Option<String>, /// The obfuscated user id. - pub user_id: String, + pub user_id: Option<String>, /// The email address of the user. Present only if the email scope is present in the request. - pub email: String, + pub email: Option<String>, /// Boolean flag which is true if the email address is verified. Present only if the email scope is present in the request. - pub verified_email: bool, + pub verified_email: Option<bool>, } impl ResponseResult for Tokeninfo {} @@ -666,16 +666,20 @@ impl<'a, C, A> UserinfoV2MeGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -858,16 +862,20 @@ impl<'a, C, A> UserinfoGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/pagespeedonline2-cli/Cargo.toml b/gen/pagespeedonline2-cli/Cargo.toml index 5224ab42f9..91a036aff9 100644 --- a/gen/pagespeedonline2-cli/Cargo.toml +++ b/gen/pagespeedonline2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-pagespeedonline2-cli" version = "0.0.1+20150317" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/speed/docs/insights/v2/getting-started" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/pagespeedonline2-cli/src/cmn.rs b/gen/pagespeedonline2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/pagespeedonline2-cli/src/cmn.rs +++ b/gen/pagespeedonline2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/pagespeedonline2-cli/src/main.rs b/gen/pagespeedonline2-cli/src/main.rs index 22f591c66c..521d5ef1b0 100644 --- a/gen/pagespeedonline2-cli/src/main.rs +++ b/gen/pagespeedonline2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -28,6 +29,12 @@ Configuration: 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. "); mod cmn; @@ -51,7 +58,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.pagespeedapi().runpagespeed(&self.opt.arg_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "strategy" => { call = call.strategy(value.unwrap_or("")); @@ -98,8 +105,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -137,21 +143,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "pagespeedonline2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "pagespeedonline2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "pagespeedonline2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "pagespeedonline2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Pagespeedonline::new(hyper::Client::new(), auth), + hub: api::Pagespeedonline::new(client, auth), }; match engine._doit(true) { @@ -171,12 +193,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/pagespeedonline2/Cargo.toml b/gen/pagespeedonline2/Cargo.toml index ce55ea6e9b..63e71cb79e 100644 --- a/gen/pagespeedonline2/Cargo.toml +++ b/gen/pagespeedonline2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-pagespeedonline2" version = "0.1.5+20150317" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/speed/docs/insights/v2/getting-started" diff --git a/gen/pagespeedonline2/src/cmn.rs b/gen/pagespeedonline2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/pagespeedonline2/src/cmn.rs +++ b/gen/pagespeedonline2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/pagespeedonline2/src/lib.rs b/gen/pagespeedonline2/src/lib.rs index 2d43c205b2..0e2dedca5a 100644 --- a/gen/pagespeedonline2/src/lib.rs +++ b/gen/pagespeedonline2/src/lib.rs @@ -315,13 +315,13 @@ impl<'a, C, A> Pagespeedonline<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiFormatStringV2ArgsSecondaryRects { /// The width of the rect. - pub width: i32, + pub width: Option<i32>, /// The top coordinate of the rect, in page coordinates. - pub top: i32, + pub top: Option<i32>, /// The height of the rect. - pub height: i32, + pub height: Option<i32>, /// The left coordinate of the rect, in page coordinates. - pub left: i32, + pub left: Option<i32>, } impl NestedType for PagespeedApiFormatStringV2ArgsSecondaryRects {} @@ -335,13 +335,13 @@ impl Part for PagespeedApiFormatStringV2ArgsSecondaryRects {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiFormatStringV2ArgsRects { /// The width of the rect. - pub width: i32, + pub width: Option<i32>, /// The top coordinate of the rect, in page coordinates. - pub top: i32, + pub top: Option<i32>, /// The height of the rect. - pub height: i32, + pub height: Option<i32>, /// The left coordinate of the rect, in page coordinates. - pub left: i32, + pub left: Option<i32>, } impl NestedType for PagespeedApiFormatStringV2ArgsRects {} @@ -355,9 +355,9 @@ impl Part for PagespeedApiFormatStringV2ArgsRects {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiFormatStringV2 { /// List of arguments for the format string. - pub args: Vec<PagespeedApiFormatStringV2Args>, + pub args: Option<Vec<PagespeedApiFormatStringV2Args>>, /// A localized format string with {{FOO}} placeholders, where 'FOO' is the key of the argument whose value should be substituted. For HYPERLINK arguments, the format string will instead contain {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'. - pub format: String, + pub format: Option<String>, } impl Part for PagespeedApiFormatStringV2 {} @@ -370,9 +370,9 @@ impl Part for PagespeedApiFormatStringV2 {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultFormattedResultsRuleResultsUrlBlocksUrls { /// List of entries that provide additional details about a single URL. Optional. - pub details: Vec<PagespeedApiFormatStringV2>, + pub details: Option<Vec<PagespeedApiFormatStringV2>>, /// A format string that gives information about the URL, and a list of arguments for that format string. - pub result: PagespeedApiFormatStringV2, + pub result: Option<PagespeedApiFormatStringV2>, } impl NestedType for ResultFormattedResultsRuleResultsUrlBlocksUrls {} @@ -387,43 +387,43 @@ impl Part for ResultFormattedResultsRuleResultsUrlBlocksUrls {} pub struct ResultPageStats { /// Number of response bytes for flash resources on the page. #[serde(rename="flashResponseBytes")] - pub flash_response_bytes: String, + pub flash_response_bytes: Option<String>, /// Total size of all request bytes sent by the page. #[serde(rename="totalRequestBytes")] - pub total_request_bytes: String, + pub total_request_bytes: Option<String>, /// Number of CSS resources referenced by the page. #[serde(rename="numberCssResources")] - pub number_css_resources: i32, + pub number_css_resources: Option<i32>, /// Number of uncompressed response bytes for text resources not covered by other statistics (i.e non-HTML, non-script, non-CSS resources) on the page. #[serde(rename="textResponseBytes")] - pub text_response_bytes: String, + pub text_response_bytes: Option<String>, /// Number of HTTP resources loaded by the page. #[serde(rename="numberResources")] - pub number_resources: i32, + pub number_resources: Option<i32>, /// Number of response bytes for other resources on the page. #[serde(rename="otherResponseBytes")] - pub other_response_bytes: String, + pub other_response_bytes: Option<String>, /// Number of response bytes for image resources on the page. #[serde(rename="imageResponseBytes")] - pub image_response_bytes: String, + pub image_response_bytes: Option<String>, /// Number of unique hosts referenced by the page. #[serde(rename="numberHosts")] - pub number_hosts: i32, + pub number_hosts: Option<i32>, /// Number of uncompressed response bytes for JS resources on the page. #[serde(rename="javascriptResponseBytes")] - pub javascript_response_bytes: String, + pub javascript_response_bytes: Option<String>, /// Number of uncompressed response bytes for the main HTML document and all iframes on the page. #[serde(rename="htmlResponseBytes")] - pub html_response_bytes: String, + pub html_response_bytes: Option<String>, /// Number of uncompressed response bytes for CSS resources on the page. #[serde(rename="cssResponseBytes")] - pub css_response_bytes: String, + pub css_response_bytes: Option<String>, /// Number of JavaScript resources referenced by the page. #[serde(rename="numberJsResources")] - pub number_js_resources: i32, + pub number_js_resources: Option<i32>, /// Number of static (i.e. cacheable) resources on the page. #[serde(rename="numberStaticResources")] - pub number_static_resources: i32, + pub number_static_resources: Option<i32>, } impl NestedType for ResultPageStats {} @@ -438,17 +438,17 @@ impl Part for ResultPageStats {} pub struct ResultFormattedResultsRuleResults { /// Localized name of the rule, intended for presentation to a user. #[serde(rename="localizedRuleName")] - pub localized_rule_name: String, + pub localized_rule_name: Option<String>, /// List of blocks of URLs. Each block may contain a heading and a list of URLs. Each URL may optionally include additional details. #[serde(rename="urlBlocks")] - pub url_blocks: Vec<ResultFormattedResultsRuleResultsUrlBlocks>, + pub url_blocks: Option<Vec<ResultFormattedResultsRuleResultsUrlBlocks>>, /// List of rule groups that this rule belongs to. Each entry in the list is one of "SPEED" or "USABILITY". - pub groups: Vec<String>, + pub groups: Option<Vec<String>>, /// The impact (unbounded floating point value) that implementing the suggestions for this rule would have on making the page faster. Impact is comparable between rules to determine which rule's suggestions would have a higher or lower impact on making a page faster. For instance, if enabling compression would save 1MB, while optimizing images would save 500kB, the enable compression rule would have 2x the impact of the image optimization rule, all other things being equal. #[serde(rename="ruleImpact")] - pub rule_impact: f64, + pub rule_impact: Option<f64>, /// A brief summary description for the rule, indicating at a high level what should be done to follow the rule and what benefit can be gained by doing so. - pub summary: PagespeedApiFormatStringV2, + pub summary: Option<PagespeedApiFormatStringV2>, } impl NestedType for ResultFormattedResultsRuleResults {} @@ -462,9 +462,9 @@ impl Part for ResultFormattedResultsRuleResults {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultVersion { /// The major version number of PageSpeed used to generate these results. - pub major: i32, + pub major: Option<i32>, /// The minor version number of PageSpeed used to generate these results. - pub minor: i32, + pub minor: Option<i32>, } impl NestedType for ResultVersion {} @@ -478,16 +478,16 @@ impl Part for ResultVersion {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiFormatStringV2Args { /// The screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. If this is absent for a SNAPSHOT_RECT argument, it means that that argument refers to the entire snapshot. - pub rects: Vec<PagespeedApiFormatStringV2ArgsRects>, + pub rects: Option<Vec<PagespeedApiFormatStringV2ArgsRects>>, /// The placeholder key for this arg, as a string. - pub key: String, + pub key: Option<String>, /// Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or SNAPSHOT_RECT. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Secondary screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. - pub secondary_rects: Vec<PagespeedApiFormatStringV2ArgsSecondaryRects>, + pub secondary_rects: Option<Vec<PagespeedApiFormatStringV2ArgsSecondaryRects>>, /// Argument value, as a localized string. - pub value: String, + pub value: Option<String>, } impl NestedType for PagespeedApiFormatStringV2Args {} @@ -501,9 +501,9 @@ impl Part for PagespeedApiFormatStringV2Args {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultFormattedResultsRuleResultsUrlBlocks { /// Heading to be displayed with the list of URLs. - pub header: PagespeedApiFormatStringV2, + pub header: Option<PagespeedApiFormatStringV2>, /// List of entries that provide information about URLs in the url block. Optional. - pub urls: Vec<ResultFormattedResultsRuleResultsUrlBlocksUrls>, + pub urls: Option<Vec<ResultFormattedResultsRuleResultsUrlBlocksUrls>>, } impl NestedType for ResultFormattedResultsRuleResultsUrlBlocks {} @@ -517,17 +517,17 @@ impl Part for ResultFormattedResultsRuleResultsUrlBlocks {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiImageV2 { /// Width of screenshot in pixels. - pub width: i32, + pub width: Option<i32>, /// Unique string key, if any, identifying this image. - pub key: String, + pub key: Option<String>, /// The region of the page that is captured by this image, with dimensions measured in CSS pixels. - pub page_rect: PagespeedApiImageV2PageRect, + pub page_rect: Option<PagespeedApiImageV2PageRect>, /// Image data base64 encoded. - pub data: String, + pub data: Option<String>, /// Mime type of image data (e.g. "image/jpeg"). - pub mime_type: String, + pub mime_type: Option<String>, /// Height of screenshot in pixels. - pub height: i32, + pub height: Option<i32>, } impl Part for PagespeedApiImageV2 {} @@ -545,30 +545,30 @@ impl Part for PagespeedApiImageV2 {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultType { /// Kind of result. - pub kind: String, + pub kind: Option<String>, /// Response code for the document. 200 indicates a normal page load. 4xx/5xx indicates an error. #[serde(rename="responseCode")] - pub response_code: i32, + pub response_code: Option<i32>, /// Base64-encoded screenshot of the page that was analyzed. - pub screenshot: PagespeedApiImageV2, + pub screenshot: Option<PagespeedApiImageV2>, /// Title of the page, as displayed in the browser's title bar. - pub title: String, + pub title: Option<String>, /// A map with one entry for each rule group in these results. #[serde(rename="ruleGroups")] - pub rule_groups: HashMap<String, ResultRuleGroups>, + pub rule_groups: Option<HashMap<String, ResultRuleGroups>>, /// The version of PageSpeed used to generate these results. - pub version: ResultVersion, + pub version: Option<ResultVersion>, /// Localized PageSpeed results. Contains a ruleResults entry for each PageSpeed rule instantiated and run by the server. #[serde(rename="formattedResults")] - pub formatted_results: ResultFormattedResults, + pub formatted_results: Option<ResultFormattedResults>, /// List of rules that were specified in the request, but which the server did not know how to instantiate. #[serde(rename="invalidRules")] - pub invalid_rules: Vec<String>, + pub invalid_rules: Option<Vec<String>>, /// Summary statistics for the page, such as number of JavaScript bytes, number of HTML bytes, etc. #[serde(rename="pageStats")] - pub page_stats: ResultPageStats, + pub page_stats: Option<ResultPageStats>, /// Canonicalized and final URL for the document, after following page redirects (if any). - pub id: String, + pub id: Option<String>, } impl ResponseResult for ResultType {} @@ -581,13 +581,13 @@ impl ResponseResult for ResultType {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PagespeedApiImageV2PageRect { /// The width of the rect. - pub width: i32, + pub width: Option<i32>, /// The top coordinate of the rect, in page coordinates. - pub top: i32, + pub top: Option<i32>, /// The height of the rect. - pub height: i32, + pub height: Option<i32>, /// The left coordinate of the rect, in page coordinates. - pub left: i32, + pub left: Option<i32>, } impl NestedType for PagespeedApiImageV2PageRect {} @@ -601,10 +601,10 @@ impl Part for PagespeedApiImageV2PageRect {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultFormattedResults { /// The locale of the formattedResults, e.g. "en_US". - pub locale: String, + pub locale: Option<String>, /// Dictionary of formatted rule results, with one entry for each PageSpeed rule instantiated and run by the server. #[serde(rename="ruleResults")] - pub rule_results: HashMap<String, ResultFormattedResultsRuleResults>, + pub rule_results: Option<HashMap<String, ResultFormattedResultsRuleResults>>, } impl NestedType for ResultFormattedResults {} @@ -618,7 +618,7 @@ impl Part for ResultFormattedResults {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultRuleGroups { /// The score (0-100) for this rule group, which indicates how much better a page could be in that category (e.g. how much faster, or how much more usable). A high score indicates little room for improvement, while a lower score indicates more room for improvement. - pub score: i32, + pub score: Option<i32>, } impl NestedType for ResultRuleGroups {} diff --git a/gen/plus1-cli/Cargo.toml b/gen/plus1-cli/Cargo.toml index c89a2423e7..a3ed7d5a13 100644 --- a/gen/plus1-cli/Cargo.toml +++ b/gen/plus1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-plus1-cli" -version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/+/api/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/plus1-cli/mkdocs.yml b/gen/plus1-cli/mkdocs.yml index 690f0173cb..db18bb94ff 100644 --- a/gen/plus1-cli/mkdocs.yml +++ b/gen/plus1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plus v0.0.1+20150326 +site_name: plus v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/plus1-cli/src/cmn.rs +++ b/gen/plus1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/plus1-cli/src/main.rs b/gen/plus1-cli/src/main.rs index 8f58c62b6a..b1c40fcc69 100644 --- a/gen/plus1-cli/src/main.rs +++ b/gen/plus1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -43,6 +44,12 @@ Configuration: 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. "); mod cmn; @@ -66,7 +73,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().get(&self.opt.arg_activity_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -98,8 +105,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -110,7 +116,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -148,8 +154,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -160,7 +165,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().search(&self.opt.arg_query); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -204,8 +209,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -216,7 +220,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.comments().get(&self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -248,8 +252,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -260,7 +263,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.comments().list(&self.opt.arg_activity_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -301,8 +304,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -311,10 +313,10 @@ impl Engine { fn _moments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Moment = Default::default(); + 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); + 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")); @@ -337,9 +339,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -370,483 +373,492 @@ impl Engine { }, "target.start-date" => { request_target_init(&mut request); - request.target.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "target.end-date" => { request_target_init(&mut request); - request.target.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "target.text" => { request_target_init(&mut request); - request.target.as_mut().unwrap().text = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "target.image" => { request_target_init(&mut request); - request.target.as_mut().unwrap().image = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().image = Some(value.unwrap_or("").to_string()); }, "target.birth-date" => { request_target_init(&mut request); - request.target.as_mut().unwrap().birth_date = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().birth_date = Some(value.unwrap_or("").to_string()); }, "target.date-published" => { request_target_init(&mut request); - request.target.as_mut().unwrap().date_published = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().date_published = Some(value.unwrap_or("").to_string()); }, "target.address-locality" => { request_target_init(&mut request); - request.target.as_mut().unwrap().address_locality = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().address_locality = Some(value.unwrap_or("").to_string()); }, "target.additional-name" => { request_target_init(&mut request); - request.target.as_mut().unwrap().additional_name.push(value.unwrap_or("").to_string()); + if request.target.as_mut().unwrap().additional_name.is_none() { + request.target.as_mut().unwrap().additional_name = Some(Default::default()); + } + request.target.as_mut().unwrap().additional_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "target.worst-rating" => { request_target_init(&mut request); - request.target.as_mut().unwrap().worst_rating = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().worst_rating = Some(value.unwrap_or("").to_string()); }, "target.duration" => { request_target_init(&mut request); - request.target.as_mut().unwrap().duration = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "target.thumbnail-url" => { request_target_init(&mut request); - request.target.as_mut().unwrap().thumbnail_url = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().thumbnail_url = Some(value.unwrap_or("").to_string()); }, "target.id" => { request_target_init(&mut request); - request.target.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "target.post-office-box-number" => { request_target_init(&mut request); - request.target.as_mut().unwrap().post_office_box_number = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().post_office_box_number = Some(value.unwrap_or("").to_string()); }, "target.caption" => { request_target_init(&mut request); - request.target.as_mut().unwrap().caption = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().caption = Some(value.unwrap_or("").to_string()); }, "target.best-rating" => { request_target_init(&mut request); - request.target.as_mut().unwrap().best_rating = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().best_rating = Some(value.unwrap_or("").to_string()); }, "target.address-country" => { request_target_init(&mut request); - request.target.as_mut().unwrap().address_country = arg_from_str(value.unwrap_or("-0"), err, "target.address-country", "int64"); + request.target.as_mut().unwrap().address_country = Some(arg_from_str(value.unwrap_or("-0"), err, "target.address-country", "int64")); }, "target.width" => { request_target_init(&mut request); - request.target.as_mut().unwrap().width = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().width = Some(value.unwrap_or("").to_string()); }, "target.street-address" => { request_target_init(&mut request); - request.target.as_mut().unwrap().street_address = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().street_address = Some(value.unwrap_or("").to_string()); }, "target.latitude" => { request_target_init(&mut request); - request.target.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "target.latitude", "number"); + request.target.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "target.latitude", "number")); }, "target.embed-url" => { request_target_init(&mut request); - request.target.as_mut().unwrap().embed_url = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().embed_url = Some(value.unwrap_or("").to_string()); }, "target.type" => { request_target_init(&mut request); - request.target.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "target.date-modified" => { request_target_init(&mut request); - request.target.as_mut().unwrap().date_modified = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().date_modified = Some(value.unwrap_or("").to_string()); }, "target.content-size" => { request_target_init(&mut request); - request.target.as_mut().unwrap().content_size = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().content_size = Some(value.unwrap_or("").to_string()); }, "target.content-url" => { request_target_init(&mut request); - request.target.as_mut().unwrap().content_url = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().content_url = Some(value.unwrap_or("").to_string()); }, "target.description" => { request_target_init(&mut request); - request.target.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "target.family-name" => { request_target_init(&mut request); - request.target.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().family_name = Some(value.unwrap_or("").to_string()); }, "target.date-created" => { request_target_init(&mut request); - request.target.as_mut().unwrap().date_created = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().date_created = Some(value.unwrap_or("").to_string()); }, "target.postal-code" => { request_target_init(&mut request); - request.target.as_mut().unwrap().postal_code = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().postal_code = Some(value.unwrap_or("").to_string()); }, "target.attendee-count" => { request_target_init(&mut request); - request.target.as_mut().unwrap().attendee_count = arg_from_str(value.unwrap_or("-0"), err, "target.attendee-count", "integer"); + request.target.as_mut().unwrap().attendee_count = Some(arg_from_str(value.unwrap_or("-0"), err, "target.attendee-count", "integer")); }, "target.height" => { request_target_init(&mut request); - request.target.as_mut().unwrap().height = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().height = Some(value.unwrap_or("").to_string()); }, "target.ticker-symbol" => { request_target_init(&mut request); - request.target.as_mut().unwrap().ticker_symbol = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().ticker_symbol = Some(value.unwrap_or("").to_string()); }, "target.player-type" => { request_target_init(&mut request); - request.target.as_mut().unwrap().player_type = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().player_type = Some(value.unwrap_or("").to_string()); }, "target.kind" => { request_target_init(&mut request); - request.target.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "target.name" => { request_target_init(&mut request); - request.target.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "target.url" => { request_target_init(&mut request); - request.target.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "target.gender" => { request_target_init(&mut request); - request.target.as_mut().unwrap().gender = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().gender = Some(value.unwrap_or("").to_string()); }, "target.longitude" => { request_target_init(&mut request); - request.target.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "target.longitude", "number"); + request.target.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "target.longitude", "number")); }, "target.address-region" => { request_target_init(&mut request); - request.target.as_mut().unwrap().address_region = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().address_region = Some(value.unwrap_or("").to_string()); }, "target.rating-value" => { request_target_init(&mut request); - request.target.as_mut().unwrap().rating_value = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().rating_value = Some(value.unwrap_or("").to_string()); }, "target.given-name" => { request_target_init(&mut request); - request.target.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); + request.target.as_mut().unwrap().given_name = Some(value.unwrap_or("").to_string()); }, "object.start-date" => { request_object_init(&mut request); - request.object.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "object.end-date" => { request_object_init(&mut request); - request.object.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "object.text" => { request_object_init(&mut request); - request.object.as_mut().unwrap().text = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "object.image" => { request_object_init(&mut request); - request.object.as_mut().unwrap().image = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().image = Some(value.unwrap_or("").to_string()); }, "object.birth-date" => { request_object_init(&mut request); - request.object.as_mut().unwrap().birth_date = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().birth_date = Some(value.unwrap_or("").to_string()); }, "object.date-published" => { request_object_init(&mut request); - request.object.as_mut().unwrap().date_published = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().date_published = Some(value.unwrap_or("").to_string()); }, "object.address-locality" => { request_object_init(&mut request); - request.object.as_mut().unwrap().address_locality = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().address_locality = Some(value.unwrap_or("").to_string()); }, "object.additional-name" => { request_object_init(&mut request); - request.object.as_mut().unwrap().additional_name.push(value.unwrap_or("").to_string()); + if request.object.as_mut().unwrap().additional_name.is_none() { + request.object.as_mut().unwrap().additional_name = Some(Default::default()); + } + request.object.as_mut().unwrap().additional_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "object.worst-rating" => { request_object_init(&mut request); - request.object.as_mut().unwrap().worst_rating = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().worst_rating = Some(value.unwrap_or("").to_string()); }, "object.duration" => { request_object_init(&mut request); - request.object.as_mut().unwrap().duration = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "object.thumbnail-url" => { request_object_init(&mut request); - request.object.as_mut().unwrap().thumbnail_url = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().thumbnail_url = Some(value.unwrap_or("").to_string()); }, "object.id" => { request_object_init(&mut request); - request.object.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "object.post-office-box-number" => { request_object_init(&mut request); - request.object.as_mut().unwrap().post_office_box_number = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().post_office_box_number = Some(value.unwrap_or("").to_string()); }, "object.caption" => { request_object_init(&mut request); - request.object.as_mut().unwrap().caption = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().caption = Some(value.unwrap_or("").to_string()); }, "object.best-rating" => { request_object_init(&mut request); - request.object.as_mut().unwrap().best_rating = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().best_rating = Some(value.unwrap_or("").to_string()); }, "object.address-country" => { request_object_init(&mut request); - request.object.as_mut().unwrap().address_country = arg_from_str(value.unwrap_or("-0"), err, "object.address-country", "int64"); + request.object.as_mut().unwrap().address_country = Some(arg_from_str(value.unwrap_or("-0"), err, "object.address-country", "int64")); }, "object.width" => { request_object_init(&mut request); - request.object.as_mut().unwrap().width = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().width = Some(value.unwrap_or("").to_string()); }, "object.street-address" => { request_object_init(&mut request); - request.object.as_mut().unwrap().street_address = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().street_address = Some(value.unwrap_or("").to_string()); }, "object.latitude" => { request_object_init(&mut request); - request.object.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "object.latitude", "number"); + request.object.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "object.latitude", "number")); }, "object.embed-url" => { request_object_init(&mut request); - request.object.as_mut().unwrap().embed_url = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().embed_url = Some(value.unwrap_or("").to_string()); }, "object.type" => { request_object_init(&mut request); - request.object.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "object.date-modified" => { request_object_init(&mut request); - request.object.as_mut().unwrap().date_modified = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().date_modified = Some(value.unwrap_or("").to_string()); }, "object.content-size" => { request_object_init(&mut request); - request.object.as_mut().unwrap().content_size = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().content_size = Some(value.unwrap_or("").to_string()); }, "object.content-url" => { request_object_init(&mut request); - request.object.as_mut().unwrap().content_url = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().content_url = Some(value.unwrap_or("").to_string()); }, "object.description" => { request_object_init(&mut request); - request.object.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "object.family-name" => { request_object_init(&mut request); - request.object.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().family_name = Some(value.unwrap_or("").to_string()); }, "object.date-created" => { request_object_init(&mut request); - request.object.as_mut().unwrap().date_created = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().date_created = Some(value.unwrap_or("").to_string()); }, "object.postal-code" => { request_object_init(&mut request); - request.object.as_mut().unwrap().postal_code = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().postal_code = Some(value.unwrap_or("").to_string()); }, "object.attendee-count" => { request_object_init(&mut request); - request.object.as_mut().unwrap().attendee_count = arg_from_str(value.unwrap_or("-0"), err, "object.attendee-count", "integer"); + request.object.as_mut().unwrap().attendee_count = Some(arg_from_str(value.unwrap_or("-0"), err, "object.attendee-count", "integer")); }, "object.height" => { request_object_init(&mut request); - request.object.as_mut().unwrap().height = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().height = Some(value.unwrap_or("").to_string()); }, "object.ticker-symbol" => { request_object_init(&mut request); - request.object.as_mut().unwrap().ticker_symbol = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().ticker_symbol = Some(value.unwrap_or("").to_string()); }, "object.player-type" => { request_object_init(&mut request); - request.object.as_mut().unwrap().player_type = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().player_type = Some(value.unwrap_or("").to_string()); }, "object.kind" => { request_object_init(&mut request); - request.object.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "object.name" => { request_object_init(&mut request); - request.object.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "object.url" => { request_object_init(&mut request); - request.object.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "object.gender" => { request_object_init(&mut request); - request.object.as_mut().unwrap().gender = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().gender = Some(value.unwrap_or("").to_string()); }, "object.longitude" => { request_object_init(&mut request); - request.object.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "object.longitude", "number"); + request.object.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "object.longitude", "number")); }, "object.address-region" => { request_object_init(&mut request); - request.object.as_mut().unwrap().address_region = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().address_region = Some(value.unwrap_or("").to_string()); }, "object.rating-value" => { request_object_init(&mut request); - request.object.as_mut().unwrap().rating_value = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().rating_value = Some(value.unwrap_or("").to_string()); }, "object.given-name" => { request_object_init(&mut request); - request.object.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().given_name = Some(value.unwrap_or("").to_string()); }, "result.start-date" => { request_result_init(&mut request); - request.result.as_mut().unwrap().start_date = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().start_date = Some(value.unwrap_or("").to_string()); }, "result.end-date" => { request_result_init(&mut request); - request.result.as_mut().unwrap().end_date = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().end_date = Some(value.unwrap_or("").to_string()); }, "result.text" => { request_result_init(&mut request); - request.result.as_mut().unwrap().text = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "result.image" => { request_result_init(&mut request); - request.result.as_mut().unwrap().image = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().image = Some(value.unwrap_or("").to_string()); }, "result.birth-date" => { request_result_init(&mut request); - request.result.as_mut().unwrap().birth_date = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().birth_date = Some(value.unwrap_or("").to_string()); }, "result.date-published" => { request_result_init(&mut request); - request.result.as_mut().unwrap().date_published = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().date_published = Some(value.unwrap_or("").to_string()); }, "result.address-locality" => { request_result_init(&mut request); - request.result.as_mut().unwrap().address_locality = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().address_locality = Some(value.unwrap_or("").to_string()); }, "result.additional-name" => { request_result_init(&mut request); - request.result.as_mut().unwrap().additional_name.push(value.unwrap_or("").to_string()); + if request.result.as_mut().unwrap().additional_name.is_none() { + request.result.as_mut().unwrap().additional_name = Some(Default::default()); + } + request.result.as_mut().unwrap().additional_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "result.worst-rating" => { request_result_init(&mut request); - request.result.as_mut().unwrap().worst_rating = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().worst_rating = Some(value.unwrap_or("").to_string()); }, "result.duration" => { request_result_init(&mut request); - request.result.as_mut().unwrap().duration = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "result.thumbnail-url" => { request_result_init(&mut request); - request.result.as_mut().unwrap().thumbnail_url = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().thumbnail_url = Some(value.unwrap_or("").to_string()); }, "result.id" => { request_result_init(&mut request); - request.result.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "result.post-office-box-number" => { request_result_init(&mut request); - request.result.as_mut().unwrap().post_office_box_number = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().post_office_box_number = Some(value.unwrap_or("").to_string()); }, "result.caption" => { request_result_init(&mut request); - request.result.as_mut().unwrap().caption = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().caption = Some(value.unwrap_or("").to_string()); }, "result.best-rating" => { request_result_init(&mut request); - request.result.as_mut().unwrap().best_rating = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().best_rating = Some(value.unwrap_or("").to_string()); }, "result.address-country" => { request_result_init(&mut request); - request.result.as_mut().unwrap().address_country = arg_from_str(value.unwrap_or("-0"), err, "result.address-country", "int64"); + request.result.as_mut().unwrap().address_country = Some(arg_from_str(value.unwrap_or("-0"), err, "result.address-country", "int64")); }, "result.width" => { request_result_init(&mut request); - request.result.as_mut().unwrap().width = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().width = Some(value.unwrap_or("").to_string()); }, "result.street-address" => { request_result_init(&mut request); - request.result.as_mut().unwrap().street_address = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().street_address = Some(value.unwrap_or("").to_string()); }, "result.latitude" => { request_result_init(&mut request); - request.result.as_mut().unwrap().latitude = arg_from_str(value.unwrap_or("0.0"), err, "result.latitude", "number"); + request.result.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "result.latitude", "number")); }, "result.embed-url" => { request_result_init(&mut request); - request.result.as_mut().unwrap().embed_url = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().embed_url = Some(value.unwrap_or("").to_string()); }, "result.type" => { request_result_init(&mut request); - request.result.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "result.date-modified" => { request_result_init(&mut request); - request.result.as_mut().unwrap().date_modified = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().date_modified = Some(value.unwrap_or("").to_string()); }, "result.content-size" => { request_result_init(&mut request); - request.result.as_mut().unwrap().content_size = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().content_size = Some(value.unwrap_or("").to_string()); }, "result.content-url" => { request_result_init(&mut request); - request.result.as_mut().unwrap().content_url = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().content_url = Some(value.unwrap_or("").to_string()); }, "result.description" => { request_result_init(&mut request); - request.result.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "result.family-name" => { request_result_init(&mut request); - request.result.as_mut().unwrap().family_name = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().family_name = Some(value.unwrap_or("").to_string()); }, "result.date-created" => { request_result_init(&mut request); - request.result.as_mut().unwrap().date_created = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().date_created = Some(value.unwrap_or("").to_string()); }, "result.postal-code" => { request_result_init(&mut request); - request.result.as_mut().unwrap().postal_code = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().postal_code = Some(value.unwrap_or("").to_string()); }, "result.attendee-count" => { request_result_init(&mut request); - request.result.as_mut().unwrap().attendee_count = arg_from_str(value.unwrap_or("-0"), err, "result.attendee-count", "integer"); + request.result.as_mut().unwrap().attendee_count = Some(arg_from_str(value.unwrap_or("-0"), err, "result.attendee-count", "integer")); }, "result.height" => { request_result_init(&mut request); - request.result.as_mut().unwrap().height = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().height = Some(value.unwrap_or("").to_string()); }, "result.ticker-symbol" => { request_result_init(&mut request); - request.result.as_mut().unwrap().ticker_symbol = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().ticker_symbol = Some(value.unwrap_or("").to_string()); }, "result.player-type" => { request_result_init(&mut request); - request.result.as_mut().unwrap().player_type = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().player_type = Some(value.unwrap_or("").to_string()); }, "result.kind" => { request_result_init(&mut request); - request.result.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "result.name" => { request_result_init(&mut request); - request.result.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "result.url" => { request_result_init(&mut request); - request.result.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "result.gender" => { request_result_init(&mut request); - request.result.as_mut().unwrap().gender = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().gender = Some(value.unwrap_or("").to_string()); }, "result.longitude" => { request_result_init(&mut request); - request.result.as_mut().unwrap().longitude = arg_from_str(value.unwrap_or("0.0"), err, "result.longitude", "number"); + request.result.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "result.longitude", "number")); }, "result.address-region" => { request_result_init(&mut request); - request.result.as_mut().unwrap().address_region = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().address_region = Some(value.unwrap_or("").to_string()); }, "result.rating-value" => { request_result_init(&mut request); - request.result.as_mut().unwrap().rating_value = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().rating_value = Some(value.unwrap_or("").to_string()); }, "result.given-name" => { request_result_init(&mut request); - request.result.as_mut().unwrap().given_name = value.unwrap_or("").to_string(); + request.result.as_mut().unwrap().given_name = Some(value.unwrap_or("").to_string()); }, "type" => { request_result_init(&mut request); @@ -873,8 +885,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -885,7 +896,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.moments().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); @@ -929,8 +940,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -941,7 +951,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.moments().remove(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -972,7 +982,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -983,7 +992,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().get(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1015,8 +1024,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1027,7 +1035,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1068,8 +1076,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1080,7 +1087,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().list_by_activity(&self.opt.arg_activity_id, &self.opt.arg_collection); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1118,8 +1125,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1130,7 +1136,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().search(&self.opt.arg_query); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1171,8 +1177,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1194,7 +1199,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_comments { + } + else if self.opt.cmd_comments { if self.opt.cmd_get { call_result = self._comments_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1202,7 +1208,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_moments { + } + else if self.opt.cmd_moments { if self.opt.cmd_insert { call_result = self._moments_insert(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1212,7 +1219,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_people { + } + else if self.opt.cmd_people { if self.opt.cmd_get { call_result = self._people_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1244,21 +1252,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "plus1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "plus1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "plus1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "plus1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Plus::new(hyper::Client::new(), auth), + hub: api::Plus::new(client, auth), }; match engine._doit(true) { @@ -1278,12 +1302,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/plus1/Cargo.toml b/gen/plus1/Cargo.toml index 747343283c..090fb2841f 100644 --- a/gen/plus1/Cargo.toml +++ b/gen/plus1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-plus1" -version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/+/api/" diff --git a/gen/plus1/README.md b/gen/plus1/README.md index e741afd0e8..22db0ea089 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+20150326*, where *20150326* 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.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*. Everything else about the *plus* *v1* API can be found at the [official documentation site](https://developers.google.com/+/api/). diff --git a/gen/plus1/src/cmn.rs b/gen/plus1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/plus1/src/cmn.rs +++ b/gen/plus1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/plus1/src/lib.rs b/gen/plus1/src/lib.rs index 5daa657f56..e9096dffad 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+20150326*, where *20150326* 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.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*. //! //! Everything else about the *plus* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/api/). @@ -362,11 +362,11 @@ impl<'a, C, A> Plus<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsThumbnails { /// URL of the webpage containing the image. - pub url: String, + pub url: Option<String>, /// Image resource. - pub image: ActivityObjectAttachmentsThumbnailsImage, + pub image: Option<ActivityObjectAttachmentsThumbnailsImage>, /// Potential name of the thumbnail. - pub description: String, + pub description: Option<String>, } impl NestedType for ActivityObjectAttachmentsThumbnails {} @@ -381,10 +381,10 @@ impl Part for ActivityObjectAttachmentsThumbnails {} pub struct ActivityActorName { /// The given name ("first name") of the actor. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The family name ("last name") of the actor. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, } impl NestedType for ActivityActorName {} @@ -405,25 +405,25 @@ impl Part for ActivityActorName {} pub struct ActivityFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of activities. Value: "plus#activityFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this collection of activities, which is a truncated portion of the content. - pub title: String, + pub title: Option<String>, /// The activities in this page of results. - pub items: Vec<Activity>, + pub items: Option<Vec<Activity>>, /// The time at which this collection of activities was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// Link to the next page of activities. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The ID of this collection of activities. Deprecated. - pub id: String, + pub id: Option<String>, /// Link to this activity resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for ActivityFeed {} @@ -441,11 +441,11 @@ pub struct PersonUrls { /// - "website" - URL for this Google+ Page's primary website. /// - "other" - Other URL. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The URL value. - pub value: String, + pub value: Option<String>, /// The label of the URL. - pub label: String, + pub label: Option<String>, } impl NestedType for PersonUrls {} @@ -464,9 +464,9 @@ pub struct PersonEmails { /// - "work" - Work email address. /// - "other" - Other. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The email address. - pub value: String, + pub value: Option<String>, } impl NestedType for PersonEmails {} @@ -481,27 +481,27 @@ impl Part for PersonEmails {} pub struct PersonOrganizations { /// The date that the person joined this organization. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// The date that the person left this organization. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// A short description of the person's role in this organization. Deprecated. - pub description: String, + pub description: Option<String>, /// The person's job title or role within the organization. - pub title: String, + pub title: Option<String>, /// If "true", indicates this organization is the person's primary one, which is typically interpreted as the current one. - pub primary: bool, + pub primary: Option<bool>, /// The location of this organization. Deprecated. - pub location: String, + pub location: Option<String>, /// The department within the organization. Deprecated. - pub department: String, + pub department: Option<String>, /// The type of organization. Possible values include, but are not limited to, the following values: /// - "work" - Work. /// - "school" - School. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The name of the organization. - pub name: String, + pub name: Option<String>, } impl NestedType for PersonOrganizations {} @@ -516,10 +516,10 @@ impl Part for PersonOrganizations {} pub struct ActivityObjectReplies { /// Total number of comments on this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of comments in reply to this activity. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectReplies {} @@ -533,10 +533,10 @@ impl Part for ActivityObjectReplies {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsEmbed { /// URL of the link. - pub url: String, + pub url: Option<String>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for ActivityObjectAttachmentsEmbed {} @@ -551,7 +551,7 @@ impl Part for ActivityObjectAttachmentsEmbed {} pub struct PlusAclentryResource { /// A descriptive name for this entry. Suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The type of entry describing to whom access is granted. Possible values are: /// - "person" - Access to an individual. /// - "circle" - Access to members of a circle. @@ -560,9 +560,9 @@ pub struct PlusAclentryResource { /// - "domain" - Access to members of the person's Google Apps domain. /// - "public" - Access to anyone on the web. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The ID of the entry. For entries of type "person" or "circle", this is the ID of the resource. For other types, this property is not set. - pub id: String, + pub id: Option<String>, } impl Part for PlusAclentryResource {} @@ -575,9 +575,9 @@ impl Part for PlusAclentryResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonPlacesLived { /// If "true", this place of residence is this person's primary residence. - pub primary: bool, + pub primary: Option<bool>, /// A place where this person has lived. For example: "Seattle, WA", "Near Toronto". - pub value: String, + pub value: Option<String>, } impl NestedType for PersonPlacesLived {} @@ -591,14 +591,14 @@ impl Part for PersonPlacesLived {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentObject { /// The HTML-formatted content, suitable for display. - pub content: String, + pub content: Option<String>, /// The object type of this comment. Possible values are: /// - "comment" - A comment in reply to an activity. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, /// The content (text) as provided by the author, stored without any HTML formatting. When creating or updating a comment, this value must be supplied as plain text in the request. #[serde(rename="originalContent")] - pub original_content: String, + pub original_content: Option<String>, } impl NestedType for CommentObject {} @@ -613,144 +613,144 @@ impl Part for CommentObject {} pub struct ItemScope { /// The start date and time of the event (in ISO 8601 date format). #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// The end date and time of the event (in ISO 8601 date format). #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// The text that is the result of the app activity. For example, if a user leaves a review of a restaurant, this might be the text of the review. - pub text: String, + pub text: Option<String>, /// A URL to the image that represents this result. For example, if a user writes a review of a restaurant and attaches a photo of their meal, you might use that photo as the result.image. - pub image: String, + pub image: Option<String>, /// Review rating. #[serde(rename="reviewRating")] - pub review_rating: Option<Box<ItemScope>>, + pub review_rating: Option<Option<Box<ItemScope>>>, /// Date of birth. #[serde(rename="birthDate")] - pub birth_date: String, + pub birth_date: Option<String>, /// The initial date that the result was published. For example, a user writes a comment on a blog, which has a result.dateCreated of when they submit it. If the blog users comment moderation, the result.datePublished value would match the date when the owner approved the message. #[serde(rename="datePublished")] - pub date_published: String, + pub date_published: Option<String>, /// Address locality. #[serde(rename="addressLocality")] - pub address_locality: String, + pub address_locality: Option<String>, /// The duration of the item (movie, audio recording, event, etc.) in ISO 8601 date format. - pub duration: String, + pub duration: Option<String>, /// An additional name for a Person, can be used for a middle name. #[serde(rename="additionalName")] - pub additional_name: Vec<String>, + pub additional_name: Option<Vec<String>>, /// Worst possible rating value that a result might obtain. This property defines the lower bound for the ratingValue. #[serde(rename="worstRating")] - pub worst_rating: String, + pub worst_rating: Option<String>, /// A list of contributors to this result. - pub contributor: Vec<ItemScope>, + pub contributor: Option<Vec<ItemScope>>, /// A URL to a thumbnail image that represents this result. #[serde(rename="thumbnailUrl")] - pub thumbnail_url: String, + pub thumbnail_url: Option<String>, /// An identifier for the object. Your app can choose how to identify objects. The object.id is required if you are writing an action that does not have a corresponding web page or object.url property. - pub id: String, + pub id: Option<String>, /// Post office box number. #[serde(rename="postOfficeBoxNumber")] - pub post_office_box_number: String, + pub post_office_box_number: Option<String>, /// A person attending the event. - pub attendees: Vec<ItemScope>, + pub attendees: Option<Vec<ItemScope>>, /// The person or persons who created this result. In the example of restaurant reviews, this might be the reviewer's name. - pub author: Vec<ItemScope>, + pub author: Option<Vec<ItemScope>>, /// The encoding. - pub associated_media: Vec<ItemScope>, + pub associated_media: Option<Vec<ItemScope>>, /// Best possible rating value that a result might obtain. This property defines the upper bound for the ratingValue. For example, you might have a 5 star rating scale, you would provide 5 as the value for this property. #[serde(rename="bestRating")] - pub best_rating: String, + pub best_rating: Option<String>, /// Address country. #[serde(rename="addressCountry")] - pub address_country: i64, + pub address_country: Option<i64>, /// The width of the media object. - pub width: String, + pub width: Option<String>, /// Street address. #[serde(rename="streetAddress")] - pub street_address: String, + pub street_address: Option<String>, /// The location of the event or organization. - pub location: Option<Box<ItemScope>>, + pub location: Option<Option<Box<ItemScope>>>, /// Latitude. - pub latitude: f64, + pub latitude: Option<f64>, /// From http://schema.org/MusicRecording, the artist that performed this recording. #[serde(rename="byArtist")] - pub by_artist: Option<Box<ItemScope>>, + pub by_artist: Option<Option<Box<ItemScope>>>, /// The schema.org URL that best describes the referenced object and matches the type of moment. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The date the result was last modified such as the date that a review was last edited. #[serde(rename="dateModified")] - pub date_modified: String, + pub date_modified: Option<String>, /// File size in (mega/kilo) bytes. #[serde(rename="contentSize")] - pub content_size: String, + pub content_size: Option<String>, /// Actual bytes of the media object, for example the image file or video file. #[serde(rename="contentUrl")] - pub content_url: String, + pub content_url: Option<String>, /// Family name. This property can be used with givenName instead of the name property. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, /// The string that describes the content of the result. - pub description: String, + pub description: Option<String>, /// Property of http://schema.org/TVEpisode indicating which series the episode belongs to. #[serde(rename="partOfTVSeries")] - pub part_of_tv_series: Option<Box<ItemScope>>, + pub part_of_tv_series: Option<Option<Box<ItemScope>>>, /// The subject matter of the content. - pub about: Option<Box<ItemScope>>, + pub about: Option<Option<Box<ItemScope>>>, /// The date the result was created such as the date that a review was first created. #[serde(rename="dateCreated")] - pub date_created: String, + pub date_created: Option<String>, /// Postal code. #[serde(rename="postalCode")] - pub postal_code: String, + pub postal_code: Option<String>, /// Number of attendees. #[serde(rename="attendeeCount")] - pub attendee_count: i32, + pub attendee_count: Option<i32>, /// From http://schema.org/MusicRecording, which album a song is in. #[serde(rename="inAlbum")] - pub in_album: Option<Box<ItemScope>>, + pub in_album: Option<Option<Box<ItemScope>>>, /// Postal address. - pub address: Option<Box<ItemScope>>, + pub address: Option<Option<Box<ItemScope>>>, /// The height of the media object. - pub height: String, + pub height: Option<String>, /// Geo coordinates. - pub geo: Option<Box<ItemScope>>, + pub geo: Option<Option<Box<ItemScope>>>, /// A URL pointing to a player for a specific video. In general, this is the information in the src element of an embed tag and should not be the same as the content of the loc tag. #[serde(rename="embedUrl")] - pub embed_url: String, + pub embed_url: Option<String>, /// The exchange traded instrument associated with a Corporation object. The tickerSymbol is expressed as an exchange and an instrument name separated by a space character. For the exchange component of the tickerSymbol attribute, we recommend using the controlled vocabulary of Market Identifier Codes (MIC) specified in ISO15022. #[serde(rename="tickerSymbol")] - pub ticker_symbol: String, + pub ticker_symbol: Option<String>, /// The name of the result. In the example of a restaurant review, this might be the summary the user gave their review such as "Great ambiance, but overpriced." - pub name: String, + pub name: Option<String>, /// Identifies this resource as an itemScope. - pub kind: String, + pub kind: Option<String>, /// From http://schema.org/MusicRecording, the audio file. - pub audio: Option<Box<ItemScope>>, + pub audio: Option<Option<Box<ItemScope>>>, /// Player type that is required. For example: Flash or Silverlight. #[serde(rename="playerType")] - pub player_type: String, + pub player_type: Option<String>, /// The main performer or performers of the event-for example, a presenter, musician, or actor. - pub performers: Vec<ItemScope>, + pub performers: Option<Vec<ItemScope>>, /// The URL that points to the result object. For example, a permalink directly to a restaurant reviewer's comment. - pub url: String, + pub url: Option<String>, /// Gender of the person. - pub gender: String, + pub gender: Option<String>, /// Longitude. - pub longitude: f64, + pub longitude: Option<f64>, /// Thumbnail image for an image or video. - pub thumbnail: Option<Box<ItemScope>>, + pub thumbnail: Option<Option<Box<ItemScope>>>, /// Address region. #[serde(rename="addressRegion")] - pub address_region: String, + pub address_region: Option<String>, /// The caption for this object. - pub caption: String, + pub caption: Option<String>, /// Rating value. #[serde(rename="ratingValue")] - pub rating_value: String, + pub rating_value: Option<String>, /// Given name. This property can be used with familyName instead of the name property. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, } impl Part for ItemScope {} @@ -763,14 +763,14 @@ impl Part for ItemScope {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsImage { /// Image URL. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsImage {} @@ -784,9 +784,9 @@ impl Part for ActivityObjectAttachmentsImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentInReplyTo { /// The URL of the activity. - pub url: String, + pub url: Option<String>, /// The ID of the activity. - pub id: String, + pub id: Option<String>, } impl NestedType for CommentInReplyTo {} @@ -808,21 +808,21 @@ impl Part for CommentInReplyTo {} pub struct PeopleFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of people. Value: "plus#peopleFeed". - pub kind: String, + pub kind: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The title of this collection of people. - pub title: String, + pub title: Option<String>, /// The total number of people available in this list. The number of people in a response might be smaller due to paging. This might not be set for all collections. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, /// The people in this page of results. Each item includes the id, displayName, image, and url for the person. To retrieve additional profile data, see the people.get method. - pub items: Vec<Person>, + pub items: Option<Vec<Person>>, /// Link to this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for PeopleFeed {} @@ -835,14 +835,14 @@ impl ResponseResult for PeopleFeed {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentActor { /// A link to the Person resource for this actor. - pub url: String, + pub url: Option<String>, /// The image representation of this actor. - pub image: CommentActorImage, + pub image: Option<CommentActorImage>, /// The name of this actor, suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The ID of the actor. - pub id: String, + pub id: Option<String>, } impl NestedType for CommentActor {} @@ -856,16 +856,16 @@ impl Part for CommentActor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityActor { /// The link to the actor's Google profile. - pub url: String, + pub url: Option<String>, /// The image representation of the actor. - pub image: ActivityActorImage, + pub image: Option<ActivityActorImage>, /// The name of the actor, suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The ID of the actor's Person resource. - pub id: String, + pub id: Option<String>, /// An object representation of the individual components of name. - pub name: ActivityActorName, + pub name: Option<ActivityActorName>, } impl NestedType for ActivityActor {} @@ -879,7 +879,7 @@ impl Part for ActivityActor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityProvider { /// Name of the service provider. - pub title: String, + pub title: Option<String>, } impl NestedType for ActivityProvider {} @@ -893,9 +893,9 @@ impl Part for ActivityProvider {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacePosition { /// The latitude of this position. - pub latitude: f64, + pub latitude: Option<f64>, /// The longitude of this position. - pub longitude: f64, + pub longitude: Option<f64>, } impl NestedType for PlacePosition {} @@ -910,10 +910,10 @@ impl Part for PlacePosition {} pub struct ActivityObjectPlusoners { /// Total number of people who +1'd this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of people who +1'd this activity. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectPlusoners {} @@ -928,10 +928,10 @@ impl Part for ActivityObjectPlusoners {} pub struct PersonCoverCoverInfo { /// The difference between the left position of the cover image and the actual displayed cover image. Only valid for banner layout. #[serde(rename="leftImageOffset")] - pub left_image_offset: i32, + pub left_image_offset: Option<i32>, /// The difference between the top position of the cover image and the actual displayed cover image. Only valid for banner layout. #[serde(rename="topImageOffset")] - pub top_image_offset: i32, + pub top_image_offset: Option<i32>, } impl NestedType for PersonCoverCoverInfo {} @@ -981,7 +981,7 @@ impl ResponseResult for Moment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentActorImage { /// The URL of the actor's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, } impl NestedType for CommentActorImage {} @@ -995,10 +995,10 @@ impl Part for CommentActorImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonImage { /// The URL of the person's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, /// Whether the person's profile photo is the default one #[serde(rename="isDefault")] - pub is_default: bool, + pub is_default: Option<bool>, } impl NestedType for PersonImage {} @@ -1013,7 +1013,7 @@ impl Part for PersonImage {} pub struct CommentPlusoners { /// Total number of people who +1'd this comment. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, } impl NestedType for CommentPlusoners {} @@ -1028,29 +1028,29 @@ impl Part for CommentPlusoners {} pub struct ActivityObjectAttachments { /// The title of the attachment, such as a photo caption or an article title. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// If the attachment is an album, this property is a list of potential additional thumbnails from the album. - pub thumbnails: Vec<ActivityObjectAttachmentsThumbnails>, + pub thumbnails: Option<Vec<ActivityObjectAttachmentsThumbnails>>, /// The full image URL for photo attachments. #[serde(rename="fullImage")] - pub full_image: ActivityObjectAttachmentsFullImage, + pub full_image: Option<ActivityObjectAttachmentsFullImage>, /// The link to the attachment, which should be of type text/html. - pub url: String, + pub url: Option<String>, /// The preview image for photos or videos. - pub image: ActivityObjectAttachmentsImage, + pub image: Option<ActivityObjectAttachmentsImage>, /// If the attachment is an article, this property contains a snippet of text from the article. It can also include descriptions for other types. - pub content: String, + pub content: Option<String>, /// If the attachment is a video, the embeddable link. - pub embed: ActivityObjectAttachmentsEmbed, + pub embed: Option<ActivityObjectAttachmentsEmbed>, /// The ID of the attachment. - pub id: String, + pub id: Option<String>, /// The type of media object. Possible values include, but are not limited to, the following values: /// - "photo" - A photo. /// - "album" - A photo album. /// - "video" - A video. /// - "article" - An article, specified by a link. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, } impl NestedType for ActivityObjectAttachments {} @@ -1064,11 +1064,11 @@ impl Part for ActivityObjectAttachments {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonCoverCoverPhoto { /// The URL of the image. - pub url: String, + pub url: Option<String>, /// The width of the image. - pub width: i32, + pub width: Option<i32>, /// The height of the image. - pub height: i32, + pub height: Option<i32>, } impl NestedType for PersonCoverCoverPhoto {} @@ -1082,14 +1082,14 @@ impl Part for PersonCoverCoverPhoto {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsFullImage { /// URL of the image. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsFullImage {} @@ -1104,13 +1104,13 @@ impl Part for ActivityObjectAttachmentsFullImage {} pub struct PersonCover { /// Extra information about the cover photo. #[serde(rename="coverInfo")] - pub cover_info: PersonCoverCoverInfo, + pub cover_info: Option<PersonCoverCoverInfo>, /// The layout of the cover art. Possible values include, but are not limited to, the following values: /// - "banner" - One large image banner. - pub layout: String, + pub layout: Option<String>, /// The person's primary cover image. #[serde(rename="coverPhoto")] - pub cover_photo: PersonCoverCoverPhoto, + pub cover_photo: Option<PersonCoverCoverPhoto>, } impl NestedType for PersonCover {} @@ -1124,11 +1124,11 @@ impl Part for PersonCover {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Acl { /// The list of access entries. - pub items: Vec<PlusAclentryResource>, + pub items: Option<Vec<PlusAclentryResource>>, /// Identifies this resource as a collection of access controls. Value: "plus#acl". - pub kind: String, + pub kind: Option<String>, /// Description of the access granted, suitable for display. - pub description: String, + pub description: Option<String>, } impl Part for Acl {} @@ -1147,7 +1147,7 @@ impl Part for Acl {} pub struct Person { /// The "bragging rights" line of this person. #[serde(rename="braggingRights")] - pub bragging_rights: String, + pub bragging_rights: Option<String>, /// The person's relationship status. Possible values include, but are not limited to, the following values: /// - "single" - Person is single. /// - "in_a_relationship" - Person is in a relationship. @@ -1159,77 +1159,77 @@ pub struct Person { /// - "in_domestic_partnership" - Person is in a domestic partnership. /// - "in_civil_union" - Person is in a civil union. #[serde(rename="relationshipStatus")] - pub relationship_status: String, + pub relationship_status: Option<String>, /// The representation of the person's profile photo. - pub image: PersonImage, + pub image: Option<PersonImage>, /// The hosted domain name for the user's Google Apps account. For instance, example.com. The plus.profile.emails.read or email scope is needed to get this domain name. - pub domain: String, + pub domain: Option<String>, /// A list of places where this person has lived. #[serde(rename="placesLived")] - pub places_lived: Vec<PersonPlacesLived>, + pub places_lived: Option<Vec<PersonPlacesLived>>, /// The person's date of birth, represented as YYYY-MM-DD. - pub birthday: String, + pub birthday: Option<String>, /// The name of this person, which is suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The nickname of this person. - pub nickname: String, + pub nickname: Option<String>, /// A list of email addresses that this person has, including their Google account email address, and the public verified email addresses on their Google+ profile. The plus.profile.emails.read scope is needed to retrieve these email addresses, or the email scope can be used to retrieve just the Google account email address. - pub emails: Vec<PersonEmails>, + pub emails: Option<Vec<PersonEmails>>, /// The occupation of this person. - pub occupation: String, + pub occupation: Option<String>, /// A list of current or past organizations with which this person is associated. - pub organizations: Vec<PersonOrganizations>, + pub organizations: Option<Vec<PersonOrganizations>>, /// Identifies this resource as a person. Value: "plus#person". - pub kind: String, + pub kind: Option<String>, /// Whether the person or Google+ Page has been verified. - pub verified: bool, + pub verified: Option<bool>, /// An object representation of the individual components of a person's name. - pub name: PersonName, + pub name: Option<PersonName>, /// The user's preferred language for rendering. - pub language: String, + pub language: Option<String>, /// Whether this user has signed up for Google+. #[serde(rename="isPlusUser")] - pub is_plus_user: bool, + pub is_plus_user: Option<bool>, /// The person's skills. - pub skills: String, + pub skills: Option<String>, /// The brief description (tagline) of this person. - pub tagline: String, + pub tagline: Option<String>, /// (this field is not currently used) #[serde(rename="currentLocation")] - pub current_location: String, + pub current_location: Option<String>, /// The cover photo content. - pub cover: PersonCover, + pub cover: Option<PersonCover>, /// The ID of this person. - pub id: String, + pub id: Option<String>, /// The URL of this person's profile. - pub url: String, + pub url: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// If a Google+ Page, the number of people who have +1'd this page. #[serde(rename="plusOneCount")] - pub plus_one_count: i32, + pub plus_one_count: Option<i32>, /// A list of URLs for this person. - pub urls: Vec<PersonUrls>, + pub urls: Option<Vec<PersonUrls>>, /// The person's gender. Possible values include, but are not limited to, the following values: /// - "male" - Male gender. /// - "female" - Female gender. /// - "other" - Other. - pub gender: String, + pub gender: Option<String>, /// The age range of the person. Valid ranges are 17 or younger, 18 to 20, and 21 or older. Age is determined from the user's birthday using Western age reckoning. #[serde(rename="ageRange")] - pub age_range: PersonAgeRange, + pub age_range: Option<PersonAgeRange>, /// For followers who are visible, the number of people who have added this person or page to a circle. #[serde(rename="circledByCount")] - pub circled_by_count: i32, + pub circled_by_count: Option<i32>, /// Type of person within Google+. Possible values include, but are not limited to, the following values: /// - "person" - represents an actual person. /// - "page" - represents a page. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, /// A short biography for this person. #[serde(rename="aboutMe")] - pub about_me: String, + pub about_me: Option<String>, } impl ResponseResult for Person {} @@ -1242,14 +1242,14 @@ impl ResponseResult for Person {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectActor { /// A link to the original actor's Google profile. - pub url: String, + pub url: Option<String>, /// The image representation of the original actor. - pub image: ActivityObjectActorImage, + pub image: Option<ActivityObjectActorImage>, /// The original actor's name, which is suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// ID of the original actor. - pub id: String, + pub id: Option<String>, } impl NestedType for ActivityObjectActor {} @@ -1269,23 +1269,23 @@ impl Part for ActivityObjectActor {} pub struct MomentsFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of moments. Value: "plus#momentsFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this collection of moments. - pub title: String, + pub title: Option<String>, /// The moments in this page of results. - pub items: Vec<Moment>, + pub items: Option<Vec<Moment>>, /// The RFC 339 timestamp for when this collection of moments was last updated. - pub updated: String, + pub updated: Option<String>, /// Link to the next page of moments. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// Link to this page of moments. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for MomentsFeed {} @@ -1304,49 +1304,49 @@ impl ResponseResult for MomentsFeed {} pub struct Activity { /// Name of the place where this activity occurred. #[serde(rename="placeName")] - pub place_name: String, + pub place_name: Option<String>, /// The time at which this activity was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// The object of this activity. - pub object: ActivityObject, + pub object: Option<ActivityObject>, /// This activity's verb, which indicates the action that was performed. Possible values include, but are not limited to, the following values: /// - "post" - Publish content to the stream. /// - "share" - Reshare an activity. - pub verb: String, + pub verb: Option<String>, /// Radius, in meters, of the region where this activity occurred, centered at the latitude and longitude identified in geocode. - pub radius: String, + pub radius: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// Street address where this activity occurred. - pub address: String, + pub address: Option<String>, /// Additional content added by the person who shared this activity, applicable only when resharing an activity. - pub annotation: String, + pub annotation: Option<String>, /// Identifies this resource as an activity. Value: "plus#activity". - pub kind: String, + pub kind: Option<String>, /// Title of this activity. - pub title: String, + pub title: Option<String>, /// The link to this activity. - pub url: String, + pub url: Option<String>, /// ID of the place where this activity occurred. #[serde(rename="placeId")] - pub place_id: String, + pub place_id: Option<String>, /// The person who performed this activity. - pub actor: ActivityActor, + pub actor: Option<ActivityActor>, /// The ID of this activity. - pub id: String, + pub id: Option<String>, /// Identifies who has access to see this activity. - pub access: Acl, + pub access: Option<Acl>, /// Latitude and longitude where this activity occurred. Format is latitude followed by longitude, space separated. - pub geocode: String, + pub geocode: Option<String>, /// The location where this activity occurred. - pub location: Place, + pub location: Option<Place>, /// The service provider that initially published this activity. - pub provider: ActivityProvider, + pub provider: Option<ActivityProvider>, /// If this activity is a crosspost from another system, this property specifies the ID of the original activity. #[serde(rename="crosspostSource")] - pub crosspost_source: String, + pub crosspost_source: Option<String>, /// The time at which this activity was initially published. Formatted as an RFC 3339 timestamp. - pub published: String, + pub published: Option<String>, } impl ResponseResult for Activity {} @@ -1365,22 +1365,22 @@ impl ResponseResult for Activity {} pub struct CommentFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of comments. Value: "plus#commentFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this collection of comments. - pub title: String, + pub title: Option<String>, /// The comments in this page of results. - pub items: Vec<Comment>, + pub items: Option<Vec<Comment>>, /// The time at which this collection of comments was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// Link to the next page of activities. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The ID of this collection of comments. - pub id: String, + pub id: Option<String>, } impl ResponseResult for CommentFeed {} @@ -1394,10 +1394,10 @@ impl ResponseResult for CommentFeed {} pub struct ActivityObjectResharers { /// Total number of people who reshared this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of resharers. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectResharers {} @@ -1411,7 +1411,7 @@ impl Part for ActivityObjectResharers {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityActorImage { /// The URL of the actor's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, } impl NestedType for ActivityActorImage {} @@ -1432,29 +1432,29 @@ impl Part for ActivityActorImage {} pub struct Comment { /// The activity this comment replied to. #[serde(rename="inReplyTo")] - pub in_reply_to: Vec<CommentInReplyTo>, + pub in_reply_to: Option<Vec<CommentInReplyTo>>, /// Identifies this resource as a comment. Value: "plus#comment". - pub kind: String, + pub kind: Option<String>, /// People who +1'd this comment. - pub plusoners: CommentPlusoners, + pub plusoners: Option<CommentPlusoners>, /// The object of this comment. - pub object: CommentObject, + pub object: Option<CommentObject>, /// The time at which this comment was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// The person who posted this comment. - pub actor: CommentActor, + pub actor: Option<CommentActor>, /// This comment's verb, indicating what action was performed. Possible values are: /// - "post" - Publish content to the stream. - pub verb: String, + pub verb: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The time at which this comment was initially published. Formatted as an RFC 3339 timestamp. - pub published: String, + pub published: Option<String>, /// The ID of this comment. - pub id: String, + pub id: Option<String>, /// Link to this comment resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl Resource for Comment {} @@ -1468,7 +1468,7 @@ impl ResponseResult for Comment {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectActorImage { /// A URL that points to a thumbnail photo of the original actor. - pub url: String, + pub url: Option<String>, } impl NestedType for ActivityObjectActorImage {} @@ -1484,11 +1484,11 @@ pub struct PersonAgeRange { /// The age range's upper bound, if any. Possible values include, but are not limited to, the following: /// - "17" - for age 17 /// - "20" - for age 20 - pub max: i32, + pub max: Option<i32>, /// The age range's lower bound, if any. Possible values include, but are not limited to, the following: /// - "21" - for age 21 /// - "18" - for age 18 - pub min: i32, + pub min: Option<i32>, } impl NestedType for PersonAgeRange {} @@ -1503,21 +1503,21 @@ impl Part for PersonAgeRange {} pub struct PersonName { /// The honorific prefixes (such as "Dr." or "Mrs.") for this person. #[serde(rename="honorificPrefix")] - pub honorific_prefix: String, + pub honorific_prefix: Option<String>, /// The given name (first name) of this person. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The middle name of this person. #[serde(rename="middleName")] - pub middle_name: String, + pub middle_name: Option<String>, /// The family name (last name) of this person. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, /// The full name of this person, including middle names, suffixes, etc. - pub formatted: String, + pub formatted: Option<String>, /// The honorific suffixes (such as "Jr.") for this person. #[serde(rename="honorificSuffix")] - pub honorific_suffix: String, + pub honorific_suffix: Option<String>, } impl NestedType for PersonName {} @@ -1531,14 +1531,14 @@ impl Part for PersonName {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsThumbnailsImage { /// Image url. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsThumbnailsImage {} @@ -1552,7 +1552,7 @@ impl Part for ActivityObjectAttachmentsThumbnailsImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlaceAddress { /// The formatted address for display. - pub formatted: String, + pub formatted: Option<String>, } impl NestedType for PlaceAddress {} @@ -1566,29 +1566,29 @@ impl Part for PlaceAddress {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObject { /// The HTML-formatted content, which is suitable for display. - pub content: String, + pub content: Option<String>, /// The media objects attached to this activity. - pub attachments: Vec<ActivityObjectAttachments>, + pub attachments: Option<Vec<ActivityObjectAttachments>>, /// The content (text) as provided by the author, which is stored without any HTML formatting. When creating or updating an activity, this value must be supplied as plain text in the request. #[serde(rename="originalContent")] - pub original_content: String, + pub original_content: Option<String>, /// People who +1'd this activity. - pub plusoners: ActivityObjectPlusoners, + pub plusoners: Option<ActivityObjectPlusoners>, /// If this activity's object is itself another activity, such as when a person reshares an activity, this property specifies the original activity's actor. - pub actor: ActivityObjectActor, + pub actor: Option<ActivityObjectActor>, /// People who reshared this activity. - pub resharers: ActivityObjectResharers, + pub resharers: Option<ActivityObjectResharers>, /// The URL that points to the linked resource. - pub url: String, + pub url: Option<String>, /// Comments in reply to this activity. - pub replies: ActivityObjectReplies, + pub replies: Option<ActivityObjectReplies>, /// The ID of the object. When resharing an activity, this is the ID of the activity that is being reshared. - pub id: String, + pub id: Option<String>, /// The type of the object. Possible values include, but are not limited to, the following values: /// - "note" - Textual content. /// - "activity" - A Google+ activity. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, } impl NestedType for ActivityObject {} @@ -1602,16 +1602,16 @@ impl Part for ActivityObject {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Place { /// The position of the place. - pub position: PlacePosition, + pub position: Option<PlacePosition>, /// Identifies this resource as a place. Value: "plus#place". - pub kind: String, + pub kind: Option<String>, /// The display name of the place. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The id of the place. - pub id: String, + pub id: Option<String>, /// The physical address of the place. - pub address: PlaceAddress, + pub address: Option<PlaceAddress>, } impl Part for Place {} @@ -2057,7 +2057,7 @@ impl<'a, C, A> PeopleMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Moment = Default::default(); +/// let mut req = Moment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2156,16 +2156,20 @@ impl<'a, C, A> MomentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2438,16 +2442,20 @@ impl<'a, C, A> MomentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2705,16 +2713,20 @@ impl<'a, C, A> MomentRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2921,16 +2933,20 @@ impl<'a, C, A> ActivitySearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3179,16 +3195,20 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3421,16 +3441,20 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3690,16 +3714,20 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3941,16 +3969,20 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4162,16 +4194,20 @@ impl<'a, C, A> PeopleSearchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4425,16 +4461,20 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4696,16 +4736,20 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4957,16 +5001,20 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/plusdomains1-cli/Cargo.toml b/gen/plusdomains1-cli/Cargo.toml index aee1fa97d4..79b9b05b21 100644 --- a/gen/plusdomains1-cli/Cargo.toml +++ b/gen/plusdomains1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-plusdomains1-cli" -version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/+/domains/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/plusdomains1-cli/mkdocs.yml b/gen/plusdomains1-cli/mkdocs.yml index a811f45280..b545e49080 100644 --- a/gen/plusdomains1-cli/mkdocs.yml +++ b/gen/plusdomains1-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: plusDomains v0.0.1+20150326 +site_name: plusDomains v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/plusdomains1-cli/src/cmn.rs +++ b/gen/plusdomains1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/plusdomains1-cli/src/main.rs b/gen/plusdomains1-cli/src/main.rs index 0547bf7c54..dcb7112879 100644 --- a/gen/plusdomains1-cli/src/main.rs +++ b/gen/plusdomains1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -51,6 +52,12 @@ Configuration: 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. "); mod cmn; @@ -74,7 +81,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().get(&self.opt.arg_activity_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -106,8 +113,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -116,10 +122,10 @@ impl Engine { fn _activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Activity = Default::default(); + 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); + 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")); @@ -142,9 +148,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -154,24 +161,94 @@ impl Engine { } } + fn request_actor_image_init(request: &mut api::Activity) { + request_actor_init(request); + if request.actor.as_mut().unwrap().image.is_none() { + request.actor.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_actor_init(request: &mut api::Activity) { if request.actor.is_none() { request.actor = Some(Default::default()); } } + fn request_actor_name_init(request: &mut api::Activity) { + request_actor_init(request); + if request.actor.as_mut().unwrap().name.is_none() { + request.actor.as_mut().unwrap().name = Some(Default::default()); + } + } + + fn request_location_address_init(request: &mut api::Activity) { + request_location_init(request); + if request.location.as_mut().unwrap().address.is_none() { + request.location.as_mut().unwrap().address = Some(Default::default()); + } + } + fn request_location_init(request: &mut api::Activity) { if request.location.is_none() { request.location = Some(Default::default()); } } + fn request_location_position_init(request: &mut api::Activity) { + request_location_init(request); + if request.location.as_mut().unwrap().position.is_none() { + request.location.as_mut().unwrap().position = Some(Default::default()); + } + } + + fn request_object_actor_image_init(request: &mut api::Activity) { + request_object_actor_init(request); + if request.object.as_mut().unwrap().actor.as_mut().unwrap().image.is_none() { + request.object.as_mut().unwrap().actor.as_mut().unwrap().image = Some(Default::default()); + } + } + + fn request_object_actor_init(request: &mut api::Activity) { + request_object_init(request); + if request.object.as_mut().unwrap().actor.is_none() { + request.object.as_mut().unwrap().actor = Some(Default::default()); + } + } + fn request_object_init(request: &mut api::Activity) { if request.object.is_none() { request.object = Some(Default::default()); } } + fn request_object_plusoners_init(request: &mut api::Activity) { + request_object_init(request); + if request.object.as_mut().unwrap().plusoners.is_none() { + request.object.as_mut().unwrap().plusoners = Some(Default::default()); + } + } + + fn request_object_replies_init(request: &mut api::Activity) { + request_object_init(request); + if request.object.as_mut().unwrap().replies.is_none() { + request.object.as_mut().unwrap().replies = Some(Default::default()); + } + } + + fn request_object_resharers_init(request: &mut api::Activity) { + request_object_init(request); + if request.object.as_mut().unwrap().resharers.is_none() { + request.object.as_mut().unwrap().resharers = Some(Default::default()); + } + } + + fn request_object_status_for_viewer_init(request: &mut api::Activity) { + request_object_init(request); + if request.object.as_mut().unwrap().status_for_viewer.is_none() { + request.object.as_mut().unwrap().status_for_viewer = Some(Default::default()); + } + } + fn request_provider_init(request: &mut api::Activity) { if request.provider.is_none() { request.provider = Some(Default::default()); @@ -187,7 +264,7 @@ impl Engine { }, "provider.title" => { request_provider_init(&mut request); - request.provider.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.provider.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "title" => { request_provider_init(&mut request); @@ -202,84 +279,84 @@ impl Engine { request.geocode = Some(value.unwrap_or("").to_string()); }, "object.resharers.total-items" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().resharers.total_items = arg_from_str(value.unwrap_or("-0"), err, "object.resharers.total-items", "integer"); + request_object_resharers_init(&mut request); + request.object.as_mut().unwrap().resharers.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "object.resharers.total-items", "integer")); }, "object.resharers.self-link" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().resharers.self_link = value.unwrap_or("").to_string(); + request_object_resharers_init(&mut request); + request.object.as_mut().unwrap().resharers.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "object.original-content" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().original_content = value.unwrap_or("").to_string(); + request_object_resharers_init(&mut request); + request.object.as_mut().unwrap().original_content = Some(value.unwrap_or("").to_string()); }, "object.plusoners.total-items" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().plusoners.total_items = arg_from_str(value.unwrap_or("-0"), err, "object.plusoners.total-items", "integer"); + request_object_plusoners_init(&mut request); + request.object.as_mut().unwrap().plusoners.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "object.plusoners.total-items", "integer")); }, "object.plusoners.self-link" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().plusoners.self_link = value.unwrap_or("").to_string(); + request_object_plusoners_init(&mut request); + request.object.as_mut().unwrap().plusoners.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "object.actor.url" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().actor.url = value.unwrap_or("").to_string(); + request_object_actor_init(&mut request); + request.object.as_mut().unwrap().actor.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "object.actor.image.url" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().actor.image.url = value.unwrap_or("").to_string(); + request_object_actor_image_init(&mut request); + request.object.as_mut().unwrap().actor.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "object.actor.display-name" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().actor.display_name = value.unwrap_or("").to_string(); + request_object_actor_image_init(&mut request); + request.object.as_mut().unwrap().actor.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "object.actor.id" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().actor.id = value.unwrap_or("").to_string(); + request_object_actor_image_init(&mut request); + request.object.as_mut().unwrap().actor.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "object.content" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().content = value.unwrap_or("").to_string(); + request_object_actor_init(&mut request); + request.object.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "object.url" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request_object_actor_init(&mut request); + request.object.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "object.status-for-viewer.can-plusone" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().status_for_viewer.can_plusone = arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-plusone", "boolean"); + request_object_status_for_viewer_init(&mut request); + request.object.as_mut().unwrap().status_for_viewer.as_mut().unwrap().can_plusone = Some(arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-plusone", "boolean")); }, "object.status-for-viewer.can-update" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().status_for_viewer.can_update = arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-update", "boolean"); + request_object_status_for_viewer_init(&mut request); + request.object.as_mut().unwrap().status_for_viewer.as_mut().unwrap().can_update = Some(arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-update", "boolean")); }, "object.status-for-viewer.is-plus-oned" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().status_for_viewer.is_plus_oned = arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.is-plus-oned", "boolean"); + request_object_status_for_viewer_init(&mut request); + request.object.as_mut().unwrap().status_for_viewer.as_mut().unwrap().is_plus_oned = Some(arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.is-plus-oned", "boolean")); }, "object.status-for-viewer.resharing-disabled" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().status_for_viewer.resharing_disabled = arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.resharing-disabled", "boolean"); + request_object_status_for_viewer_init(&mut request); + request.object.as_mut().unwrap().status_for_viewer.as_mut().unwrap().resharing_disabled = Some(arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.resharing-disabled", "boolean")); }, "object.status-for-viewer.can-comment" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().status_for_viewer.can_comment = arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-comment", "boolean"); + request_object_status_for_viewer_init(&mut request); + request.object.as_mut().unwrap().status_for_viewer.as_mut().unwrap().can_comment = Some(arg_from_str(value.unwrap_or("false"), err, "object.status-for-viewer.can-comment", "boolean")); }, "object.replies.total-items" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().replies.total_items = arg_from_str(value.unwrap_or("-0"), err, "object.replies.total-items", "integer"); + request_object_replies_init(&mut request); + request.object.as_mut().unwrap().replies.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "object.replies.total-items", "integer")); }, "object.replies.self-link" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().replies.self_link = value.unwrap_or("").to_string(); + request_object_replies_init(&mut request); + request.object.as_mut().unwrap().replies.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "object.id" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_object_replies_init(&mut request); + request.object.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "object.object-type" => { - request_object_init(&mut request); - request.object.as_mut().unwrap().object_type = value.unwrap_or("").to_string(); + request_object_replies_init(&mut request); + request.object.as_mut().unwrap().object_type = Some(value.unwrap_or("").to_string()); }, "kind" => { request_object_init(&mut request); @@ -287,27 +364,27 @@ impl Engine { }, "actor.url" => { request_actor_init(&mut request); - request.actor.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.actor.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "actor.image.url" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "actor.display-name" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "actor.id" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "actor.name.given-name" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().name.given_name = value.unwrap_or("").to_string(); + request_actor_name_init(&mut request); + request.actor.as_mut().unwrap().name.as_mut().unwrap().given_name = Some(value.unwrap_or("").to_string()); }, "actor.name.family-name" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().name.family_name = value.unwrap_or("").to_string(); + request_actor_name_init(&mut request); + request.actor.as_mut().unwrap().name.as_mut().unwrap().family_name = Some(value.unwrap_or("").to_string()); }, "place-id" => { request_actor_init(&mut request); @@ -315,15 +392,15 @@ impl Engine { }, "access.kind" => { request_access_init(&mut request); - request.access.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.access.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "access.description" => { request_access_init(&mut request); - request.access.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.access.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "access.domain-restricted" => { request_access_init(&mut request); - request.access.as_mut().unwrap().domain_restricted = arg_from_str(value.unwrap_or("false"), err, "access.domain-restricted", "boolean"); + request.access.as_mut().unwrap().domain_restricted = Some(arg_from_str(value.unwrap_or("false"), err, "access.domain-restricted", "boolean")); }, "etag" => { request_access_init(&mut request); @@ -334,28 +411,28 @@ impl Engine { request.radius = Some(value.unwrap_or("").to_string()); }, "location.position.latitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().position.latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.position.latitude", "number"); + request_location_position_init(&mut request); + request.location.as_mut().unwrap().position.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.position.latitude", "number")); }, "location.position.longitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().position.longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.position.longitude", "number"); + request_location_position_init(&mut request); + request.location.as_mut().unwrap().position.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.position.longitude", "number")); }, "location.kind" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_location_position_init(&mut request); + request.location.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "location.display-name" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_location_position_init(&mut request); + request.location.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "location.id" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_location_position_init(&mut request); + request.location.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "location.address.formatted" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().address.formatted = value.unwrap_or("").to_string(); + request_location_address_init(&mut request); + request.location.as_mut().unwrap().address.as_mut().unwrap().formatted = Some(value.unwrap_or("").to_string()); }, "verb" => { request_location_init(&mut request); @@ -398,8 +475,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -410,7 +486,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -448,8 +524,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -460,7 +535,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.audiences().list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -498,8 +573,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -510,7 +584,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.circles().add_people(&self.opt.arg_circle_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-id" => { call = call.add_user_id(value.unwrap_or("")); @@ -548,8 +622,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -560,7 +633,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.circles().get(&self.opt.arg_circle_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -592,8 +665,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -602,10 +674,10 @@ impl Engine { fn _circles_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Circle = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -625,9 +697,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -649,7 +722,7 @@ impl Engine { }, "people.total-items" => { request_people_init(&mut request); - request.people.as_mut().unwrap().total_items = arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer"); + request.people.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer")); }, "etag" => { request_people_init(&mut request); @@ -680,8 +753,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -692,7 +764,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.circles().list(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -730,8 +802,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -740,10 +811,10 @@ impl Engine { fn _circles_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Circle = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -763,9 +834,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -787,7 +859,7 @@ impl Engine { }, "people.total-items" => { request_people_init(&mut request); - request.people.as_mut().unwrap().total_items = arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer"); + request.people.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer")); }, "etag" => { request_people_init(&mut request); @@ -818,8 +890,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -830,7 +901,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.circles().remove(&self.opt.arg_circle_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -861,7 +932,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -872,7 +942,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.circles().remove_people(&self.opt.arg_circle_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "user-id" => { call = call.add_user_id(value.unwrap_or("")); @@ -909,7 +979,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -918,10 +987,10 @@ impl Engine { fn _circles_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Circle = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -941,9 +1010,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -965,7 +1035,7 @@ impl Engine { }, "people.total-items" => { request_people_init(&mut request); - request.people.as_mut().unwrap().total_items = arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer"); + request.people.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "people.total-items", "integer")); }, "etag" => { request_people_init(&mut request); @@ -996,8 +1066,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1008,7 +1077,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.comments().get(&self.opt.arg_comment_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1040,8 +1109,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1050,10 +1118,10 @@ impl Engine { fn _comments_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Comment = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1073,12 +1141,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_actor_image_init(request: &mut api::Comment) { + request_actor_init(request); + if request.actor.as_mut().unwrap().image.is_none() { + request.actor.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_actor_init(request: &mut api::Comment) { if request.actor.is_none() { request.actor = Some(Default::default()); @@ -1103,19 +1179,19 @@ impl Engine { }, "plusoners.total-items" => { request_plusoners_init(&mut request); - request.plusoners.as_mut().unwrap().total_items = arg_from_str(value.unwrap_or("-0"), err, "plusoners.total-items", "integer"); + request.plusoners.as_mut().unwrap().total_items = Some(arg_from_str(value.unwrap_or("-0"), err, "plusoners.total-items", "integer")); }, "object.content" => { request_object_init(&mut request); - request.object.as_mut().unwrap().content = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "object.original-content" => { request_object_init(&mut request); - request.object.as_mut().unwrap().original_content = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().original_content = Some(value.unwrap_or("").to_string()); }, "object.object-type" => { request_object_init(&mut request); - request.object.as_mut().unwrap().object_type = value.unwrap_or("").to_string(); + request.object.as_mut().unwrap().object_type = Some(value.unwrap_or("").to_string()); }, "updated" => { request_object_init(&mut request); @@ -1123,19 +1199,19 @@ impl Engine { }, "actor.url" => { request_actor_init(&mut request); - request.actor.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.actor.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "actor.image.url" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "actor.display-name" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "actor.id" => { - request_actor_init(&mut request); - request.actor.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_actor_image_init(&mut request); + request.actor.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "verb" => { request_actor_init(&mut request); @@ -1174,8 +1250,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1186,7 +1261,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.comments().list(&self.opt.arg_activity_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sort-order" => { call = call.sort_order(value.unwrap_or("")); @@ -1227,8 +1302,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1237,10 +1311,10 @@ impl Engine { fn _media_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Media = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1260,12 +1334,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_author_image_init(request: &mut api::Media) { + request_author_init(request); + if request.author.as_mut().unwrap().image.is_none() { + request.author.as_mut().unwrap().image = Some(Default::default()); + } + } + fn request_author_init(request: &mut api::Media) { if request.author.is_none() { request.author = Some(Default::default()); @@ -1287,23 +1369,23 @@ impl Engine { }, "exif.time" => { request_exif_init(&mut request); - request.exif.as_mut().unwrap().time = value.unwrap_or("").to_string(); + request.exif.as_mut().unwrap().time = Some(value.unwrap_or("").to_string()); }, "author.url" => { request_author_init(&mut request); - request.author.as_mut().unwrap().url = value.unwrap_or("").to_string(); + request.author.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.image.url" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().image.url = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().image.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "author.display-name" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().display_name = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().display_name = Some(value.unwrap_or("").to_string()); }, "author.id" => { - request_author_init(&mut request); - request.author.as_mut().unwrap().id = value.unwrap_or("").to_string(); + request_author_image_init(&mut request); + request.author.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "url" => { request_author_init(&mut request); @@ -1384,8 +1466,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1396,7 +1477,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().get(&self.opt.arg_user_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1428,8 +1509,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1440,7 +1520,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().list(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1481,8 +1561,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1493,7 +1572,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().list_by_activity(&self.opt.arg_activity_id, &self.opt.arg_collection); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1531,8 +1610,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1543,7 +1621,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.people().list_by_circle(&self.opt.arg_circle_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1581,8 +1659,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1604,13 +1681,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_audiences { + } + else if self.opt.cmd_audiences { if self.opt.cmd_list { call_result = self._audiences_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_circles { + } + else if self.opt.cmd_circles { if self.opt.cmd_add_people { call_result = self._circles_add_people(dry_run, &mut err); } else if self.opt.cmd_get { @@ -1630,7 +1709,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_comments { + } + else if self.opt.cmd_comments { if self.opt.cmd_get { call_result = self._comments_get(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -1640,13 +1720,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_media { + } + else if self.opt.cmd_media { if self.opt.cmd_insert { call_result = self._media_insert(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_people { + } + else if self.opt.cmd_people { if self.opt.cmd_get { call_result = self._people_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -1678,21 +1760,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "plusdomains1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "plusdomains1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "plusdomains1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "plusdomains1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::PlusDomains::new(hyper::Client::new(), auth), + hub: api::PlusDomains::new(client, auth), }; match engine._doit(true) { @@ -1712,12 +1810,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/plusdomains1/Cargo.toml b/gen/plusdomains1/Cargo.toml index f44d911bb4..a4b0052e03 100644 --- a/gen/plusdomains1/Cargo.toml +++ b/gen/plusdomains1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-plusdomains1" -version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/+/domains/" diff --git a/gen/plusdomains1/README.md b/gen/plusdomains1/README.md index 52797d4c05..1073cf3a38 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+20150326*, where *20150326* 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.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*. Everything else about the *plusDomains* *v1* API can be found at the [official documentation site](https://developers.google.com/+/domains/). diff --git a/gen/plusdomains1/src/cmn.rs b/gen/plusdomains1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/plusdomains1/src/cmn.rs +++ b/gen/plusdomains1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/plusdomains1/src/lib.rs b/gen/plusdomains1/src/lib.rs index 5290363f1d..f8a1b1176c 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+20150326*, where *20150326* 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.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*. //! //! Everything else about the *plusDomains* *v1* API can be found at the //! [official documentation site](https://developers.google.com/+/domains/). @@ -403,11 +403,11 @@ impl<'a, C, A> PlusDomains<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsThumbnails { /// URL of the webpage containing the image. - pub url: String, + pub url: Option<String>, /// Image resource. - pub image: ActivityObjectAttachmentsThumbnailsImage, + pub image: Option<ActivityObjectAttachmentsThumbnailsImage>, /// Potential name of the thumbnail. - pub description: String, + pub description: Option<String>, } impl NestedType for ActivityObjectAttachmentsThumbnails {} @@ -421,14 +421,14 @@ impl Part for ActivityObjectAttachmentsThumbnails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Videostream { /// URL of the video stream. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the video resource. - pub width: i32, + pub width: Option<i32>, /// MIME type of the video stream. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the video resource. - pub height: i32, + pub height: Option<i32>, } impl Part for Videostream {} @@ -447,25 +447,25 @@ impl Part for Videostream {} pub struct ActivityFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of activities. Value: "plus#activityFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this collection of activities, which is a truncated portion of the content. - pub title: String, + pub title: Option<String>, /// The activities in this page of results. - pub items: Vec<Activity>, + pub items: Option<Vec<Activity>>, /// The time at which this collection of activities was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// Link to the next page of activities. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The ID of this collection of activities. Deprecated. - pub id: String, + pub id: Option<String>, /// Link to this activity resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for ActivityFeed {} @@ -478,7 +478,7 @@ impl ResponseResult for ActivityFeed {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediaExif { /// The time the media was captured. Formatted as an RFC 3339 timestamp. - pub time: String, + pub time: Option<String>, } impl NestedType for MediaExif {} @@ -497,9 +497,9 @@ pub struct PersonEmails { /// - "work" - Work email address. /// - "other" - Other. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The email address. - pub value: String, + pub value: Option<String>, } impl NestedType for PersonEmails {} @@ -578,27 +578,27 @@ impl ResponseResult for Media {} pub struct PersonOrganizations { /// The date that the person joined this organization. #[serde(rename="startDate")] - pub start_date: String, + pub start_date: Option<String>, /// The date that the person left this organization. #[serde(rename="endDate")] - pub end_date: String, + pub end_date: Option<String>, /// A short description of the person's role in this organization. Deprecated. - pub description: String, + pub description: Option<String>, /// The person's job title or role within the organization. - pub title: String, + pub title: Option<String>, /// If "true", indicates this organization is the person's primary one, which is typically interpreted as the current one. - pub primary: bool, + pub primary: Option<bool>, /// The location of this organization. Deprecated. - pub location: String, + pub location: Option<String>, /// The department within the organization. Deprecated. - pub department: String, + pub department: Option<String>, /// The type of organization. Possible values include, but are not limited to, the following values: /// - "work" - Work. /// - "school" - School. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The name of the organization. - pub name: String, + pub name: Option<String>, } impl NestedType for PersonOrganizations {} @@ -613,10 +613,10 @@ impl Part for PersonOrganizations {} pub struct ActivityObjectReplies { /// Total number of comments on this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of comments in reply to this activity. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectReplies {} @@ -631,10 +631,10 @@ impl Part for ActivityObjectReplies {} pub struct ActivityActorName { /// The given name ("first name") of the actor. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The family name ("last name") of the actor. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, } impl NestedType for ActivityActorName {} @@ -648,14 +648,14 @@ impl Part for ActivityActorName {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediaAuthor { /// A link to the author's Google profile. - pub url: String, + pub url: Option<String>, /// The author's Google profile image. - pub image: MediaAuthorImage, + pub image: Option<MediaAuthorImage>, /// The author's name. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// ID of the author. - pub id: String, + pub id: Option<String>, } impl NestedType for MediaAuthor {} @@ -669,7 +669,7 @@ impl Part for MediaAuthor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlaceAddress { /// The formatted address for display. - pub formatted: String, + pub formatted: Option<String>, } impl NestedType for PlaceAddress {} @@ -683,7 +683,7 @@ impl Part for PlaceAddress {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectActorImage { /// A URL that points to a thumbnail photo of the original actor. - pub url: String, + pub url: Option<String>, } impl NestedType for ActivityObjectActorImage {} @@ -697,9 +697,9 @@ impl Part for ActivityObjectActorImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonPlacesLived { /// If "true", this place of residence is this person's primary residence. - pub primary: bool, + pub primary: Option<bool>, /// A place where this person has lived. For example: "Seattle, WA", "Near Toronto". - pub value: String, + pub value: Option<String>, } impl NestedType for PersonPlacesLived {} @@ -713,14 +713,14 @@ impl Part for PersonPlacesLived {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentObject { /// The HTML-formatted content, suitable for display. - pub content: String, + pub content: Option<String>, /// The object type of this comment. Possible values are: /// - "comment" - A comment in reply to an activity. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, /// The content (text) as provided by the author, stored without any HTML formatting. When creating or updating a comment, this value must be supplied as plain text in the request. #[serde(rename="originalContent")] - pub original_content: String, + pub original_content: Option<String>, } impl NestedType for CommentObject {} @@ -735,19 +735,19 @@ impl Part for CommentObject {} pub struct ActivityObjectStatusForViewer { /// Whether the viewer can +1 the activity. #[serde(rename="canPlusone")] - pub can_plusone: bool, + pub can_plusone: Option<bool>, /// Whether the viewer can edit or delete the activity. #[serde(rename="canUpdate")] - pub can_update: bool, + pub can_update: Option<bool>, /// Whether the viewer has +1'd the activity. #[serde(rename="isPlusOned")] - pub is_plus_oned: bool, + pub is_plus_oned: Option<bool>, /// Whether reshares are disabled for the activity. #[serde(rename="resharingDisabled")] - pub resharing_disabled: bool, + pub resharing_disabled: Option<bool>, /// Whether the viewer can comment on the activity. #[serde(rename="canComment")] - pub can_comment: bool, + pub can_comment: Option<bool>, } impl NestedType for ActivityObjectStatusForViewer {} @@ -761,14 +761,14 @@ impl Part for ActivityObjectStatusForViewer {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsImage { /// Image URL. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsImage {} @@ -823,9 +823,9 @@ impl ResponseResult for Circle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentInReplyTo { /// The URL of the activity. - pub url: String, + pub url: Option<String>, /// The ID of the activity. - pub id: String, + pub id: Option<String>, } impl NestedType for CommentInReplyTo {} @@ -847,21 +847,21 @@ impl Part for CommentInReplyTo {} pub struct PeopleFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of people. Value: "plus#peopleFeed". - pub kind: String, + pub kind: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The title of this collection of people. - pub title: String, + pub title: Option<String>, /// The total number of people available in this list. The number of people in a response might be smaller due to paging. This might not be set for all collections. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, /// The people in this page of results. Each item includes the id, displayName, image, and url for the person. To retrieve additional profile data, see the people.get method. - pub items: Vec<Person>, + pub items: Option<Vec<Person>>, /// Link to this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for PeopleFeed {} @@ -874,14 +874,14 @@ impl ResponseResult for PeopleFeed {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentActor { /// A link to the Person resource for this actor. - pub url: String, + pub url: Option<String>, /// The image representation of this actor. - pub image: CommentActorImage, + pub image: Option<CommentActorImage>, /// The name of this actor, suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The ID of the actor. - pub id: String, + pub id: Option<String>, } impl NestedType for CommentActor {} @@ -896,10 +896,10 @@ impl Part for CommentActor {} pub struct PersonCoverCoverInfo { /// The difference between the left position of the cover image and the actual displayed cover image. Only valid for banner layout. #[serde(rename="leftImageOffset")] - pub left_image_offset: i32, + pub left_image_offset: Option<i32>, /// The difference between the top position of the cover image and the actual displayed cover image. Only valid for banner layout. #[serde(rename="topImageOffset")] - pub top_image_offset: i32, + pub top_image_offset: Option<i32>, } impl NestedType for PersonCoverCoverInfo {} @@ -918,11 +918,11 @@ pub struct PersonUrls { /// - "website" - URL for this Google+ Page's primary website. /// - "other" - Other URL. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The URL value. - pub value: String, + pub value: Option<String>, /// The label of the URL. - pub label: String, + pub label: Option<String>, } impl NestedType for PersonUrls {} @@ -936,7 +936,7 @@ impl Part for PersonUrls {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityProvider { /// Name of the service provider. - pub title: String, + pub title: Option<String>, } impl NestedType for ActivityProvider {} @@ -950,9 +950,9 @@ impl Part for ActivityProvider {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacePosition { /// The latitude of this position. - pub latitude: f64, + pub latitude: Option<f64>, /// The longitude of this position. - pub longitude: f64, + pub longitude: Option<f64>, } impl NestedType for PlacePosition {} @@ -967,10 +967,10 @@ impl Part for PlacePosition {} pub struct ActivityObjectPlusoners { /// Total number of people who +1'd this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of people who +1'd this activity. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectPlusoners {} @@ -984,7 +984,7 @@ impl Part for ActivityObjectPlusoners {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediaAuthorImage { /// The URL of the author's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, } impl NestedType for MediaAuthorImage {} @@ -998,7 +998,7 @@ impl Part for MediaAuthorImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CommentActorImage { /// The URL of the actor's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, } impl NestedType for CommentActorImage {} @@ -1012,10 +1012,10 @@ impl Part for CommentActorImage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonImage { /// The URL of the person's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, /// Whether the person's profile photo is the default one #[serde(rename="isDefault")] - pub is_default: bool, + pub is_default: Option<bool>, } impl NestedType for PersonImage {} @@ -1030,7 +1030,7 @@ impl Part for PersonImage {} pub struct CommentPlusoners { /// Total number of people who +1'd this comment. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, } impl NestedType for CommentPlusoners {} @@ -1050,16 +1050,16 @@ impl Part for CommentPlusoners {} pub struct AudiencesFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The audiences in this result. - pub items: Vec<Audience>, + pub items: Option<Vec<Audience>>, /// Identifies this resource as a collection of audiences. Value: "plus#audienceFeed". - pub kind: String, + pub kind: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The total number of ACL entries. The number of entries in this response may be smaller due to paging. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for AudiencesFeed {} @@ -1073,32 +1073,32 @@ impl ResponseResult for AudiencesFeed {} pub struct ActivityObjectAttachments { /// When previewing, these are the optional thumbnails for the post. When posting an article, choose one by setting the attachment.image.url property. If you don't choose one, one will be chosen for you. #[serde(rename="previewThumbnails")] - pub preview_thumbnails: Vec<ActivityObjectAttachmentsPreviewThumbnails>, + pub preview_thumbnails: Option<Vec<ActivityObjectAttachmentsPreviewThumbnails>>, /// The title of the attachment, such as a photo caption or an article title. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// If the attachment is an album, this property is a list of potential additional thumbnails from the album. - pub thumbnails: Vec<ActivityObjectAttachmentsThumbnails>, + pub thumbnails: Option<Vec<ActivityObjectAttachmentsThumbnails>>, /// The full image URL for photo attachments. #[serde(rename="fullImage")] - pub full_image: ActivityObjectAttachmentsFullImage, + pub full_image: Option<ActivityObjectAttachmentsFullImage>, /// The link to the attachment, which should be of type text/html. - pub url: String, + pub url: Option<String>, /// The preview image for photos or videos. - pub image: ActivityObjectAttachmentsImage, + pub image: Option<ActivityObjectAttachmentsImage>, /// If the attachment is an article, this property contains a snippet of text from the article. It can also include descriptions for other types. - pub content: String, + pub content: Option<String>, /// If the attachment is a video, the embeddable link. - pub embed: ActivityObjectAttachmentsEmbed, + pub embed: Option<ActivityObjectAttachmentsEmbed>, /// The ID of the attachment. - pub id: String, + pub id: Option<String>, /// The type of media object. Possible values include, but are not limited to, the following values: /// - "photo" - A photo. /// - "album" - A photo album. /// - "video" - A video. /// - "article" - An article, specified by a link. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, } impl NestedType for ActivityObjectAttachments {} @@ -1112,11 +1112,11 @@ impl Part for ActivityObjectAttachments {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PersonCoverCoverPhoto { /// The URL of the image. - pub url: String, + pub url: Option<String>, /// The width of the image. - pub width: i32, + pub width: Option<i32>, /// The height of the image. - pub height: i32, + pub height: Option<i32>, } impl NestedType for PersonCoverCoverPhoto {} @@ -1130,14 +1130,14 @@ impl Part for PersonCoverCoverPhoto {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectActor { /// A link to the original actor's Google profile. - pub url: String, + pub url: Option<String>, /// The image representation of the original actor. - pub image: ActivityObjectActorImage, + pub image: Option<ActivityObjectActorImage>, /// The original actor's name, which is suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// ID of the original actor. - pub id: String, + pub id: Option<String>, } impl NestedType for ActivityObjectActor {} @@ -1151,14 +1151,14 @@ impl Part for ActivityObjectActor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsFullImage { /// URL of the image. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsFullImage {} @@ -1173,13 +1173,13 @@ impl Part for ActivityObjectAttachmentsFullImage {} pub struct PersonCover { /// Extra information about the cover photo. #[serde(rename="coverInfo")] - pub cover_info: PersonCoverCoverInfo, + pub cover_info: Option<PersonCoverCoverInfo>, /// The layout of the cover art. Possible values include, but are not limited to, the following values: /// - "banner" - One large image banner. - pub layout: String, + pub layout: Option<String>, /// The person's primary cover image. #[serde(rename="coverPhoto")] - pub cover_photo: PersonCoverCoverPhoto, + pub cover_photo: Option<PersonCoverCoverPhoto>, } impl NestedType for PersonCover {} @@ -1193,14 +1193,14 @@ impl Part for PersonCover {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Acl { /// The list of access entries. - pub items: Vec<PlusDomainsAclentryResource>, + pub items: Option<Vec<PlusDomainsAclentryResource>>, /// Identifies this resource as a collection of access controls. Value: "plus#acl". - pub kind: String, + pub kind: Option<String>, /// Description of the access granted, suitable for display. - pub description: String, + pub description: Option<String>, /// Whether access is restricted to the domain. #[serde(rename="domainRestricted")] - pub domain_restricted: bool, + pub domain_restricted: Option<bool>, } impl Part for Acl {} @@ -1219,7 +1219,7 @@ impl Part for Acl {} pub struct Person { /// The "bragging rights" line of this person. #[serde(rename="braggingRights")] - pub bragging_rights: String, + pub bragging_rights: Option<String>, /// The person's relationship status. Possible values include, but are not limited to, the following values: /// - "single" - Person is single. /// - "in_a_relationship" - Person is in a relationship. @@ -1231,72 +1231,72 @@ pub struct Person { /// - "in_domestic_partnership" - Person is in a domestic partnership. /// - "in_civil_union" - Person is in a civil union. #[serde(rename="relationshipStatus")] - pub relationship_status: String, + pub relationship_status: Option<String>, /// The representation of the person's profile photo. - pub image: PersonImage, + pub image: Option<PersonImage>, /// The hosted domain name for the user's Google Apps account. For instance, example.com. The plus.profile.emails.read or email scope is needed to get this domain name. - pub domain: String, + pub domain: Option<String>, /// A list of places where this person has lived. #[serde(rename="placesLived")] - pub places_lived: Vec<PersonPlacesLived>, + pub places_lived: Option<Vec<PersonPlacesLived>>, /// The person's date of birth, represented as YYYY-MM-DD. - pub birthday: String, + pub birthday: Option<String>, /// The name of this person, which is suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The nickname of this person. - pub nickname: String, + pub nickname: Option<String>, /// A list of email addresses that this person has, including their Google account email address, and the public verified email addresses on their Google+ profile. The plus.profile.emails.read scope is needed to retrieve these email addresses, or the email scope can be used to retrieve just the Google account email address. - pub emails: Vec<PersonEmails>, + pub emails: Option<Vec<PersonEmails>>, /// The occupation of this person. - pub occupation: String, + pub occupation: Option<String>, /// A list of current or past organizations with which this person is associated. - pub organizations: Vec<PersonOrganizations>, + pub organizations: Option<Vec<PersonOrganizations>>, /// Identifies this resource as a person. Value: "plus#person". - pub kind: String, + pub kind: Option<String>, /// Whether the person or Google+ Page has been verified. - pub verified: bool, + pub verified: Option<bool>, /// An object representation of the individual components of a person's name. - pub name: PersonName, + pub name: Option<PersonName>, /// Whether this user has signed up for Google+. #[serde(rename="isPlusUser")] - pub is_plus_user: bool, + pub is_plus_user: Option<bool>, /// The person's skills. - pub skills: String, + pub skills: Option<String>, /// The brief description (tagline) of this person. - pub tagline: String, + pub tagline: Option<String>, /// (this field is not currently used) #[serde(rename="currentLocation")] - pub current_location: String, + pub current_location: Option<String>, /// The cover photo content. - pub cover: PersonCover, + pub cover: Option<PersonCover>, /// The ID of this person. - pub id: String, + pub id: Option<String>, /// The URL of this person's profile. - pub url: String, + pub url: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// If a Google+ Page, the number of people who have +1'd this page. #[serde(rename="plusOneCount")] - pub plus_one_count: i32, + pub plus_one_count: Option<i32>, /// A list of URLs for this person. - pub urls: Vec<PersonUrls>, + pub urls: Option<Vec<PersonUrls>>, /// The person's gender. Possible values include, but are not limited to, the following values: /// - "male" - Male gender. /// - "female" - Female gender. /// - "other" - Other. - pub gender: String, + pub gender: Option<String>, /// For followers who are visible, the number of people who have added this person or page to a circle. #[serde(rename="circledByCount")] - pub circled_by_count: i32, + pub circled_by_count: Option<i32>, /// Type of person within Google+. Possible values include, but are not limited to, the following values: /// - "person" - represents an actual person. /// - "page" - represents a page. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, /// A short biography for this person. #[serde(rename="aboutMe")] - pub about_me: String, + pub about_me: Option<String>, } impl ResponseResult for Person {} @@ -1339,16 +1339,16 @@ impl Resource for Audience {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Place { /// The position of the place. - pub position: PlacePosition, + pub position: Option<PlacePosition>, /// Identifies this resource as a place. Value: "plus#place". - pub kind: String, + pub kind: Option<String>, /// The display name of the place. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The id of the place. - pub id: String, + pub id: Option<String>, /// The physical address of the place. - pub address: PlaceAddress, + pub address: Option<PlaceAddress>, } impl Part for Place {} @@ -1361,7 +1361,7 @@ impl Part for Place {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsPreviewThumbnails { /// URL of the thumbnail image. - pub url: String, + pub url: Option<String>, } impl NestedType for ActivityObjectAttachmentsPreviewThumbnails {} @@ -1438,16 +1438,16 @@ impl ResponseResult for Activity {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityActor { /// The link to the actor's Google profile. - pub url: String, + pub url: Option<String>, /// The image representation of the actor. - pub image: ActivityActorImage, + pub image: Option<ActivityActorImage>, /// The name of the actor, suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The ID of the actor's Person resource. - pub id: String, + pub id: Option<String>, /// An object representation of the individual components of name. - pub name: ActivityActorName, + pub name: Option<ActivityActorName>, } impl NestedType for ActivityActor {} @@ -1461,10 +1461,10 @@ impl Part for ActivityActor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsEmbed { /// URL of the link. - pub url: String, + pub url: Option<String>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for ActivityObjectAttachmentsEmbed {} @@ -1484,22 +1484,22 @@ impl Part for ActivityObjectAttachmentsEmbed {} pub struct CommentFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of comments. Value: "plus#commentFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this collection of comments. - pub title: String, + pub title: Option<String>, /// The comments in this page of results. - pub items: Vec<Comment>, + pub items: Option<Vec<Comment>>, /// The time at which this collection of comments was last updated. Formatted as an RFC 3339 timestamp. - pub updated: String, + pub updated: Option<String>, /// Link to the next page of activities. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The ID of this collection of comments. - pub id: String, + pub id: Option<String>, } impl ResponseResult for CommentFeed {} @@ -1513,10 +1513,10 @@ impl ResponseResult for CommentFeed {} pub struct ActivityObjectResharers { /// Total number of people who reshared this activity. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, /// The URL for the collection of resharers. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl NestedType for ActivityObjectResharers {} @@ -1530,7 +1530,7 @@ impl Part for ActivityObjectResharers {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityActorImage { /// The URL of the actor's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side. - pub url: String, + pub url: Option<String>, } impl NestedType for ActivityActorImage {} @@ -1590,21 +1590,21 @@ impl ResponseResult for Comment {} pub struct PersonName { /// The honorific prefixes (such as "Dr." or "Mrs.") for this person. #[serde(rename="honorificPrefix")] - pub honorific_prefix: String, + pub honorific_prefix: Option<String>, /// The given name (first name) of this person. #[serde(rename="givenName")] - pub given_name: String, + pub given_name: Option<String>, /// The middle name of this person. #[serde(rename="middleName")] - pub middle_name: String, + pub middle_name: Option<String>, /// The family name (last name) of this person. #[serde(rename="familyName")] - pub family_name: String, + pub family_name: Option<String>, /// The full name of this person, including middle names, suffixes, etc. - pub formatted: String, + pub formatted: Option<String>, /// The honorific suffixes (such as "Jr.") for this person. #[serde(rename="honorificSuffix")] - pub honorific_suffix: String, + pub honorific_suffix: Option<String>, } impl NestedType for PersonName {} @@ -1619,7 +1619,7 @@ impl Part for PersonName {} pub struct PlusDomainsAclentryResource { /// A descriptive name for this entry. Suitable for display. #[serde(rename="displayName")] - pub display_name: String, + pub display_name: Option<String>, /// The type of entry describing to whom access is granted. Possible values are: /// - "person" - Access to an individual. /// - "circle" - Access to members of a circle. @@ -1628,9 +1628,9 @@ pub struct PlusDomainsAclentryResource { /// - "domain" - Access to members of the person's Google Apps domain. /// - "public" - Access to anyone on the web. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The ID of the entry. For entries of type "person" or "circle", this is the ID of the resource. For other types, this property is not set. - pub id: String, + pub id: Option<String>, } impl Part for PlusDomainsAclentryResource {} @@ -1643,14 +1643,14 @@ impl Part for PlusDomainsAclentryResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObjectAttachmentsThumbnailsImage { /// Image url. - pub url: String, + pub url: Option<String>, /// The width, in pixels, of the linked resource. - pub width: u32, + pub width: Option<u32>, /// Media type of the link. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The height, in pixels, of the linked resource. - pub height: u32, + pub height: Option<u32>, } impl NestedType for ActivityObjectAttachmentsThumbnailsImage {} @@ -1665,7 +1665,7 @@ impl Part for ActivityObjectAttachmentsThumbnailsImage {} pub struct CirclePeople { /// The total number of people in this circle. #[serde(rename="totalItems")] - pub total_items: u32, + pub total_items: Option<u32>, } impl NestedType for CirclePeople {} @@ -1679,32 +1679,32 @@ impl Part for CirclePeople {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityObject { /// The HTML-formatted content, which is suitable for display. - pub content: String, + pub content: Option<String>, /// The media objects attached to this activity. - pub attachments: Vec<ActivityObjectAttachments>, + pub attachments: Option<Vec<ActivityObjectAttachments>>, /// The content (text) as provided by the author, which is stored without any HTML formatting. When creating or updating an activity, this value must be supplied as plain text in the request. #[serde(rename="originalContent")] - pub original_content: String, + pub original_content: Option<String>, /// People who +1'd this activity. - pub plusoners: ActivityObjectPlusoners, + pub plusoners: Option<ActivityObjectPlusoners>, /// If this activity's object is itself another activity, such as when a person reshares an activity, this property specifies the original activity's actor. - pub actor: ActivityObjectActor, + pub actor: Option<ActivityObjectActor>, /// People who reshared this activity. - pub resharers: ActivityObjectResharers, + pub resharers: Option<ActivityObjectResharers>, /// The URL that points to the linked resource. - pub url: String, + pub url: Option<String>, /// Status of the activity as seen by the viewer. #[serde(rename="statusForViewer")] - pub status_for_viewer: ActivityObjectStatusForViewer, + pub status_for_viewer: Option<ActivityObjectStatusForViewer>, /// Comments in reply to this activity. - pub replies: ActivityObjectReplies, + pub replies: Option<ActivityObjectReplies>, /// The ID of the object. When resharing an activity, this is the ID of the activity that is being reshared. - pub id: String, + pub id: Option<String>, /// The type of the object. Possible values include, but are not limited to, the following values: /// - "note" - Textual content. /// - "activity" - A Google+ activity. #[serde(rename="objectType")] - pub object_type: String, + pub object_type: Option<String>, } impl NestedType for ActivityObject {} @@ -1724,24 +1724,24 @@ impl Part for ActivityObject {} pub struct CircleFeed { /// The continuation token, which is used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies this resource as a collection of circles. Value: "plus#circleFeed". - pub kind: String, + pub kind: Option<String>, /// The title of this list of resources. - pub title: String, + pub title: Option<String>, /// The circles in this page of results. - pub items: Vec<Circle>, + pub items: Option<Vec<Circle>>, /// Link to the next page of circles. #[serde(rename="nextLink")] - pub next_link: String, + pub next_link: Option<String>, /// ETag of this response for caching purposes. - pub etag: String, + pub etag: Option<String>, /// The total number of circles. The number of circles in this response may be smaller due to paging. #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, /// Link to this page of circles. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for CircleFeed {} @@ -2510,16 +2510,20 @@ impl<'a, C, A> CircleRemovePeopleCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2665,7 +2669,7 @@ impl<'a, C, A> CircleRemovePeopleCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Circle = Default::default(); +/// let mut req = Circle::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2757,16 +2761,20 @@ impl<'a, C, A> CircleInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3018,16 +3026,20 @@ impl<'a, C, A> CircleAddPeopleCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -3264,16 +3276,20 @@ impl<'a, C, A> CircleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3504,16 +3520,20 @@ impl<'a, C, A> CircleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3667,7 +3687,7 @@ impl<'a, C, A> CircleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Circle = Default::default(); +/// let mut req = Circle::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3759,16 +3779,20 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3921,7 +3945,7 @@ impl<'a, C, A> CircleUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Circle = Default::default(); +/// let mut req = Circle::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4013,16 +4037,20 @@ impl<'a, C, A> CirclePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4255,16 +4283,20 @@ impl<'a, C, A> CircleRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4394,7 +4426,7 @@ impl<'a, C, A> CircleRemoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Activity = Default::default(); +/// let mut req = Activity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4491,16 +4523,20 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4741,16 +4777,20 @@ impl<'a, C, A> ActivityGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4983,16 +5023,20 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5247,16 +5291,20 @@ impl<'a, C, A> PeopleListByCircleCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5508,16 +5556,20 @@ impl<'a, C, A> PeopleListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5769,16 +5821,20 @@ impl<'a, C, A> PeopleGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6011,16 +6067,20 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6185,7 +6245,7 @@ impl<'a, C, A> PeopleListByActivityCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Media = Default::default(); +/// let mut req = Media::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. @@ -6290,16 +6350,20 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -6560,7 +6624,7 @@ impl<'a, C, A> MediaInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Comment = Default::default(); +/// let mut req = Comment::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6652,16 +6716,20 @@ impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6910,16 +6978,20 @@ impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7161,16 +7233,20 @@ impl<'a, C, A> CommentGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7401,16 +7477,20 @@ impl<'a, C, A> AudienceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/prediction1d6-cli/Cargo.toml b/gen/prediction1d6-cli/Cargo.toml index 0ec32c7a85..59d02e58df 100644 --- a/gen/prediction1d6-cli/Cargo.toml +++ b/gen/prediction1d6-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-prediction1d6-cli" version = "0.0.1+20140522" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/prediction/docs/developer-guide" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/prediction1d6-cli/src/cmn.rs b/gen/prediction1d6-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/prediction1d6-cli/src/cmn.rs +++ b/gen/prediction1d6-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/prediction1d6-cli/src/main.rs b/gen/prediction1d6-cli/src/main.rs index fc7f7a1f4d..57df417732 100644 --- a/gen/prediction1d6-cli/src/main.rs +++ b/gen/prediction1d6-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -39,6 +40,12 @@ Configuration: 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. "); mod cmn; @@ -60,10 +67,10 @@ struct Engine { impl Engine { fn _hostedmodels_predict(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Input = Default::default(); + let mut request = api::Input::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -83,9 +90,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -107,8 +115,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -119,7 +126,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.trainedmodels().analyze(&self.opt.arg_project, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -151,8 +158,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -163,7 +169,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.trainedmodels().delete(&self.opt.arg_project, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -194,7 +200,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -205,7 +210,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.trainedmodels().get(&self.opt.arg_project, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -237,8 +242,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -247,10 +251,10 @@ impl Engine { fn _trainedmodels_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Insert = Default::default(); + let mut request = api::Insert::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -270,9 +274,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -312,8 +317,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -324,7 +328,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.trainedmodels().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -362,8 +366,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -372,10 +375,10 @@ impl Engine { fn _trainedmodels_predict(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Input = Default::default(); + let mut request = api::Input::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -395,9 +398,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -419,8 +423,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -429,10 +432,10 @@ impl Engine { fn _trainedmodels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Update = Default::default(); + let mut request = api::Update::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -452,9 +455,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -479,8 +483,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -498,7 +501,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_trainedmodels { + } + else if self.opt.cmd_trainedmodels { if self.opt.cmd_analyze { call_result = self._trainedmodels_analyze(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -536,21 +540,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "prediction1d6-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "prediction1d6-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "prediction1d6", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "prediction1d6", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Prediction::new(hyper::Client::new(), auth), + hub: api::Prediction::new(client, auth), }; match engine._doit(true) { @@ -570,12 +590,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/prediction1d6/Cargo.toml b/gen/prediction1d6/Cargo.toml index 0febbfd460..857e20bdd1 100644 --- a/gen/prediction1d6/Cargo.toml +++ b/gen/prediction1d6/Cargo.toml @@ -5,7 +5,7 @@ name = "google-prediction1d6" version = "0.1.5+20140522" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/prediction/docs/developer-guide" diff --git a/gen/prediction1d6/README.md b/gen/prediction1d6/README.md index 41a9db9e36..3fb800f6e9 100644 --- a/gen/prediction1d6/README.md +++ b/gen/prediction1d6/README.md @@ -97,7 +97,7 @@ let mut hub = Prediction::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Update = Default::default(); +let mut req = Update::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/prediction1d6/src/cmn.rs b/gen/prediction1d6/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/prediction1d6/src/cmn.rs +++ b/gen/prediction1d6/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/prediction1d6/src/lib.rs b/gen/prediction1d6/src/lib.rs index 326fb75db7..ca3860c31b 100644 --- a/gen/prediction1d6/src/lib.rs +++ b/gen/prediction1d6/src/lib.rs @@ -98,7 +98,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Update = Default::default(); +//! let mut req = Update::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -285,7 +285,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Update = Default::default(); +/// let mut req = Update::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -358,9 +358,9 @@ impl<'a, C, A> Prediction<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionFeaturesCategoricalValues { /// Number of times this feature had this value. - pub count: String, + pub count: Option<String>, /// The category name. - pub value: String, + pub value: Option<String>, } impl NestedType for AnalyzeDataDescriptionFeaturesCategoricalValues {} @@ -413,9 +413,9 @@ impl RequestValue for Insert {} pub struct AnalyzeDataDescription { /// Description of the output value or label. #[serde(rename="outputFeature")] - pub output_feature: AnalyzeDataDescriptionOutputFeature, + pub output_feature: Option<AnalyzeDataDescriptionOutputFeature>, /// Description of the input features in the data set. - pub features: Vec<AnalyzeDataDescriptionFeatures>, + pub features: Option<Vec<AnalyzeDataDescriptionFeatures>>, } impl NestedType for AnalyzeDataDescription {} @@ -429,11 +429,11 @@ impl Part for AnalyzeDataDescription {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionFeaturesNumeric { /// Number of numeric values for this feature in the data set. - pub count: String, + pub count: Option<String>, /// Variance of the numeric values of this feature in the data set. - pub variance: String, + pub variance: Option<String>, /// Mean of the numeric values of this feature in the data set. - pub mean: String, + pub mean: Option<String>, } impl NestedType for AnalyzeDataDescriptionFeaturesNumeric {} @@ -453,14 +453,14 @@ impl Part for AnalyzeDataDescriptionFeaturesNumeric {} pub struct List { /// Pagination token to fetch the next page, if one exists. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of models. - pub items: Vec<Insert2>, + pub items: Option<Vec<Insert2>>, /// What kind of resource this is. - pub kind: String, + pub kind: Option<String>, /// A URL to re-request this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for List {} @@ -474,7 +474,7 @@ impl ResponseResult for List {} pub struct InputInput { /// A list of input features, these can be strings or doubles. #[serde(rename="csvInstance")] - pub csv_instance: Vec<String>, + pub csv_instance: Option<Vec<String>>, } impl NestedType for InputInput {} @@ -488,7 +488,7 @@ impl Part for InputInput {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionFeaturesText { /// Number of multiple-word text values for this feature. - pub count: String, + pub count: Option<String>, } impl NestedType for AnalyzeDataDescriptionFeaturesText {} @@ -502,13 +502,13 @@ impl Part for AnalyzeDataDescriptionFeaturesText {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionFeatures { /// The feature index. - pub index: String, + pub index: Option<String>, /// Description of the categorical values of this feature. - pub categorical: AnalyzeDataDescriptionFeaturesCategorical, + pub categorical: Option<AnalyzeDataDescriptionFeaturesCategorical>, /// Description of the numeric values of this feature. - pub numeric: AnalyzeDataDescriptionFeaturesNumeric, + pub numeric: Option<AnalyzeDataDescriptionFeaturesNumeric>, /// Description of multiple-word text values of this feature. - pub text: AnalyzeDataDescriptionFeaturesText, + pub text: Option<AnalyzeDataDescriptionFeaturesText>, } impl NestedType for AnalyzeDataDescriptionFeatures {} @@ -547,21 +547,21 @@ impl RequestValue for Input {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Output { /// What kind of resource this is. - pub kind: String, + pub kind: Option<String>, /// A list of class labels with their estimated probabilities (Categorical models only). #[serde(rename="outputMulti")] - pub output_multi: Vec<OutputOutputMulti>, + pub output_multi: Option<Vec<OutputOutputMulti>>, /// The most likely class label (Categorical models only). #[serde(rename="outputLabel")] - pub output_label: String, + pub output_label: Option<String>, /// The unique name for the predictive model. - pub id: String, + pub id: Option<String>, /// A URL to re-request this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// The estimated regression value (Regression models only). #[serde(rename="outputValue")] - pub output_value: String, + pub output_value: Option<String>, } impl ResponseResult for Output {} @@ -579,20 +579,20 @@ impl ResponseResult for Output {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Analyze { /// What kind of resource this is. - pub kind: String, + pub kind: Option<String>, /// List of errors with the data. - pub errors: Vec<HashMap<String, String>>, + pub errors: Option<Vec<HashMap<String, String>>>, /// Description of the data the model was trained on. #[serde(rename="dataDescription")] - pub data_description: AnalyzeDataDescription, + pub data_description: Option<AnalyzeDataDescription>, /// Description of the model. #[serde(rename="modelDescription")] - pub model_description: AnalyzeModelDescription, + pub model_description: Option<AnalyzeModelDescription>, /// The unique name for the predictive model. - pub id: String, + pub id: Option<String>, /// A URL to re-request this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for Analyze {} @@ -612,35 +612,35 @@ impl ResponseResult for Analyze {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Insert2 { /// What kind of resource this is. - pub kind: String, + pub kind: Option<String>, /// Insert time of the model (as a RFC 3339 timestamp). - pub created: String, + pub created: Option<String>, /// Google storage location of the preprocessing pmml file. #[serde(rename="storagePMMLLocation")] - pub storage_pmml_location: String, + pub storage_pmml_location: Option<String>, /// Google storage location of the pmml model file. #[serde(rename="storagePMMLModelLocation")] - pub storage_pmml_model_location: String, + pub storage_pmml_model_location: Option<String>, /// Type of predictive model (CLASSIFICATION or REGRESSION). #[serde(rename="modelType")] - pub model_type: String, + pub model_type: Option<String>, /// Google storage location of the training data file. #[serde(rename="storageDataLocation")] - pub storage_data_location: String, + pub storage_data_location: Option<String>, /// A URL to re-request this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// Model metadata. #[serde(rename="modelInfo")] - pub model_info: Insert2ModelInfo, + pub model_info: Option<Insert2ModelInfo>, /// Training completion time (as a RFC 3339 timestamp). #[serde(rename="trainingComplete")] - pub training_complete: String, + pub training_complete: Option<String>, /// The unique name for the predictive model. - pub id: String, + pub id: Option<String>, /// The current status of the training job. This can be one of following: RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND #[serde(rename="trainingStatus")] - pub training_status: String, + pub training_status: Option<String>, } impl ResponseResult for Insert2 {} @@ -653,11 +653,11 @@ impl ResponseResult for Insert2 {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionOutputFeatureNumeric { /// Number of numeric output values in the data set. - pub count: String, + pub count: Option<String>, /// Variance of the output values in the data set. - pub variance: String, + pub variance: Option<String>, /// Mean of the output values in the data set. - pub mean: String, + pub mean: Option<String>, } impl NestedType for AnalyzeDataDescriptionOutputFeatureNumeric {} @@ -671,9 +671,9 @@ impl Part for AnalyzeDataDescriptionOutputFeatureNumeric {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionOutputFeature { /// Description of the output labels in the data set. - pub text: Vec<AnalyzeDataDescriptionOutputFeatureText>, + pub text: Option<Vec<AnalyzeDataDescriptionOutputFeatureText>>, /// Description of the output values in the data set. - pub numeric: AnalyzeDataDescriptionOutputFeatureNumeric, + pub numeric: Option<AnalyzeDataDescriptionOutputFeatureNumeric>, } impl NestedType for AnalyzeDataDescriptionOutputFeature {} @@ -688,12 +688,12 @@ impl Part for AnalyzeDataDescriptionOutputFeature {} pub struct AnalyzeModelDescription { /// An output confusion matrix. This shows an estimate for how this model will do in predictions. This is first indexed by the true class label. For each true class label, this provides a pair {predicted_label, count}, where count is the estimated number of times the model will predict the predicted label given the true label. Will not output if more then 100 classes (Categorical models only). #[serde(rename="confusionMatrix")] - pub confusion_matrix: HashMap<String, HashMap<String, String>>, + pub confusion_matrix: Option<HashMap<String, HashMap<String, String>>>, /// A list of the confusion matrix row totals. #[serde(rename="confusionMatrixRowTotals")] - pub confusion_matrix_row_totals: HashMap<String, String>, + pub confusion_matrix_row_totals: Option<HashMap<String, String>>, /// Basic information about the model. - pub modelinfo: Insert2, + pub modelinfo: Option<Insert2>, } impl NestedType for AnalyzeModelDescription {} @@ -708,22 +708,22 @@ impl Part for AnalyzeModelDescription {} pub struct Insert2ModelInfo { /// Number of valid data instances used in the trained model. #[serde(rename="numberInstances")] - pub number_instances: String, + pub number_instances: Option<String>, /// Estimated accuracy of model taking utility weights into account (Categorical models only). #[serde(rename="classWeightedAccuracy")] - pub class_weighted_accuracy: String, + pub class_weighted_accuracy: Option<String>, /// Number of class labels in the trained model (Categorical models only). #[serde(rename="numberLabels")] - pub number_labels: String, + pub number_labels: Option<String>, /// A number between 0.0 and 1.0, where 1.0 is 100% accurate. This is an estimate, based on the amount and quality of the training data, of the estimated prediction accuracy. You can use this is a guide to decide whether the results are accurate enough for your needs. This estimate will be more reliable if your real input data is similar to your training data (Categorical models only). #[serde(rename="classificationAccuracy")] - pub classification_accuracy: String, + pub classification_accuracy: Option<String>, /// An estimated mean squared error. The can be used to measure the quality of the predicted model (Regression models only). #[serde(rename="meanSquaredError")] - pub mean_squared_error: String, + pub mean_squared_error: Option<String>, /// Type of predictive model (CLASSIFICATION or REGRESSION). #[serde(rename="modelType")] - pub model_type: String, + pub model_type: Option<String>, } impl NestedType for Insert2ModelInfo {} @@ -737,9 +737,9 @@ impl Part for Insert2ModelInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionOutputFeatureText { /// Number of times the output label occurred in the data set. - pub count: String, + pub count: Option<String>, /// The output label. - pub value: String, + pub value: Option<String>, } impl NestedType for AnalyzeDataDescriptionOutputFeatureText {} @@ -753,9 +753,9 @@ impl Part for AnalyzeDataDescriptionOutputFeatureText {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyzeDataDescriptionFeaturesCategorical { /// Number of categorical values for this feature in the data. - pub count: String, + pub count: Option<String>, /// List of all the categories for this feature in the data set. - pub values: Vec<AnalyzeDataDescriptionFeaturesCategoricalValues>, + pub values: Option<Vec<AnalyzeDataDescriptionFeaturesCategoricalValues>>, } impl NestedType for AnalyzeDataDescriptionFeaturesCategorical {} @@ -790,10 +790,10 @@ impl RequestValue for Update {} #[derive(Default, Clone, Debug, Serialize)] pub struct InsertTrainingInstances { /// The generic output value - could be regression or class label. - pub output: String, + pub output: Option<String>, /// The input features for this instance. #[serde(rename="csvInstance")] - pub csv_instance: Vec<String>, + pub csv_instance: Option<Vec<String>>, } impl NestedType for InsertTrainingInstances {} @@ -807,9 +807,9 @@ impl Part for InsertTrainingInstances {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OutputOutputMulti { /// The probability of the class label. - pub score: String, + pub score: Option<String>, /// The class label. - pub label: String, + pub label: Option<String>, } impl NestedType for OutputOutputMulti {} @@ -1177,16 +1177,20 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1336,7 +1340,7 @@ impl<'a, C, A> TrainedmodelGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Update = Default::default(); +/// let mut req = Update::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1430,16 +1434,20 @@ impl<'a, C, A> TrainedmodelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1693,16 +1701,20 @@ impl<'a, C, A> TrainedmodelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1938,16 +1950,20 @@ impl<'a, C, A> TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2087,7 +2103,7 @@ impl<'a, C, A> TrainedmodelDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Insert = Default::default(); +/// let mut req = Insert::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2179,16 +2195,20 @@ impl<'a, C, A> TrainedmodelInsertCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2424,16 +2444,20 @@ impl<'a, C, A> TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2583,7 +2607,7 @@ impl<'a, C, A> TrainedmodelAnalyzeCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Input = Default::default(); +/// let mut req = Input::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2677,16 +2701,20 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2849,7 +2877,7 @@ impl<'a, C, A> TrainedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Input = Default::default(); +/// let mut req = Input::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2943,16 +2971,20 @@ impl<'a, C, A> HostedmodelPredictCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/pubsub1_beta2-cli/Cargo.toml b/gen/pubsub1_beta2-cli/Cargo.toml index 9b617fca1b..c3e7445e94 100644 --- a/gen/pubsub1_beta2-cli/Cargo.toml +++ b/gen/pubsub1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-pubsub1_beta2-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" documentation = "http://byron.github.io/google-apis-rs/google_pubsub1_beta2_cli" @@ -22,6 +22,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/pubsub1_beta2-cli/src/cmn.rs b/gen/pubsub1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/pubsub1_beta2-cli/src/cmn.rs +++ b/gen/pubsub1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/pubsub1_beta2-cli/src/main.rs b/gen/pubsub1_beta2-cli/src/main.rs index 94dda153fe..9aa088c4e3 100644 --- a/gen/pubsub1_beta2-cli/src/main.rs +++ b/gen/pubsub1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -45,6 +46,12 @@ Configuration: 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. "); mod cmn; @@ -66,10 +73,10 @@ struct Engine { impl Engine { fn _projects_subscriptions_acknowledge(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::AcknowledgeRequest = Default::default(); + let mut request = api::AcknowledgeRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -89,18 +96,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.ack_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.ack_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -119,8 +127,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -129,10 +136,10 @@ impl Engine { fn _projects_subscriptions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subscription = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -152,9 +159,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -173,11 +181,15 @@ impl Engine { }, "push-config.attributes" => { request_push_config_init(&mut request); - request.push_config.as_mut().unwrap().attributes.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + request.push_config.as_mut().unwrap().push_endpoint = Some(value.unwrap_or("").to_string()); }, "name" => { request_push_config_init(&mut request); @@ -200,8 +212,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -212,7 +223,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().subscriptions_delete(&self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -244,8 +255,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -256,7 +266,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().subscriptions_get(&self.opt.arg_subscription); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -288,8 +298,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -300,7 +309,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().subscriptions_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -338,8 +347,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -348,10 +356,10 @@ impl Engine { fn _projects_subscriptions_modify_ack_deadline(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ModifyAckDeadlineRequest = Default::default(); + let mut request = api::ModifyAckDeadlineRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -371,9 +379,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -401,8 +410,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -411,10 +419,10 @@ impl Engine { fn _projects_subscriptions_modify_push_config(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ModifyPushConfigRequest = Default::default(); + let mut request = api::ModifyPushConfigRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -434,9 +442,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -449,11 +458,15 @@ impl Engine { match &field_name.to_string()[..] { "push-config.attributes" => { request_push_config_init(&mut request); - request.push_config.as_mut().unwrap().attributes.push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -472,8 +485,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -482,10 +494,10 @@ impl Engine { fn _projects_subscriptions_pull(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PullRequest = Default::default(); + let mut request = api::PullRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -505,9 +517,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -535,8 +548,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -545,10 +557,10 @@ impl Engine { fn _projects_topics_create(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Topic = Default::default(); + let mut request = api::Topic::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -568,9 +580,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -595,8 +608,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -607,7 +619,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().topics_delete(&self.opt.arg_topic); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -639,8 +651,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -651,7 +662,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().topics_get(&self.opt.arg_topic); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -683,8 +694,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -695,7 +705,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().topics_list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -733,8 +743,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -743,10 +752,10 @@ impl Engine { fn _projects_topics_publish(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PublishRequest = Default::default(); + let mut request = api::PublishRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -766,9 +775,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -790,8 +800,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -802,7 +811,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.projects().topics_subscriptions_list(&self.opt.arg_topic); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -840,8 +849,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -905,21 +913,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "pubsub1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "pubsub1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "pubsub1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "pubsub1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Pubsub::new(hyper::Client::new(), auth), + hub: api::Pubsub::new(client, auth), }; match engine._doit(true) { @@ -939,12 +963,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 ca1ec4daca..adcf77a5f5 100644 --- a/gen/pubsub1_beta2/Cargo.toml +++ b/gen/pubsub1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-pubsub1_beta2" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" documentation = "http://byron.github.io/google-apis-rs/google_pubsub1_beta2" diff --git a/gen/pubsub1_beta2/README.md b/gen/pubsub1_beta2/README.md index 10b7fe7d98..8c753fa0ae 100644 --- a/gen/pubsub1_beta2/README.md +++ b/gen/pubsub1_beta2/README.md @@ -94,7 +94,7 @@ let mut hub = Pubsub::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: AcknowledgeRequest = Default::default(); +let mut req = AcknowledgeRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/pubsub1_beta2/src/cmn.rs b/gen/pubsub1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/pubsub1_beta2/src/cmn.rs +++ b/gen/pubsub1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/pubsub1_beta2/src/lib.rs b/gen/pubsub1_beta2/src/lib.rs index 1026f5eb32..702900bc48 100644 --- a/gen/pubsub1_beta2/src/lib.rs +++ b/gen/pubsub1_beta2/src/lib.rs @@ -95,7 +95,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: AcknowledgeRequest = Default::default(); +//! let mut req = AcknowledgeRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -274,7 +274,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AcknowledgeRequest = Default::default(); +/// let mut req = AcknowledgeRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -350,9 +350,9 @@ impl<'a, C, A> Pubsub<C, A> pub struct ListTopicSubscriptionsResponse { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// no description provided - pub subscriptions: Vec<String>, + pub subscriptions: Option<Vec<String>>, } impl ResponseResult for ListTopicSubscriptionsResponse {} @@ -366,9 +366,9 @@ impl ResponseResult for ListTopicSubscriptionsResponse {} pub struct ReceivedMessage { /// no description provided #[serde(rename="ackId")] - pub ack_id: String, + pub ack_id: Option<String>, /// no description provided - pub message: PubsubMessage, + pub message: Option<PubsubMessage>, } impl Part for ReceivedMessage {} @@ -446,9 +446,9 @@ impl RequestValue for PublishRequest {} pub struct ListSubscriptionsResponse { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// no description provided - pub subscriptions: Vec<Subscription>, + pub subscriptions: Option<Vec<Subscription>>, } impl ResponseResult for ListSubscriptionsResponse {} @@ -467,9 +467,9 @@ impl ResponseResult for ListSubscriptionsResponse {} pub struct ListTopicsResponse { /// no description provided #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// no description provided - pub topics: Vec<Topic>, + pub topics: Option<Vec<Topic>>, } impl ResponseResult for ListTopicsResponse {} @@ -542,10 +542,10 @@ impl RequestValue for PullRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PushConfig { /// no description provided - pub attributes: HashMap<String, String>, + pub attributes: Option<HashMap<String, String>>, /// no description provided #[serde(rename="pushEndpoint")] - pub push_endpoint: String, + pub push_endpoint: Option<String>, } impl Part for PushConfig {} @@ -584,7 +584,7 @@ impl ResponseResult for Topic {} pub struct PublishResponse { /// no description provided #[serde(rename="messageIds")] - pub message_ids: Vec<String>, + pub message_ids: Option<Vec<String>>, } impl ResponseResult for PublishResponse {} @@ -603,7 +603,7 @@ impl ResponseResult for PublishResponse {} pub struct PullResponse { /// no description provided #[serde(rename="receivedMessages")] - pub received_messages: Vec<ReceivedMessage>, + pub received_messages: Option<Vec<ReceivedMessage>>, } impl ResponseResult for PullResponse {} @@ -616,12 +616,12 @@ impl ResponseResult for PullResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PubsubMessage { /// no description provided - pub attributes: HashMap<String, String>, + pub attributes: Option<HashMap<String, String>>, /// no description provided - pub data: String, + pub data: Option<String>, /// no description provided #[serde(rename="messageId")] - pub message_id: String, + pub message_id: Option<String>, } impl Part for PubsubMessage {} @@ -1087,16 +1087,20 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1247,7 +1251,7 @@ impl<'a, C, A> ProjectTopicListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PullRequest = Default::default(); +/// let mut req = PullRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1343,16 +1347,20 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1504,7 +1512,7 @@ impl<'a, C, A> ProjectSubscriptionPullCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Topic = Default::default(); +/// let mut req = Topic::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1600,16 +1608,20 @@ impl<'a, C, A> ProjectTopicCreateCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1846,16 +1858,20 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1994,7 +2010,7 @@ impl<'a, C, A> ProjectTopicDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ModifyPushConfigRequest = Default::default(); +/// let mut req = ModifyPushConfigRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2090,16 +2106,20 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2251,7 +2271,7 @@ impl<'a, C, A> ProjectSubscriptionModifyPushConfigCall<'a, C, A> where C: Borrow /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PublishRequest = Default::default(); +/// let mut req = PublishRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2347,16 +2367,20 @@ impl<'a, C, A> ProjectTopicPublishCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2593,16 +2617,20 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2741,7 +2769,7 @@ impl<'a, C, A> ProjectTopicGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ModifyAckDeadlineRequest = Default::default(); +/// let mut req = ModifyAckDeadlineRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2837,16 +2865,20 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2998,7 +3030,7 @@ impl<'a, C, A> ProjectSubscriptionModifyAckDeadlineCall<'a, C, A> where C: Borro /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: AcknowledgeRequest = Default::default(); +/// let mut req = AcknowledgeRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3094,16 +3126,20 @@ impl<'a, C, A> ProjectSubscriptionAcknowledgeCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3340,16 +3376,20 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3488,7 +3528,7 @@ impl<'a, C, A> ProjectSubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subscription = Default::default(); +/// let mut req = Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3584,16 +3624,20 @@ impl<'a, C, A> ProjectSubscriptionCreateCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3830,16 +3874,20 @@ impl<'a, C, A> ProjectSubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4073,16 +4121,20 @@ impl<'a, C, A> ProjectTopicSubscriptionListCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4328,16 +4380,20 @@ impl<'a, C, A> ProjectSubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/qpxexpress1-cli/Cargo.toml b/gen/qpxexpress1-cli/Cargo.toml index beed3f8b6a..7512ba8d5e 100644 --- a/gen/qpxexpress1-cli/Cargo.toml +++ b/gen/qpxexpress1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-qpxexpress1-cli" version = "0.0.1+20140321" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/qpx-express" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/qpxexpress1-cli/src/cmn.rs b/gen/qpxexpress1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/qpxexpress1-cli/src/cmn.rs +++ b/gen/qpxexpress1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/qpxexpress1-cli/src/main.rs b/gen/qpxexpress1-cli/src/main.rs index 2059eb0e87..e54488b401 100644 --- a/gen/qpxexpress1-cli/src/main.rs +++ b/gen/qpxexpress1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -28,6 +29,12 @@ Configuration: 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. "); mod cmn; @@ -49,10 +56,10 @@ struct Engine { impl Engine { fn _trips_search(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TripsSearchRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -72,9 +79,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -84,46 +92,53 @@ impl Engine { } } + fn request_request_passengers_init(request: &mut api::TripsSearchRequest) { + request_request_init(request); + if request.request.as_mut().unwrap().passengers.is_none() { + request.request.as_mut().unwrap().passengers = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "request.refundable" => { request_request_init(&mut request); - request.request.as_mut().unwrap().refundable = arg_from_str(value.unwrap_or("false"), err, "request.refundable", "boolean"); + request.request.as_mut().unwrap().refundable = Some(arg_from_str(value.unwrap_or("false"), err, "request.refundable", "boolean")); }, "request.passengers.kind" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.kind = value.unwrap_or("").to_string(); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "request.passengers.infant-in-lap-count" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.infant_in_lap_count = arg_from_str(value.unwrap_or("-0"), err, "request.passengers.infant-in-lap-count", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().infant_in_lap_count = Some(arg_from_str(value.unwrap_or("-0"), err, "request.passengers.infant-in-lap-count", "integer")); }, "request.passengers.senior-count" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.senior_count = arg_from_str(value.unwrap_or("-0"), err, "request.passengers.senior-count", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().senior_count = Some(arg_from_str(value.unwrap_or("-0"), err, "request.passengers.senior-count", "integer")); }, "request.passengers.infant-in-seat-count" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.infant_in_seat_count = arg_from_str(value.unwrap_or("-0"), err, "request.passengers.infant-in-seat-count", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().infant_in_seat_count = Some(arg_from_str(value.unwrap_or("-0"), err, "request.passengers.infant-in-seat-count", "integer")); }, "request.passengers.child-count" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.child_count = arg_from_str(value.unwrap_or("-0"), err, "request.passengers.child-count", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().child_count = Some(arg_from_str(value.unwrap_or("-0"), err, "request.passengers.child-count", "integer")); }, "request.passengers.adult-count" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().passengers.adult_count = arg_from_str(value.unwrap_or("-0"), err, "request.passengers.adult-count", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().passengers.as_mut().unwrap().adult_count = Some(arg_from_str(value.unwrap_or("-0"), err, "request.passengers.adult-count", "integer")); }, "request.sale-country" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().sale_country = arg_from_str(value.unwrap_or("-0"), err, "request.sale-country", "int64"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().sale_country = Some(arg_from_str(value.unwrap_or("-0"), err, "request.sale-country", "int64")); }, "request.solutions" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().solutions = arg_from_str(value.unwrap_or("-0"), err, "request.solutions", "integer"); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().solutions = Some(arg_from_str(value.unwrap_or("-0"), err, "request.solutions", "integer")); }, "request.max-price" => { - request_request_init(&mut request); - request.request.as_mut().unwrap().max_price = value.unwrap_or("").to_string(); + request_request_passengers_init(&mut request); + request.request.as_mut().unwrap().max_price = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -142,8 +157,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -181,21 +195,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "qpxexpress1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "qpxexpress1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "qpxexpress1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "qpxexpress1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::QPXExpress::new(hyper::Client::new(), auth), + hub: api::QPXExpress::new(client, auth), }; match engine._doit(true) { @@ -215,12 +245,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/qpxexpress1/Cargo.toml b/gen/qpxexpress1/Cargo.toml index f317bd948d..01246af09b 100644 --- a/gen/qpxexpress1/Cargo.toml +++ b/gen/qpxexpress1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-qpxexpress1" version = "0.1.5+20140321" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/qpx-express" diff --git a/gen/qpxexpress1/README.md b/gen/qpxexpress1/README.md index 3aca2eb78a..d47cf9981f 100644 --- a/gen/qpxexpress1/README.md +++ b/gen/qpxexpress1/README.md @@ -93,7 +93,7 @@ let mut hub = QPXExpress::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: TripsSearchRequest = Default::default(); +let mut req = TripsSearchRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/qpxexpress1/src/cmn.rs b/gen/qpxexpress1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/qpxexpress1/src/cmn.rs +++ b/gen/qpxexpress1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/qpxexpress1/src/lib.rs b/gen/qpxexpress1/src/lib.rs index 6e1b207296..54f12b5e0e 100644 --- a/gen/qpxexpress1/src/lib.rs +++ b/gen/qpxexpress1/src/lib.rs @@ -94,7 +94,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: TripsSearchRequest = Default::default(); +//! let mut req = TripsSearchRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -247,7 +247,7 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TripsSearchRequest = Default::default(); +/// let mut req = TripsSearchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -318,21 +318,21 @@ impl<'a, C, A> QPXExpress<C, A> pub struct PassengerCounts { /// The number of passengers that are infants travelling in the lap of an adult. #[serde(rename="infantInLapCount")] - pub infant_in_lap_count: i32, + pub infant_in_lap_count: Option<i32>, /// Identifies this as a passenger count object, representing the number of passengers. Value: the fixed string qpxexpress#passengerCounts. - pub kind: String, + pub kind: Option<String>, /// The number of passengers that are infants each assigned a seat. #[serde(rename="infantInSeatCount")] - pub infant_in_seat_count: i32, + pub infant_in_seat_count: Option<i32>, /// The number of passengers that are adults. #[serde(rename="adultCount")] - pub adult_count: i32, + pub adult_count: Option<i32>, /// The number of passengers that are senior citizens. #[serde(rename="seniorCount")] - pub senior_count: i32, + pub senior_count: Option<i32>, /// The number of passengers that are children. #[serde(rename="childCount")] - pub child_count: i32, + pub child_count: Option<i32>, } impl Part for PassengerCounts {} @@ -345,16 +345,16 @@ impl Part for PassengerCounts {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SegmentPricing { /// Identifies this as a segment pricing object, representing the price of this segment. Value: the fixed string qpxexpress#segmentPricing. - pub kind: String, + pub kind: Option<String>, /// A segment identifier unique within a single solution. It is used to refer to different parts of the same solution. #[serde(rename="fareId")] - pub fare_id: String, + pub fare_id: Option<String>, /// Details of the free baggage allowance on this segment. #[serde(rename="freeBaggageOption")] - pub free_baggage_option: Vec<FreeBaggageAllowance>, + pub free_baggage_option: Option<Vec<FreeBaggageAllowance>>, /// Unique identifier in the response of this segment. #[serde(rename="segmentId")] - pub segment_id: String, + pub segment_id: Option<String>, } impl Part for SegmentPricing {} @@ -367,47 +367,47 @@ impl Part for SegmentPricing {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LegInfo { /// The leg origin as a city and airport. - pub origin: String, + pub origin: Option<String>, /// The terminal the flight is scheduled to depart from. #[serde(rename="originTerminal")] - pub origin_terminal: String, + pub origin_terminal: Option<String>, /// The number of miles in this leg. - pub mileage: i32, + pub mileage: Option<i32>, /// Whether passenger information must be furnished to the United States Transportation Security Administration (TSA) prior to departure. - pub secure: bool, + pub secure: Option<bool>, /// Duration of a connection following this leg, in minutes. #[serde(rename="connectionDuration")] - pub connection_duration: i32, + pub connection_duration: Option<i32>, /// The scheduled departure time of the leg, local to the point of departure. #[serde(rename="departureTime")] - pub departure_time: String, + pub departure_time: Option<String>, /// The aircraft (or bus, ferry, railcar, etc) travelling between the two points of this leg. - pub aircraft: String, + pub aircraft: Option<String>, /// In percent, the published on time performance on this leg. #[serde(rename="onTimePerformance")] - pub on_time_performance: i32, + pub on_time_performance: Option<i32>, /// The scheduled time of arrival at the destination of the leg, local to the point of arrival. #[serde(rename="arrivalTime")] - pub arrival_time: String, + pub arrival_time: Option<String>, /// The scheduled travelling time from the origin to the destination. - pub duration: i32, + pub duration: Option<i32>, /// The leg destination as a city and airport. - pub destination: String, + pub destination: Option<String>, /// An identifier that uniquely identifies this leg in the solution. - pub id: String, + pub id: Option<String>, /// Identifies this as a leg object. A leg is the smallest unit of travel, in the case of a flight a takeoff immediately followed by a landing at two set points on a particular carrier with a particular flight number. Value: the fixed string qpxexpress#legInfo. - pub kind: String, + pub kind: Option<String>, /// The terminal the flight is scheduled to arrive at. #[serde(rename="destinationTerminal")] - pub destination_terminal: String, + pub destination_terminal: Option<String>, /// Whether you have to change planes following this leg. Only applies to the next leg. #[serde(rename="changePlane")] - pub change_plane: bool, + pub change_plane: Option<bool>, /// Department of Transportation disclosure information on the actual operator of a flight in a code share. (A code share refers to a marketing agreement between two carriers, where one carrier will list in its schedules (and take bookings for) flights that are actually operated by another carrier.) #[serde(rename="operatingDisclosure")] - pub operating_disclosure: String, + pub operating_disclosure: Option<String>, /// A simple, general description of the meal(s) served on the flight, for example: "Hot meal". - pub meal: String, + pub meal: Option<String>, } impl Part for LegInfo {} @@ -421,19 +421,19 @@ impl Part for LegInfo {} pub struct FareInfo { /// no description provided #[serde(rename="basisCode")] - pub basis_code: String, + pub basis_code: Option<String>, /// The city code of the city the trip begins at. - pub origin: String, + pub origin: Option<String>, /// Identifies this as a fare object. Value: the fixed string qpxexpress#fareInfo. - pub kind: String, + pub kind: Option<String>, /// The carrier of the aircraft or other vehicle commuting between two points. - pub carrier: String, + pub carrier: Option<String>, /// The city code of the city the trip ends at. - pub destination: String, + pub destination: Option<String>, /// A unique identifier of the fare. - pub id: String, + pub id: Option<String>, /// Whether this is a private fare, for example one offered only to select customers rather than the general public. - pub private: bool, + pub private: Option<bool>, } impl Part for FareInfo {} @@ -446,32 +446,32 @@ impl Part for FareInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SegmentInfo { /// Identifies this as a segment object. A segment is one or more consecutive legs on the same flight. For example a hypothetical flight ZZ001, from DFW to OGG, could have one segment with two legs: DFW to HNL (leg 1), HNL to OGG (leg 2). Value: the fixed string qpxexpress#segmentInfo. - pub kind: String, + pub kind: Option<String>, /// The number of seats available in this booking code on this segment. #[serde(rename="bookingCodeCount")] - pub booking_code_count: i32, + pub booking_code_count: Option<i32>, /// The flight this is a segment of. - pub flight: FlightInfo, + pub flight: Option<FlightInfo>, /// The legs composing this segment. - pub leg: Vec<LegInfo>, + pub leg: Option<Vec<LegInfo>>, /// Whether the operation of this segment remains subject to government approval. #[serde(rename="subjectToGovernmentApproval")] - pub subject_to_government_approval: bool, + pub subject_to_government_approval: Option<bool>, /// In minutes, the duration of the connection following this segment. #[serde(rename="connectionDuration")] - pub connection_duration: i32, + pub connection_duration: Option<i32>, /// The booking code or class for this segment. #[serde(rename="bookingCode")] - pub booking_code: String, + pub booking_code: Option<String>, /// The duration of the flight segment in minutes. - pub duration: i32, + pub duration: Option<i32>, /// An id uniquely identifying the segment in the solution. - pub id: String, + pub id: Option<String>, /// The cabin booked for this segment. - pub cabin: String, + pub cabin: Option<String>, /// The solution-based index of a segment in a married segment group. Married segments can only be booked together. For example, an airline might report a certain booking code as sold out from Boston to Pittsburgh, but as available as part of two married segments Boston to Chicago connecting through Pittsburgh. For example content of this field, consider the round-trip flight ZZ1 PHX-PHL ZZ2 PHL-CLT ZZ3 CLT-PHX. This has three segments, with the two outbound ones (ZZ1 ZZ2) married. In this case, the two outbound segments belong to married segment group 0, and the return segment belongs to married segment group 1. #[serde(rename="marriedSegmentGroup")] - pub married_segment_group: String, + pub married_segment_group: Option<String>, } impl Part for SegmentInfo {} @@ -484,19 +484,19 @@ impl Part for SegmentInfo {} #[derive(Default, Clone, Debug, Serialize)] pub struct TripOptionsRequest { /// Counts for each passenger type in the request. - pub passengers: PassengerCounts, + pub passengers: Option<PassengerCounts>, /// The slices that make up the itinerary of this trip. A slice represents a traveler's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using one slice, round-trips using two. An example of a one slice trip with three segments might be BOS-SYD, SYD-LAX, LAX-BOS if the traveler only stopped in SYD and LAX just long enough to change planes. - pub slice: Vec<SliceInput>, + pub slice: Option<Vec<SliceInput>>, /// The number of solutions to return, maximum 500. - pub solutions: i32, + pub solutions: Option<i32>, /// Return only solutions with refundable fares. - pub refundable: bool, + pub refundable: Option<bool>, /// IATA country code representing the point of sale. This determines the "equivalent amount paid" currency for the ticket. #[serde(rename="saleCountry")] - pub sale_country: i64, + pub sale_country: Option<i64>, /// Do not return solutions that cost more than this price. The alphabetical part of the price is in ISO 4217. The format, in regex, is [A-Z]{3}\d+(\.\d+)? Example: $102.07 #[serde(rename="maxPrice")] - pub max_price: String, + pub max_price: Option<String>, } impl Part for TripOptionsRequest {} @@ -509,11 +509,11 @@ impl Part for TripOptionsRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AircraftData { /// Identifies this as an aircraftData object. Value: the fixed string qpxexpress#aircraftData - pub kind: String, + pub kind: Option<String>, /// The aircraft code. For example, for a Boeing 777 the code would be 777. - pub code: String, + pub code: Option<String>, /// The name of an aircraft, for example Boeing 777. - pub name: String, + pub name: Option<String>, } impl Part for AircraftData {} @@ -526,38 +526,38 @@ impl Part for AircraftData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PricingInfo { /// The fare used to price one or more segments. - pub fare: Vec<FareInfo>, + pub fare: Option<Vec<FareInfo>>, /// The horizontal fare calculation. This is a field on a ticket that displays all of the relevant items that go into the calculation of the fare. #[serde(rename="fareCalculation")] - pub fare_calculation: String, + pub fare_calculation: Option<String>, /// Identifies this as a pricing object, representing the price of one or more travel segments. Value: the fixed string qpxexpress#pricingInfo. - pub kind: String, + pub kind: Option<String>, /// The per-segment price and baggage information. #[serde(rename="segmentPricing")] - pub segment_pricing: Vec<SegmentPricing>, + pub segment_pricing: Option<Vec<SegmentPricing>>, /// Total per-passenger price (fare and tax) in the sale or equivalent currency. #[serde(rename="saleTotal")] - pub sale_total: String, + pub sale_total: Option<String>, /// The passenger type code for this pricing. An alphanumeric code used by a carrier to restrict fares to certain categories of passenger. For instance, a fare might be valid only for senior citizens. - pub ptc: String, + pub ptc: Option<String>, /// The number of passengers to which this price applies. - pub passengers: PassengerCounts, + pub passengers: Option<PassengerCounts>, /// The taxes used to calculate the tax total per ticket. - pub tax: Vec<TaxInfo>, + pub tax: Option<Vec<TaxInfo>>, /// The total fare in the sale or equivalent currency. #[serde(rename="saleFareTotal")] - pub sale_fare_total: String, + pub sale_fare_total: Option<String>, /// The total fare in the base fare currency (the currency of the country of origin). This element is only present when the sales currency and the currency of the country of commencement are different. #[serde(rename="baseFareTotal")] - pub base_fare_total: String, + pub base_fare_total: Option<String>, /// Whether the fares on this pricing are refundable. - pub refundable: bool, + pub refundable: Option<bool>, /// The taxes in the sale or equivalent currency. #[serde(rename="saleTaxTotal")] - pub sale_tax_total: String, + pub sale_tax_total: Option<String>, /// The latest ticketing time for this pricing assuming the reservation occurs at ticketing time and there is no change in fares/rules. The time is local to the point of sale (POS). #[serde(rename="latestTicketingTime")] - pub latest_ticketing_time: String, + pub latest_ticketing_time: Option<String>, } impl Part for PricingInfo {} @@ -571,12 +571,12 @@ impl Part for PricingInfo {} pub struct TimeOfDayRange { /// The earliest time of day in HH:MM format. #[serde(rename="earliestTime")] - pub earliest_time: String, + pub earliest_time: Option<String>, /// Identifies this as a time of day range object, representing two times in a single day defining a time range. Value: the fixed string qpxexpress#timeOfDayRange. - pub kind: String, + pub kind: Option<String>, /// The latest time of day in HH:MM format. #[serde(rename="latestTime")] - pub latest_time: String, + pub latest_time: Option<String>, } impl Part for TimeOfDayRange {} @@ -589,13 +589,13 @@ impl Part for TimeOfDayRange {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AirportData { /// The city code an airport is located in. For example, for JFK airport, this is NYC. - pub city: String, + pub city: Option<String>, /// Identifies this as an airport object. Value: the fixed string qpxexpress#airportData. - pub kind: String, + pub kind: Option<String>, /// An airport's code. For example, for Boston Logan airport, this is BOS. - pub code: String, + pub code: Option<String>, /// The name of an airport. For example, for airport BOS the name is "Boston Logan International". - pub name: String, + pub name: Option<String>, } impl Part for AirportData {} @@ -608,11 +608,11 @@ impl Part for AirportData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CarrierData { /// Identifies this as a kind of carrier (ie. an airline, bus line, railroad, etc). Value: the fixed string qpxexpress#carrierData. - pub kind: String, + pub kind: Option<String>, /// The IATA designator of a carrier (airline, etc). For example, for American Airlines, the code is AA. - pub code: String, + pub code: Option<String>, /// The long, full name of a carrier. For example: American Airlines. - pub name: String, + pub name: Option<String>, } impl Part for CarrierData {} @@ -625,11 +625,11 @@ impl Part for CarrierData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TaxData { /// Identifies this as a tax data object, representing some tax. Value: the fixed string qpxexpress#taxData. - pub kind: String, + pub kind: Option<String>, /// An identifier uniquely identifying a tax in a response. - pub id: String, + pub id: Option<String>, /// The name of a tax. - pub name: String, + pub name: Option<String>, } impl Part for TaxData {} @@ -642,19 +642,19 @@ impl Part for TaxData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TaxInfo { /// Identifies this as a tax information object. Value: the fixed string qpxexpress#taxInfo. - pub kind: String, + pub kind: Option<String>, /// The code to enter in the ticket's tax box. - pub code: String, + pub code: Option<String>, /// The price of the tax in the sales or equivalent currency. #[serde(rename="salePrice")] - pub sale_price: String, + pub sale_price: Option<String>, /// Whether this is a government charge or a carrier surcharge. #[serde(rename="chargeType")] - pub charge_type: String, + pub charge_type: Option<String>, /// For government charges, the country levying the charge. - pub country: String, + pub country: Option<String>, /// Identifier uniquely identifying this tax in a response. Not present for unnamed carrier surcharges. - pub id: String, + pub id: Option<String>, } impl Part for TaxInfo {} @@ -668,14 +668,14 @@ impl Part for TaxInfo {} pub struct TripOptionsResponse { /// A list of priced itinerary solutions to the QPX Express query. #[serde(rename="tripOption")] - pub trip_option: Vec<TripOption>, + pub trip_option: Option<Vec<TripOption>>, /// Identifies this as a QPX Express trip response object, which consists of zero or more solutions. Value: the fixed string qpxexpress#tripOptions. - pub kind: String, + pub kind: Option<String>, /// Informational data global to list of solutions. - pub data: Data, + pub data: Option<Data>, /// An identifier uniquely identifying this response. #[serde(rename="requestId")] - pub request_id: String, + pub request_id: Option<String>, } impl Part for TripOptionsResponse {} @@ -688,9 +688,9 @@ impl Part for TripOptionsResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FlightInfo { /// no description provided - pub carrier: String, + pub carrier: Option<String>, /// The flight number. - pub number: String, + pub number: Option<String>, } impl Part for FlightInfo {} @@ -721,33 +721,33 @@ impl RequestValue for TripsSearchRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct SliceInput { /// Airport or city IATA designator of the origin. - pub origin: String, + pub origin: Option<String>, /// Identifies this as a slice input object, representing the criteria a desired slice must satisfy. Value: the fixed string qpxexpress#sliceInput. - pub kind: String, + pub kind: Option<String>, /// Slices with only the carriers in this alliance should be returned; do not use this field with permittedCarrier. Allowed values are ONEWORLD, SKYTEAM, and STAR. - pub alliance: String, + pub alliance: Option<String>, /// Departure date in YYYY-MM-DD format. - pub date: String, + pub date: Option<String>, /// Airport or city IATA designator of the destination. - pub destination: String, + pub destination: Option<String>, /// The maximum number of stops you are willing to accept in this slice. #[serde(rename="maxStops")] - pub max_stops: i32, + pub max_stops: Option<i32>, /// Slices must depart in this time of day range, local to the point of departure. #[serde(rename="permittedDepartureTime")] - pub permitted_departure_time: TimeOfDayRange, + pub permitted_departure_time: Option<TimeOfDayRange>, /// A list of 2-letter IATA airline designators. Slices with only these carriers should be returned. #[serde(rename="permittedCarrier")] - pub permitted_carrier: Vec<String>, + pub permitted_carrier: Option<Vec<String>>, /// The longest connection between two legs, in minutes, you are willing to accept. #[serde(rename="maxConnectionDuration")] - pub max_connection_duration: i32, + pub max_connection_duration: Option<i32>, /// Prefer solutions that book in this cabin for this slice. Allowed values are COACH, PREMIUM_COACH, BUSINESS, and FIRST. #[serde(rename="preferredCabin")] - pub preferred_cabin: String, + pub preferred_cabin: Option<String>, /// A list of 2-letter IATA airline designators. Exclude slices that use these carriers. #[serde(rename="prohibitedCarrier")] - pub prohibited_carrier: Vec<String>, + pub prohibited_carrier: Option<Vec<String>>, } impl Part for SliceInput {} @@ -765,9 +765,9 @@ impl Part for SliceInput {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TripsSearchResponse { /// Identifies this as a QPX Express API search response resource. Value: the fixed string qpxExpress#tripsSearch. - pub kind: String, + pub kind: Option<String>, /// All possible solutions to the QPX Express search request. - pub trips: TripOptionsResponse, + pub trips: Option<TripOptionsResponse>, } impl ResponseResult for TripsSearchResponse {} @@ -780,16 +780,16 @@ impl ResponseResult for TripsSearchResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BagDescriptor { /// How many of this type of bag will be checked on this flight. - pub count: i32, + pub count: Option<i32>, /// The standard IATA subcode used to identify this optional service. - pub subcode: String, + pub subcode: Option<String>, /// A description of the baggage. - pub description: Vec<String>, + pub description: Option<Vec<String>>, /// Identifies this as a baggage object. Value: the fixed string qpxexpress#bagDescriptor. - pub kind: String, + pub kind: Option<String>, /// Provides the commercial name for an optional service. #[serde(rename="commercialName")] - pub commercial_name: String, + pub commercial_name: Option<String>, } impl Part for BagDescriptor {} @@ -802,13 +802,13 @@ impl Part for BagDescriptor {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CityData { /// The two-character country code of the country the city is located in. For example, US for the United States of America. - pub country: String, + pub country: Option<String>, /// Identifies this as a city, typically with one or more airports. Value: the fixed string qpxexpress#cityData. - pub kind: String, + pub kind: Option<String>, /// The IATA character ID of a city. For example, for Boston this is BOS. - pub code: String, + pub code: Option<String>, /// The full name of a city. An example would be: New York. - pub name: String, + pub name: Option<String>, } impl Part for CityData {} @@ -823,11 +823,11 @@ impl Part for CityData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SliceInfo { /// The duration of the slice in minutes. - pub duration: i32, + pub duration: Option<i32>, /// Identifies this as a slice object. A slice represents a traveller's intent, the portion of a low-fare search corresponding to a traveler's request to get between two points. One-way journeys are generally expressed using 1 slice, round-trips using 2. Value: the fixed string qpxexpress#sliceInfo. - pub kind: String, + pub kind: Option<String>, /// The segment(s) constituting the slice. - pub segment: Vec<SegmentInfo>, + pub segment: Option<Vec<SegmentInfo>>, } impl Part for SliceInfo {} @@ -841,15 +841,15 @@ impl Part for SliceInfo {} pub struct TripOption { /// The total price for all passengers on the trip, in the form of a currency followed by an amount, e.g. USD253.35. #[serde(rename="saleTotal")] - pub sale_total: String, + pub sale_total: Option<String>, /// Identifies this as a trip information object. Value: the fixed string qpxexpress#tripOption. - pub kind: String, + pub kind: Option<String>, /// The slices that make up this trip's itinerary. - pub slice: Vec<SliceInfo>, + pub slice: Option<Vec<SliceInfo>>, /// Identifier uniquely identifying this trip in a response. - pub id: String, + pub id: Option<String>, /// Per passenger pricing information. - pub pricing: Vec<PricingInfo>, + pub pricing: Option<Vec<PricingInfo>>, } impl Part for TripOption {} @@ -862,17 +862,17 @@ impl Part for TripOption {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Data { /// The city that is either the origin or destination of part of a trip. - pub city: Vec<CityData>, + pub city: Option<Vec<CityData>>, /// Identifies this as QPX Express response resource, including a trip's airport, city, taxes, airline, and aircraft. Value: the fixed string qpxexpress#data. - pub kind: String, + pub kind: Option<String>, /// The airline carrier of the aircraft flying between an origin and destination. Allowed values are IATA carrier codes. - pub carrier: Vec<CarrierData>, + pub carrier: Option<Vec<CarrierData>>, /// The airport of an origin or destination. - pub airport: Vec<AirportData>, + pub airport: Option<Vec<AirportData>>, /// The taxes due for flying between an origin and a destination. - pub tax: Vec<TaxData>, + pub tax: Option<Vec<TaxData>>, /// The aircraft that is flying between an origin and destination. - pub aircraft: Vec<AircraftData>, + pub aircraft: Option<Vec<AircraftData>>, } impl Part for Data {} @@ -886,18 +886,18 @@ impl Part for Data {} pub struct FreeBaggageAllowance { /// The maximum number of kilos any one piece of baggage may weigh. #[serde(rename="kilosPerPiece")] - pub kilos_per_piece: i32, + pub kilos_per_piece: Option<i32>, /// A representation of a type of bag, such as an ATPCo subcode, Commercial Name, or other description. #[serde(rename="bagDescriptor")] - pub bag_descriptor: Vec<BagDescriptor>, + pub bag_descriptor: Option<Vec<BagDescriptor>>, /// The number of pounds of free baggage allowed. - pub pounds: i32, + pub pounds: Option<i32>, /// The number of free pieces of baggage allowed. - pub pieces: i32, + pub pieces: Option<i32>, /// Identifies this as free baggage object, allowed on one segment of a trip. Value: the fixed string qpxexpress#freeBaggageAllowance. - pub kind: String, + pub kind: Option<String>, /// The maximum number of kilos all the free baggage together may weigh. - pub kilos: i32, + pub kilos: Option<i32>, } impl Part for FreeBaggageAllowance {} @@ -998,7 +998,7 @@ impl<'a, C, A> TripMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TripsSearchRequest = Default::default(); +/// let mut req = TripsSearchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. diff --git a/gen/replicapool1_beta2-cli/Cargo.toml b/gen/replicapool1_beta2-cli/Cargo.toml index 78649da87a..817ea2e25c 100644 --- a/gen/replicapool1_beta2-cli/Cargo.toml +++ b/gen/replicapool1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-replicapool1_beta2-cli" version = "0.0.1+20150223" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/compute/docs/instance-groups/manager/v1beta2" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/replicapool1_beta2-cli/src/cmn.rs b/gen/replicapool1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/replicapool1_beta2-cli/src/cmn.rs +++ b/gen/replicapool1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/replicapool1_beta2-cli/src/main.rs b/gen/replicapool1_beta2-cli/src/main.rs index c445b47900..f637db53d0 100644 --- a/gen/replicapool1_beta2-cli/src/main.rs +++ b/gen/replicapool1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -43,6 +44,12 @@ Configuration: 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. "); mod cmn; @@ -64,10 +71,10 @@ 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::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -87,18 +94,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -117,8 +125,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -129,7 +136,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instance_group_managers().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -161,8 +168,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -171,10 +177,10 @@ impl Engine { fn _instance_group_managers_delete_instances(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstanceGroupManagersDeleteInstancesRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -194,18 +200,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -224,8 +231,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -236,7 +242,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instance_group_managers().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -268,8 +274,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -278,11 +283,11 @@ impl Engine { fn _instance_group_managers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstanceGroupManager = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -302,9 +307,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -320,9 +326,9 @@ impl Engine { }, "target-pools" => { if request.target_pools.is_none() { - request.target_pools = Some(Default::default()); + request.target_pools = Some(Default::default()); } - request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request.kind = Some(value.unwrap_or("").to_string()); @@ -368,8 +374,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -380,7 +385,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instance_group_managers().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -421,8 +426,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -431,10 +435,10 @@ impl Engine { fn _instance_group_managers_recreate_instances(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstanceGroupManagersRecreateInstancesRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -454,18 +458,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -484,8 +489,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -497,7 +501,7 @@ impl Engine { let size: i32 = arg_from_str(&self.opt.arg_size, err, "<size>", "integer"); let mut call = self.hub.instance_group_managers().resize(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_instance_group_manager, size); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -529,8 +533,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -539,10 +542,10 @@ 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::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -562,9 +565,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -589,8 +593,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -599,10 +602,10 @@ 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::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -622,18 +625,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.target_pools.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "fingerprint" => { request.fingerprint = Some(value.unwrap_or("").to_string()); @@ -655,8 +659,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -667,7 +670,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_operations().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -699,8 +702,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -711,7 +713,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_operations().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -752,8 +754,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -789,7 +790,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zone_operations { + } + else if self.opt.cmd_zone_operations { if self.opt.cmd_get { call_result = self._zone_operations_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -817,21 +819,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "replicapool1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "replicapool1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "replicapool1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "replicapool1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Replicapool::new(hyper::Client::new(), auth), + hub: api::Replicapool::new(client, auth), }; match engine._doit(true) { @@ -851,12 +869,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 e389d548a4..2e42468337 100644 --- a/gen/replicapool1_beta2/Cargo.toml +++ b/gen/replicapool1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-replicapool1_beta2" version = "0.1.5+20150223" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/compute/docs/instance-groups/manager/v1beta2" diff --git a/gen/replicapool1_beta2/src/cmn.rs b/gen/replicapool1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/replicapool1_beta2/src/cmn.rs +++ b/gen/replicapool1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/replicapool1_beta2/src/lib.rs b/gen/replicapool1_beta2/src/lib.rs index 7dc942bde9..bc27b757a7 100644 --- a/gen/replicapool1_beta2/src/lib.rs +++ b/gen/replicapool1_beta2/src/lib.rs @@ -355,9 +355,9 @@ impl<'a, C, A> Replicapool<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// [Output Only] Metadata key for this warning. - pub key: String, + pub key: Option<String>, /// [Output Only] Metadata value for this warning. - pub value: String, + pub value: Option<String>, } impl NestedType for OperationWarningsData {} @@ -390,11 +390,11 @@ impl RequestValue for InstanceGroupManagersRecreateInstancesRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// [Output only] Optional human-readable details for this warning. - pub message: String, + pub message: Option<String>, /// [Output only] The warning type identifier for this warning. - pub code: String, + pub code: Option<String>, /// [Output only] Metadata for this warning in key:value format. - pub data: Vec<OperationWarningsData>, + pub data: Option<Vec<OperationWarningsData>>, } impl NestedType for OperationWarnings {} @@ -414,16 +414,16 @@ impl Part for OperationWarnings {} pub struct OperationList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The operation resources. - pub items: Vec<Operation>, + pub items: Option<Vec<Operation>>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option<String>, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for OperationList {} @@ -455,11 +455,11 @@ impl RequestValue for InstanceGroupManagersSetInstanceTemplateRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// [Output Only] The error type identifier for this error. - pub code: String, + pub code: Option<String>, /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub location: Option<String>, } impl NestedType for OperationErrorErrors {} @@ -479,16 +479,16 @@ impl Part for OperationErrorErrors {} pub struct InstanceGroupManagerList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of instance resources. - pub items: Vec<InstanceGroupManager>, + pub items: Option<Vec<InstanceGroupManager>>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option<String>, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for InstanceGroupManagerList {} @@ -501,7 +501,7 @@ impl ResponseResult for InstanceGroupManagerList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec<OperationErrorErrors>, + pub errors: Option<Vec<OperationErrorErrors>>, } impl NestedType for OperationError {} @@ -648,61 +648,61 @@ impl RequestValue for InstanceGroupManagersDeleteInstancesRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// [Output Only] Status of the operation. - pub status: String, + pub status: Option<String>, /// [Output Only] The time that this operation was requested, in RFC3339 text format. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option<String>, /// [Output Only] If there are issues with this operation, a warning is returned. - pub warnings: Vec<OperationWarnings>, + pub warnings: Option<Vec<OperationWarnings>>, /// [Output Only] If errors occurred during processing of this operation, this field will be populated. - pub error: OperationError, + pub error: Option<OperationError>, /// [Output Only] Unique target ID which identifies a particular incarnation of the target. #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option<String>, /// [Output only] URL of the resource the operation is mutating. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option<String>, /// [Output Only] The time that this operation was started by the server, in RFC3339 text format. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// [Output only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project. #[serde(rename="clientOperationId")] - pub client_operation_id: String, + pub client_operation_id: Option<String>, /// [Output Only] The time that this operation was requested, in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option<String>, /// [Output Only] Unique identifier for the resource, generated by the server. - pub id: String, + pub id: Option<String>, /// [Output only] Type of the resource. - pub kind: String, + pub kind: Option<String>, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option<String>, /// [Output Only] URL of the zone where the operation resides. Only available when performing per-zone operations. - pub zone: String, + pub zone: Option<String>, /// [Output Only] URL of the region where the operation resides. Only available when performing regional operations. - pub region: String, + pub region: Option<String>, /// [Output Only] Server-defined fully-qualified URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// [Output only] Type of the operation. Operations include insert, update, and delete. #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option<String>, /// [Output only] If operation fails, the HTTP error message returned. #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option<String>, /// [Output only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses. - pub progress: i32, + pub progress: Option<i32>, /// [Output Only] The time that this operation was completed, in RFC3339 text format. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// [Output only] If operation fails, the HTTP error status code returned. #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option<i32>, /// [Output Only] An optional textual description of the current status of the operation. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option<String>, /// [Output Only] User who requested the operation, for example: user@example.com. - pub user: String, + pub user: Option<String>, } impl ResponseResult for Operation {} @@ -1194,16 +1194,20 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1459,16 +1463,20 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1628,7 +1636,7 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManagersSetTargetPoolsRequest = Default::default(); +/// let mut req = InstanceGroupManagersSetTargetPoolsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1724,16 +1732,20 @@ impl<'a, C, A> InstanceGroupManagerSetTargetPoolCall<'a, C, A> where C: BorrowMu loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2004,16 +2016,20 @@ impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2184,7 +2200,7 @@ impl<'a, C, A> InstanceGroupManagerListCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManager = Default::default(); +/// let mut req = InstanceGroupManager::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2280,16 +2296,20 @@ impl<'a, C, A> InstanceGroupManagerInsertCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2547,16 +2567,20 @@ impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2716,7 +2740,7 @@ impl<'a, C, A> InstanceGroupManagerGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManagersAbandonInstancesRequest = Default::default(); +/// let mut req = InstanceGroupManagersAbandonInstancesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2812,16 +2836,20 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2994,7 +3022,7 @@ impl<'a, C, A> InstanceGroupManagerAbandonInstanceCall<'a, C, A> where C: Borrow /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManagersRecreateInstancesRequest = Default::default(); +/// let mut req = InstanceGroupManagersRecreateInstancesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3090,16 +3118,20 @@ impl<'a, C, A> InstanceGroupManagerRecreateInstanceCall<'a, C, A> where C: Borro loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3357,16 +3389,20 @@ impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3526,7 +3562,7 @@ impl<'a, C, A> InstanceGroupManagerDeleteCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManagersSetInstanceTemplateRequest = Default::default(); +/// let mut req = InstanceGroupManagersSetInstanceTemplateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3622,16 +3658,20 @@ impl<'a, C, A> InstanceGroupManagerSetInstanceTemplateCall<'a, C, A> where C: Bo loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3891,16 +3931,20 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4070,7 +4114,7 @@ impl<'a, C, A> InstanceGroupManagerResizeCall<'a, C, A> where C: BorrowMut<hyper /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstanceGroupManagersDeleteInstancesRequest = Default::default(); +/// let mut req = InstanceGroupManagersDeleteInstancesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4166,16 +4210,20 @@ impl<'a, C, A> InstanceGroupManagerDeleteInstanceCall<'a, C, A> where C: BorrowM loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/replicapoolupdater1_beta1-cli/Cargo.toml b/gen/replicapoolupdater1_beta1-cli/Cargo.toml index 6516a9b4a2..91ce5a15a8 100644 --- a/gen/replicapoolupdater1_beta1-cli/Cargo.toml +++ b/gen/replicapoolupdater1_beta1-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-replicapoolupdater1_beta1-cli" -version = "0.0.1+20150129" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_service" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/replicapoolupdater1_beta1-cli/mkdocs.yml b/gen/replicapoolupdater1_beta1-cli/mkdocs.yml index 9756774547..9f30932897 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+20150129 +site_name: replicapoolupdater v0.0.1+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 fd8d66fa4c..a8d3f46368 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/cmn.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/replicapoolupdater1_beta1-cli/src/main.rs b/gen/replicapoolupdater1_beta1-cli/src/main.rs index 34bd00f546..a22325cb18 100644 --- a/gen/replicapoolupdater1_beta1-cli/src/main.rs +++ b/gen/replicapoolupdater1_beta1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -40,6 +41,12 @@ Configuration: 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. "); mod cmn; @@ -63,7 +70,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().cancel(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -95,8 +102,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -107,7 +113,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -139,8 +145,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -149,10 +154,10 @@ impl Engine { fn _rolling_updates_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::RollingUpdate = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -172,9 +177,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -200,12 +206,6 @@ impl Engine { "instance-group" => { request.instance_group = Some(value.unwrap_or("").to_string()); }, - "instances" => { - if request.instances.is_none() { - request.instances = Some(Default::default()); - } - request.instances.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, "instance-template" => { request.instance_template = Some(value.unwrap_or("").to_string()); }, @@ -218,29 +218,25 @@ impl Engine { "instance-group-manager" => { request.instance_group_manager = Some(value.unwrap_or("").to_string()); }, + "policy.auto-pause-after-instances" => { + request_policy_init(&mut request); + request.policy.as_mut().unwrap().auto_pause_after_instances = Some(arg_from_str(value.unwrap_or("-0"), err, "policy.auto-pause-after-instances", "integer")); + }, "policy.instance-startup-timeout-sec" => { request_policy_init(&mut request); - request.policy.as_mut().unwrap().instance_startup_timeout_sec = arg_from_str(value.unwrap_or("-0"), err, "policy.instance-startup-timeout-sec", "integer"); + request.policy.as_mut().unwrap().instance_startup_timeout_sec = Some(arg_from_str(value.unwrap_or("-0"), err, "policy.instance-startup-timeout-sec", "integer")); }, "policy.max-num-concurrent-instances" => { request_policy_init(&mut request); - request.policy.as_mut().unwrap().max_num_concurrent_instances = arg_from_str(value.unwrap_or("-0"), err, "policy.max-num-concurrent-instances", "integer"); + request.policy.as_mut().unwrap().max_num_concurrent_instances = Some(arg_from_str(value.unwrap_or("-0"), err, "policy.max-num-concurrent-instances", "integer")); }, "policy.min-instance-update-time-sec" => { request_policy_init(&mut request); - request.policy.as_mut().unwrap().min_instance_update_time_sec = arg_from_str(value.unwrap_or("-0"), err, "policy.min-instance-update-time-sec", "integer"); - }, - "policy.sleep-after-instance-restart-sec" => { - request_policy_init(&mut request); - request.policy.as_mut().unwrap().sleep_after_instance_restart_sec = arg_from_str(value.unwrap_or("-0"), err, "policy.sleep-after-instance-restart-sec", "integer"); + request.policy.as_mut().unwrap().min_instance_update_time_sec = Some(arg_from_str(value.unwrap_or("-0"), err, "policy.min-instance-update-time-sec", "integer")); }, "policy.max-num-failed-instances" => { request_policy_init(&mut request); - request.policy.as_mut().unwrap().max_num_failed_instances = arg_from_str(value.unwrap_or("-0"), err, "policy.max-num-failed-instances", "integer"); - }, - "policy.auto-pause-after-instances" => { - request_policy_init(&mut request); - request.policy.as_mut().unwrap().auto_pause_after_instances = arg_from_str(value.unwrap_or("-0"), err, "policy.auto-pause-after-instances", "integer"); + request.policy.as_mut().unwrap().max_num_failed_instances = Some(arg_from_str(value.unwrap_or("-0"), err, "policy.max-num-failed-instances", "integer")); }, "progress" => { request_policy_init(&mut request); @@ -275,8 +271,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -287,7 +282,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -331,8 +326,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -343,7 +337,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().list_instance_updates(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -384,8 +378,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -396,7 +389,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().pause(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -428,8 +421,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -440,7 +432,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().resume(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -472,8 +464,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -484,7 +475,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.rolling_updates().rollback(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_rolling_update); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -516,8 +507,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -528,7 +518,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_operations().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -560,8 +550,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -593,7 +582,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zone_operations { + } + else if self.opt.cmd_zone_operations { if self.opt.cmd_get { call_result = self._zone_operations_get(dry_run, &mut err); } else { @@ -619,21 +609,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "replicapoolupdater1-beta1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "replicapoolupdater1-beta1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "replicapoolupdater1-beta1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "replicapoolupdater1-beta1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Replicapoolupdater::new(hyper::Client::new(), auth), + hub: api::Replicapoolupdater::new(client, auth), }; match engine._doit(true) { @@ -653,12 +659,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 4a27c17ccd..799599e452 100644 --- a/gen/replicapoolupdater1_beta1/Cargo.toml +++ b/gen/replicapoolupdater1_beta1/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-replicapoolupdater1_beta1" -version = "0.1.5+20150129" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_service" diff --git a/gen/replicapoolupdater1_beta1/README.md b/gen/replicapoolupdater1_beta1/README.md index 4f1d9aa9b2..f5535b8a46 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+20150129*, where *20150129* 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.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*. 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). diff --git a/gen/replicapoolupdater1_beta1/src/cmn.rs b/gen/replicapoolupdater1_beta1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/replicapoolupdater1_beta1/src/cmn.rs +++ b/gen/replicapoolupdater1_beta1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/replicapoolupdater1_beta1/src/lib.rs b/gen/replicapoolupdater1_beta1/src/lib.rs index 508ddd8baf..5361afed9b 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+20150129*, where *20150129* 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.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*. //! //! 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). @@ -362,11 +362,11 @@ pub struct InstanceUpdate { /// - "ROLLED_OUT": The instance update is finished, the instance is running the new template. /// - "ROLLED_BACK": The instance update is finished, the instance has been reverted to the previous template. /// - "CANCELLED": The instance update is paused and no longer can be resumed, undefined in which template the instance is running. - pub status: String, + pub status: Option<String>, /// URL of the instance being updated. - pub instance: String, + pub instance: Option<String>, /// Errors that occurred during the instance update. - pub error: InstanceUpdateError, + pub error: Option<InstanceUpdateError>, } impl Part for InstanceUpdate {} @@ -385,14 +385,14 @@ impl Part for InstanceUpdate {} pub struct InstanceUpdateList { /// A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Collection of requested instance updates. - pub items: Vec<InstanceUpdate>, + pub items: Option<Vec<InstanceUpdate>>, /// [Output Only] Type of the resource. - pub kind: String, + pub kind: Option<String>, /// [Output Only] The fully qualified URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for InstanceUpdateList {} @@ -405,9 +405,9 @@ impl ResponseResult for InstanceUpdateList {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// [Output Only] Metadata key for this warning. - pub key: String, + pub key: Option<String>, /// [Output Only] Metadata value for this warning. - pub value: String, + pub value: Option<String>, } impl NestedType for OperationWarningsData {} @@ -421,7 +421,7 @@ impl Part for OperationWarningsData {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstanceUpdateError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec<InstanceUpdateErrorErrors>, + pub errors: Option<Vec<InstanceUpdateErrorErrors>>, } impl NestedType for InstanceUpdateError {} @@ -454,41 +454,39 @@ pub struct RollingUpdate { /// - "ROLLED_BACK": The update is finished, all instances have been reverted to the previous template. /// - "CANCELLED": The update is paused and no longer can be resumed, undefined how many instances are running in which template. pub status: Option<String>, + /// [Output Only] The fully qualified URL for the resource. + #[serde(rename="selfLink")] + pub self_link: Option<String>, + /// [Output Only] Type of the resource. + pub kind: Option<String>, /// An optional textual description of the resource; provided by the client when the resource is created. pub description: Option<String>, - /// Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set. + /// Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager and instanceGroup must be set. #[serde(rename="instanceGroup")] pub instance_group: Option<String>, - /// List of fully-qualified URLs of instances to be updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set. - pub instances: Option<Vec<String>>, /// Fully-qualified URL of an instance template to apply. #[serde(rename="instanceTemplate")] pub instance_template: Option<String>, - /// Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups and explicit lists of instances. + /// Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups. #[serde(rename="actionType")] pub action_type: Option<String>, /// [Output Only] User who requested the update, for example: user@example.com. pub user: Option<String>, - /// [Output Only] Creation timestamp in RFC3339 text format. - #[serde(rename="creationTimestamp")] - pub creation_timestamp: Option<String>, - /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: Option<String>, - /// [Output Only] Type of the resource. - pub kind: Option<String>, - /// [Output Only] The fully qualified URL for the resource. - #[serde(rename="selfLink")] - pub self_link: Option<String>, - /// [Output Only] Errors that occurred during rolling update. + /// [Output Only] Errors that occurred during the rolling update. pub error: Option<RollingUpdateError>, /// Parameters of the update process. pub policy: Option<RollingUpdatePolicy>, /// [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the update will be complete. This number should be monotonically increasing as the update progresses. pub progress: Option<i32>, + /// [Output Only] Creation timestamp in RFC3339 text format. + #[serde(rename="creationTimestamp")] + pub creation_timestamp: Option<String>, + /// [Output Only] Unique identifier for the resource; defined by the server. + pub id: Option<String>, /// [Output Only] An optional textual description of the current status of the update. #[serde(rename="statusMessage")] pub status_message: Option<String>, - /// Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set. + /// Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager and instanceGroup must be set. #[serde(rename="instanceGroupManager")] pub instance_group_manager: Option<String>, } @@ -505,11 +503,11 @@ impl ResponseResult for RollingUpdate {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RollingUpdateErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// [Output Only] The error type identifier for this error. - pub code: String, - /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub code: Option<String>, + /// [Output Only] Indicates the field in the request that caused the error. This property is optional. + pub location: Option<String>, } impl NestedType for RollingUpdateErrorErrors {} @@ -522,24 +520,21 @@ impl Part for RollingUpdateErrorErrors {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RollingUpdatePolicy { - /// Time period after the instance has been restarted but before marking the update of this instance as done. This field is deprecated and ignored by Rolling Updater. - #[serde(rename="sleepAfterInstanceRestartSec")] - pub sleep_after_instance_restart_sec: i32, - /// Maximum amount of time we will wait after finishing all steps until we receive HEALTHY state for instance. If this deadline is exceeded instance update is considered as failed. - #[serde(rename="instanceStartupTimeoutSec")] - pub instance_startup_timeout_sec: i32, - /// Maximum number of instances that can be updated simultaneously (concurrently). An update of an instance starts when the instance is about to be restarted and finishes after the instance has been restarted and the sleep period (defined by sleepAfterInstanceRestartSec) has passed. - #[serde(rename="maxNumConcurrentInstances")] - pub max_num_concurrent_instances: i32, - /// Specifies minimum amount of time we will spend on updating single instance, measuring at the start of the first update action (e.g. Recreate call on Instance Group Manager or Stop call on Instance resource). If actual instance update takes less time we will simply sleep before proceeding with next instance. - #[serde(rename="minInstanceUpdateTimeSec")] - pub min_instance_update_time_sec: i32, - /// Number of instances updated before the update gets automatically paused. + /// Number of instances to update before the updater pauses the rolling update. #[serde(rename="autoPauseAfterInstances")] - pub auto_pause_after_instances: i32, - /// Maximum number of instance updates that can fail without failing the group update. Instance update is considered failed if any of it's update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if after finishing all update actions this instance is in UNHEALTHY state. + pub auto_pause_after_instances: Option<i32>, + /// The maximum amount of time that the updater waits for a HEALTHY state after all of the update steps are complete. If the HEALTHY state is not received before the deadline, the instance update is considered a failure. + #[serde(rename="instanceStartupTimeoutSec")] + pub instance_startup_timeout_sec: Option<i32>, + /// The maximum number of instances that can be updated simultaneously. An instance update is considered complete only after the instance is restarted and initialized. + #[serde(rename="maxNumConcurrentInstances")] + pub max_num_concurrent_instances: Option<i32>, + /// The minimum amount of time that the updater spends to update each instance. Update time is the time it takes to complete all update actions (e.g. Stop call on Instance resource in Rolling Reboot), reboot, and initialize. If the instance update finishes early, the updater pauses for the remainder of the time before it starts the next instance update. + #[serde(rename="minInstanceUpdateTimeSec")] + pub min_instance_update_time_sec: Option<i32>, + /// The maximum number of instance updates that can fail before the group update is considered a failure. An instance update is considered failed if any of its update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if the instance is in an UNHEALTHY state after it finishes all of the update actions. #[serde(rename="maxNumFailedInstances")] - pub max_num_failed_instances: i32, + pub max_num_failed_instances: Option<i32>, } impl NestedType for RollingUpdatePolicy {} @@ -553,11 +548,11 @@ impl Part for RollingUpdatePolicy {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// [Output Only] The error type identifier for this error. - pub code: String, - /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub code: Option<String>, + /// [Output Only] Indicates the field in the request that caused the error. This property is optional. + pub location: Option<String>, } impl NestedType for OperationErrorErrors {} @@ -571,11 +566,11 @@ impl Part for OperationErrorErrors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InstanceUpdateErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// [Output Only] The error type identifier for this error. - pub code: String, - /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub code: Option<String>, + /// [Output Only] Indicates the field in the request that caused the error. This property is optional. + pub location: Option<String>, } impl NestedType for InstanceUpdateErrorErrors {} @@ -589,7 +584,7 @@ impl Part for InstanceUpdateErrorErrors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec<OperationErrorErrors>, + pub errors: Option<Vec<OperationErrorErrors>>, } impl NestedType for OperationError {} @@ -603,11 +598,11 @@ impl Part for OperationError {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// [Output only] Optional human-readable details for this warning. - pub message: String, + pub message: Option<String>, /// [Output only] The warning type identifier for this warning. - pub code: String, + pub code: Option<String>, /// [Output only] Metadata for this warning in key:value format. - pub data: Vec<OperationWarningsData>, + pub data: Option<Vec<OperationWarningsData>>, } impl NestedType for OperationWarnings {} @@ -631,74 +626,74 @@ impl Part for OperationWarnings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// [Output Only] Status of the operation. Can be one of the following: "PENDING", "RUNNING", or "DONE". - pub status: String, + pub status: Option<String>, /// [Output Only] The time that this operation was requested. This is in RFC 3339 format. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option<String>, /// no description provided - pub warnings: Vec<OperationWarnings>, + pub warnings: Option<Vec<OperationWarnings>>, /// [Output Only] If errors occurred during processing of this operation, this field will be populated. - pub error: OperationError, + pub error: Option<OperationError>, /// [Output Only] Unique target id which identifies a particular incarnation of the target. #[serde(rename="targetId")] - pub target_id: String, - /// [Output Only] URL of the resource the operation is mutating (output only). + pub target_id: Option<String>, + /// [Output Only] URL of the resource the operation is mutating. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option<String>, /// [Output Only] The time that this operation was started by the server. This is in RFC 3339 format. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// no description provided #[serde(rename="clientOperationId")] - pub client_operation_id: String, - /// [Output Only] Creation timestamp in RFC3339 text format (output only). + pub client_operation_id: Option<String>, + /// [Output Only] Creation timestamp in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option<String>, /// [Output Only] Unique identifier for the resource; defined by the server. - pub id: String, + pub id: Option<String>, /// [Output Only] Type of the resource. Always kind#operation for Operation resources. - pub kind: String, - /// [Output Only] Name of the resource (output only). - pub name: String, - /// [Output Only] URL of the zone where the operation resides (output only). - pub zone: String, - /// [Output Only] URL of the region where the operation resides (output only). - pub region: String, + pub kind: Option<String>, + /// [Output Only] Name of the resource. + pub name: Option<String>, + /// [Output Only] URL of the zone where the operation resides. + pub zone: Option<String>, + /// [Output Only] URL of the region where the operation resides. + pub region: Option<String>, /// [Output Only] Server defined URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// no description provided #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option<String>, /// no description provided #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option<String>, /// no description provided - pub progress: i32, + pub progress: Option<i32>, /// no description provided #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// no description provided #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option<i32>, /// [Output Only] An optional textual description of the current status of the operation. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option<String>, /// no description provided - pub user: String, + pub user: Option<String>, } impl ResponseResult for Operation {} -/// [Output Only] Errors that occurred during rolling update. +/// [Output Only] Errors that occurred during the rolling update. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RollingUpdateError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec<RollingUpdateErrorErrors>, + pub errors: Option<Vec<RollingUpdateErrorErrors>>, } impl NestedType for RollingUpdateError {} @@ -718,14 +713,14 @@ impl Part for RollingUpdateError {} pub struct RollingUpdateList { /// A token used to continue a truncated list request. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Collection of requested updates. - pub items: Vec<RollingUpdate>, + pub items: Option<Vec<RollingUpdate>>, /// [Output Only] Type of the resource. - pub kind: String, + pub kind: Option<String>, /// [Output Only] The fully qualified URL for the resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for RollingUpdateList {} @@ -1130,16 +1125,20 @@ impl<'a, C, A> RollingUpdatePauseCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1384,16 +1383,20 @@ impl<'a, C, A> RollingUpdateRollbackCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1638,16 +1641,20 @@ impl<'a, C, A> RollingUpdateGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1892,16 +1899,20 @@ impl<'a, C, A> RollingUpdateResumeCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2164,16 +2175,20 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2258,7 +2273,7 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> self._max_results = Some(new_value); self } - /// The name of the instance group manager used for filtering. + /// The name of the instance group manager. Use this parameter to return only updates to instances that are part of a specific instance group. /// /// Sets the *instance group manager* query property to the given value. pub fn instance_group_manager(mut self, new_value: &str) -> RollingUpdateListCall<'a, C, A> { @@ -2351,7 +2366,7 @@ impl<'a, C, A> RollingUpdateListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RollingUpdate = Default::default(); +/// let mut req = RollingUpdate::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2445,16 +2460,20 @@ impl<'a, C, A> RollingUpdateInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2717,16 +2736,20 @@ impl<'a, C, A> RollingUpdateListInstanceUpdateCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2992,16 +3015,20 @@ impl<'a, C, A> RollingUpdateCancelCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3246,16 +3273,20 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/reseller1_sandbox-cli/Cargo.toml b/gen/reseller1_sandbox-cli/Cargo.toml deleted file mode 100644 index 49e015fd64..0000000000 --- a/gen/reseller1_sandbox-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-reseller1_sandbox-cli" -version = "0.0.1+20141112" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with reseller (protocol v1sandbox)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox-cli" -homepage = "https://developers.google.com/google-apps/reseller/" -documentation = "http://byron.github.io/google-apis-rs/google_reseller1_sandbox_cli" -license = "MIT" -keywords = ["reseller", "google", "cli"] - -[[bin]] -name = "reseller1-sandbox" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-reseller1_sandbox] -path = "../reseller1_sandbox" diff --git a/gen/reseller1_sandbox-cli/LICENSE.md b/gen/reseller1_sandbox-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/reseller1_sandbox-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/reseller1_sandbox-cli/README.md b/gen/reseller1_sandbox-cli/README.md deleted file mode 100644 index 9039e1ee49..0000000000 --- a/gen/reseller1_sandbox-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO RESELLER:V1SANDBOX - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/reseller1_sandbox-cli/mkdocs.yml b/gen/reseller1_sandbox-cli/mkdocs.yml deleted file mode 100644 index a19e710f66..0000000000 --- a/gen/reseller1_sandbox-cli/mkdocs.yml +++ /dev/null @@ -1,30 +0,0 @@ -site_name: reseller v0.0.1+20141112 -site_url: http://byron.github.io/google-apis-rs/google-reseller1_sandbox-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/reseller1_sandbox-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['customers_get.md', 'Customers', 'Get'] -- ['customers_insert.md', 'Customers', 'Insert'] -- ['customers_patch.md', 'Customers', 'Patch'] -- ['customers_update.md', 'Customers', 'Update'] -- ['subscriptions_activate.md', 'Subscriptions', 'Activate'] -- ['subscriptions_change-plan.md', 'Subscriptions', 'Change Plan'] -- ['subscriptions_change-renewal-settings.md', 'Subscriptions', 'Change Renewal Settings'] -- ['subscriptions_change-seats.md', 'Subscriptions', 'Change Seats'] -- ['subscriptions_delete.md', 'Subscriptions', 'Delete'] -- ['subscriptions_get.md', 'Subscriptions', 'Get'] -- ['subscriptions_insert.md', 'Subscriptions', 'Insert'] -- ['subscriptions_list.md', 'Subscriptions', 'List'] -- ['subscriptions_start-paid-service.md', 'Subscriptions', 'Start Paid Service'] -- ['subscriptions_suspend.md', 'Subscriptions', 'Suspend'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/reseller1_sandbox-cli/src/cmn.rs b/gen/reseller1_sandbox-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/reseller1_sandbox-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/reseller1_sandbox-cli/src/main.rs b/gen/reseller1_sandbox-cli/src/main.rs deleted file mode 100644 index d02ba364a4..0000000000 --- a/gen/reseller1_sandbox-cli/src/main.rs +++ /dev/null @@ -1,1265 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_reseller1_sandbox as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Reseller<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _customers_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.customers().get(&self.opt.arg_customer_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customers_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Customer = Default::default(); - let mut call = self.hub.customers().insert(&request); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "postal-address.organization-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().organization_name = value.unwrap_or("").to_string(); - }, - "postal-address.country-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().country_code = value.unwrap_or("").to_string(); - }, - "postal-address.locality" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().locality = value.unwrap_or("").to_string(); - }, - "postal-address.region" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().region = value.unwrap_or("").to_string(); - }, - "postal-address.address-line2" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line2 = value.unwrap_or("").to_string(); - }, - "postal-address.address-line3" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line3 = value.unwrap_or("").to_string(); - }, - "postal-address.contact-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().contact_name = value.unwrap_or("").to_string(); - }, - "postal-address.address-line1" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line1 = value.unwrap_or("").to_string(); - }, - "postal-address.postal-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().postal_code = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Customer = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "postal-address.organization-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().organization_name = value.unwrap_or("").to_string(); - }, - "postal-address.country-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().country_code = value.unwrap_or("").to_string(); - }, - "postal-address.locality" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().locality = value.unwrap_or("").to_string(); - }, - "postal-address.region" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().region = value.unwrap_or("").to_string(); - }, - "postal-address.address-line2" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line2 = value.unwrap_or("").to_string(); - }, - "postal-address.address-line3" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line3 = value.unwrap_or("").to_string(); - }, - "postal-address.contact-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().contact_name = value.unwrap_or("").to_string(); - }, - "postal-address.address-line1" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line1 = value.unwrap_or("").to_string(); - }, - "postal-address.postal-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().postal_code = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _customers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Customer = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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 = value.unwrap_or("").to_string(); - }, - "postal-address.organization-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().organization_name = value.unwrap_or("").to_string(); - }, - "postal-address.country-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().country_code = value.unwrap_or("").to_string(); - }, - "postal-address.locality" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().locality = value.unwrap_or("").to_string(); - }, - "postal-address.region" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().region = value.unwrap_or("").to_string(); - }, - "postal-address.address-line2" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line2 = value.unwrap_or("").to_string(); - }, - "postal-address.address-line3" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line3 = value.unwrap_or("").to_string(); - }, - "postal-address.contact-name" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().contact_name = value.unwrap_or("").to_string(); - }, - "postal-address.address-line1" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().address_line1 = value.unwrap_or("").to_string(); - }, - "postal-address.postal-code" => { - request_postal_address_init(&mut request); - request.postal_address.as_mut().unwrap().postal_code = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_activate(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().activate(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_change_plan(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::ChangePlanRequest = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_seats_init(request: &mut api::ChangePlanRequest) { - if request.seats.is_none() { - request.seats = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "plan-name" => { - request.plan_name = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request.kind = Some(value.unwrap_or("").to_string()); - }, - "seats.kind" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "seats.number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.number-of-seats", "integer")); - }, - "seats.maximum-number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().maximum_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.maximum-number-of-seats", "integer")); - }, - "seats.licensed-number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().licensed_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.licensed-number-of-seats", "integer")); - }, - "purchase-order-id" => { - request_seats_init(&mut request); - request.purchase_order_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_change_renewal_settings(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::RenewalSettings = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_change_seats(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Seats = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().delete(&self.opt.arg_customer_id, &self.opt.arg_subscription_id, &self.opt.arg_deletion_type); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _subscriptions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Subscription = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_plan_init(request: &mut api::Subscription) { - if request.plan.is_none() { - request.plan = Some(Default::default()); - } - } - - fn request_renewal_settings_init(request: &mut api::Subscription) { - if request.renewal_settings.is_none() { - request.renewal_settings = Some(Default::default()); - } - } - - fn request_seats_init(request: &mut api::Subscription) { - if request.seats.is_none() { - request.seats = Some(Default::default()); - } - } - - fn request_transfer_info_init(request: &mut api::Subscription) { - if request.transfer_info.is_none() { - request.transfer_info = Some(Default::default()); - } - } - - fn request_trial_settings_init(request: &mut api::Subscription) { - if request.trial_settings.is_none() { - request.trial_settings = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "renewal-settings.kind" => { - request_renewal_settings_init(&mut request); - request.renewal_settings.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "renewal-settings.renewal-type" => { - request_renewal_settings_init(&mut request); - request.renewal_settings.as_mut().unwrap().renewal_type = Some(value.unwrap_or("").to_string()); - }, - "sku-id" => { - request_renewal_settings_init(&mut request); - request.sku_id = Some(value.unwrap_or("").to_string()); - }, - "kind" => { - request_renewal_settings_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); - }, - "trial-settings.trial-end-time" => { - request_trial_settings_init(&mut request); - request.trial_settings.as_mut().unwrap().trial_end_time = value.unwrap_or("").to_string(); - }, - "trial-settings.is-in-trial" => { - request_trial_settings_init(&mut request); - request.trial_settings.as_mut().unwrap().is_in_trial = arg_from_str(value.unwrap_or("false"), err, "trial-settings.is-in-trial", "boolean"); - }, - "transfer-info.transferability-expiration-time" => { - request_transfer_info_init(&mut request); - request.transfer_info.as_mut().unwrap().transferability_expiration_time = value.unwrap_or("").to_string(); - }, - "transfer-info.minimum-transferable-seats" => { - request_transfer_info_init(&mut request); - request.transfer_info.as_mut().unwrap().minimum_transferable_seats = arg_from_str(value.unwrap_or("-0"), err, "transfer-info.minimum-transferable-seats", "integer"); - }, - "resource-ui-url" => { - request_transfer_info_init(&mut request); - request.resource_ui_url = Some(value.unwrap_or("").to_string()); - }, - "seats.kind" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); - }, - "seats.number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.number-of-seats", "integer")); - }, - "seats.maximum-number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().maximum_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.maximum-number-of-seats", "integer")); - }, - "seats.licensed-number-of-seats" => { - request_seats_init(&mut request); - request.seats.as_mut().unwrap().licensed_number_of_seats = Some(arg_from_str(value.unwrap_or("-0"), err, "seats.licensed-number-of-seats", "integer")); - }, - "creation-time" => { - request_seats_init(&mut request); - request.creation_time = Some(value.unwrap_or("").to_string()); - }, - "status" => { - request_seats_init(&mut request); - request.status = Some(value.unwrap_or("").to_string()); - }, - "plan.plan-name" => { - request_plan_init(&mut request); - request.plan.as_mut().unwrap().plan_name = value.unwrap_or("").to_string(); - }, - "plan.commitment-interval.end-time" => { - request_plan_init(&mut request); - request.plan.as_mut().unwrap().commitment_interval.end_time = value.unwrap_or("").to_string(); - }, - "plan.commitment-interval.start-time" => { - request_plan_init(&mut request); - request.plan.as_mut().unwrap().commitment_interval.start_time = value.unwrap_or("").to_string(); - }, - "plan.is-commitment-plan" => { - request_plan_init(&mut request); - request.plan.as_mut().unwrap().is_commitment_plan = arg_from_str(value.unwrap_or("false"), err, "plan.is-commitment-plan", "boolean"); - }, - "purchase-order-id" => { - request_plan_init(&mut request); - request.purchase_order_id = Some(value.unwrap_or("").to_string()); - }, - "subscription-id" => { - request_plan_init(&mut request); - request.subscription_id = Some(value.unwrap_or("").to_string()); - }, - "billing-method" => { - request_plan_init(&mut request); - request.billing_method = Some(value.unwrap_or("").to_string()); - }, - "customer-id" => { - request_plan_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "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")); - }, - "customer-name-prefix" => { - call = call.customer_name_prefix(value.unwrap_or("")); - }, - "customer-id" => { - call = call.customer_id(value.unwrap_or("")); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_start_paid_service(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().start_paid_service(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _subscriptions_suspend(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.subscriptions().suspend(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_customers { - if self.opt.cmd_get { - call_result = self._customers_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._customers_insert(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._customers_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._customers_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_subscriptions { - if self.opt.cmd_activate { - call_result = self._subscriptions_activate(dry_run, &mut err); - } else if self.opt.cmd_change_plan { - call_result = self._subscriptions_change_plan(dry_run, &mut err); - } else if self.opt.cmd_change_renewal_settings { - call_result = self._subscriptions_change_renewal_settings(dry_run, &mut err); - } else if self.opt.cmd_change_seats { - call_result = self._subscriptions_change_seats(dry_run, &mut err); - } else if self.opt.cmd_delete { - call_result = self._subscriptions_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._subscriptions_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._subscriptions_insert(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._subscriptions_list(dry_run, &mut err); - } else if self.opt.cmd_start_paid_service { - call_result = self._subscriptions_start_paid_service(dry_run, &mut err); - } else if self.opt.cmd_suspend { - call_result = self._subscriptions_suspend(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "reseller1-sandbox-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "reseller1-sandbox", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Reseller::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/reseller1_sandbox/Cargo.toml b/gen/reseller1_sandbox/Cargo.toml index 4cb8b7960e..1ae491fe48 100644 --- a/gen/reseller1_sandbox/Cargo.toml +++ b/gen/reseller1_sandbox/Cargo.toml @@ -5,7 +5,7 @@ name = "google-reseller1_sandbox" version = "0.1.5+20141112" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/reseller/" diff --git a/gen/reseller1_sandbox/src/cmn.rs b/gen/reseller1_sandbox/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/reseller1_sandbox/src/cmn.rs +++ b/gen/reseller1_sandbox/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/reseller1_sandbox/src/lib.rs b/gen/reseller1_sandbox/src/lib.rs index ef39e7df54..71e4c54c94 100644 --- a/gen/reseller1_sandbox/src/lib.rs +++ b/gen/reseller1_sandbox/src/lib.rs @@ -445,10 +445,10 @@ impl RequestValue for Seats {} pub struct SubscriptionTransferInfo { /// Time when transfer token or intent to transfer will expire. #[serde(rename="transferabilityExpirationTime")] - pub transferability_expiration_time: String, + pub transferability_expiration_time: Option<String>, /// no description provided #[serde(rename="minimumTransferableSeats")] - pub minimum_transferable_seats: i32, + pub minimum_transferable_seats: Option<i32>, } impl NestedType for SubscriptionTransferInfo {} @@ -463,10 +463,10 @@ impl Part for SubscriptionTransferInfo {} pub struct SubscriptionPlanCommitmentInterval { /// End time of the commitment interval in milliseconds since Unix epoch. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// Start time of the commitment interval in milliseconds since Unix epoch. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, } impl NestedType for SubscriptionPlanCommitmentInterval {} @@ -486,11 +486,11 @@ impl Part for SubscriptionPlanCommitmentInterval {} pub struct Subscriptions { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies the resource as a collection of subscriptions. - pub kind: String, + pub kind: Option<String>, /// The subscriptions in this page of results. - pub subscriptions: Vec<Subscription>, + pub subscriptions: Option<Vec<Subscription>>, } impl ResponseResult for Subscriptions {} @@ -530,10 +530,10 @@ impl RequestValue for ChangePlanRequest {} pub struct SubscriptionTrialSettings { /// End time of the trial in milliseconds since Unix epoch. #[serde(rename="trialEndTime")] - pub trial_end_time: String, + pub trial_end_time: Option<String>, /// Whether the subscription is in trial. #[serde(rename="isInTrial")] - pub is_in_trial: bool, + pub is_in_trial: Option<bool>, } impl NestedType for SubscriptionTrialSettings {} @@ -548,13 +548,13 @@ impl Part for SubscriptionTrialSettings {} pub struct SubscriptionPlan { /// The plan name of this subscription's plan. #[serde(rename="planName")] - pub plan_name: String, + pub plan_name: Option<String>, /// Interval of the commitment if it is a commitment plan. #[serde(rename="commitmentInterval")] - pub commitment_interval: SubscriptionPlanCommitmentInterval, + pub commitment_interval: Option<SubscriptionPlanCommitmentInterval>, /// Whether the plan is a commitment plan or not. #[serde(rename="isCommitmentPlan")] - pub is_commitment_plan: bool, + pub is_commitment_plan: Option<bool>, } impl NestedType for SubscriptionPlan {} @@ -568,32 +568,32 @@ impl Part for SubscriptionPlan {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Address { /// Identifies the resource as a customer address. - pub kind: String, + pub kind: Option<String>, /// Name of the organization. #[serde(rename="organizationName")] - pub organization_name: String, + pub organization_name: Option<String>, /// ISO 3166 country code. #[serde(rename="countryCode")] - pub country_code: String, + pub country_code: Option<String>, /// Name of the locality. This is in accordance with - http://portablecontacts.net/draft-spec.html#address_element. - pub locality: String, + pub locality: Option<String>, /// Name of the region. This is in accordance with - http://portablecontacts.net/draft-spec.html#address_element. - pub region: String, + pub region: Option<String>, /// Address line 2 of the address. #[serde(rename="addressLine2")] - pub address_line2: String, + pub address_line2: Option<String>, /// Address line 3 of the address. #[serde(rename="addressLine3")] - pub address_line3: String, + pub address_line3: Option<String>, /// Name of the contact person. #[serde(rename="contactName")] - pub contact_name: String, + pub contact_name: Option<String>, /// Address line 1 of the address. #[serde(rename="addressLine1")] - pub address_line1: String, + pub address_line1: Option<String>, /// The postal code. This is in accordance with - http://portablecontacts.net/draft-spec.html#address_element. #[serde(rename="postalCode")] - pub postal_code: String, + pub postal_code: Option<String>, } impl Part for Address {} @@ -1054,7 +1054,7 @@ impl<'a, C, A> SubscriptionMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Customer = Default::default(); +/// let mut req = Customer::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1146,16 +1146,20 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1308,7 +1312,7 @@ impl<'a, C, A> CustomerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Customer = Default::default(); +/// let mut req = Customer::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1379,16 +1383,20 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1538,7 +1546,7 @@ impl<'a, C, A> CustomerInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Customer = Default::default(); +/// let mut req = Customer::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1630,16 +1638,20 @@ impl<'a, C, A> CustomerPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1873,16 +1885,20 @@ impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2022,7 +2038,7 @@ impl<'a, C, A> CustomerGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subscription = Default::default(); +/// let mut req = Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2119,16 +2135,20 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2372,16 +2392,20 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2614,16 +2638,20 @@ impl<'a, C, A> SubscriptionGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2853,16 +2881,20 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3027,7 +3059,7 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: RenewalSettings = Default::default(); +/// let mut req = RenewalSettings::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3121,16 +3153,20 @@ impl<'a, C, A> SubscriptionChangeRenewalSettingCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3376,16 +3412,20 @@ impl<'a, C, A> SubscriptionStartPaidServiceCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3535,7 +3575,7 @@ impl<'a, C, A> SubscriptionStartPaidServiceCall<'a, C, A> where C: BorrowMut<hyp /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Seats = Default::default(); +/// let mut req = Seats::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3629,16 +3669,20 @@ impl<'a, C, A> SubscriptionChangeSeatCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3884,16 +3928,20 @@ impl<'a, C, A> SubscriptionSuspendCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4126,16 +4174,20 @@ impl<'a, C, A> SubscriptionActivateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4285,7 +4337,7 @@ impl<'a, C, A> SubscriptionActivateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChangePlanRequest = Default::default(); +/// let mut req = ChangePlanRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4379,16 +4431,20 @@ impl<'a, C, A> SubscriptionChangePlanCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/resourceviews1_beta2-cli/Cargo.toml b/gen/resourceviews1_beta2-cli/Cargo.toml index 5a4ad3ac28..7375b1d4b8 100644 --- a/gen/resourceviews1_beta2-cli/Cargo.toml +++ b/gen/resourceviews1_beta2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-resourceviews1_beta2-cli" version = "0.0.1+20150302" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/compute/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/resourceviews1_beta2-cli/src/cmn.rs b/gen/resourceviews1_beta2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/resourceviews1_beta2-cli/src/cmn.rs +++ b/gen/resourceviews1_beta2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/resourceviews1_beta2-cli/src/main.rs b/gen/resourceviews1_beta2-cli/src/main.rs index e28a309d1a..233e550386 100644 --- a/gen/resourceviews1_beta2-cli/src/main.rs +++ b/gen/resourceviews1_beta2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -42,6 +43,12 @@ Configuration: 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. "); mod cmn; @@ -65,7 +72,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_operations().get(&self.opt.arg_project, &self.opt.arg_zone, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -97,8 +104,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -109,7 +115,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_operations().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -150,8 +156,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -160,10 +165,10 @@ impl Engine { fn _zone_views_add_resources(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ZoneViewsAddResourcesRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -183,18 +188,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -213,8 +219,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -225,7 +230,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_views().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -257,8 +262,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -269,7 +273,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_views().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -301,8 +305,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -313,7 +316,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_views().get_service(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "resource-name" => { call = call.resource_name(value.unwrap_or("")); @@ -348,8 +351,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -358,10 +360,10 @@ impl Engine { fn _zone_views_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ResourceView = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -381,9 +383,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -414,9 +417,9 @@ impl Engine { }, "resources" => { if request.resources.is_none() { - request.resources = Some(Default::default()); + request.resources = Some(Default::default()); } - request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); @@ -438,8 +441,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -450,7 +452,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_views().list(&self.opt.arg_project, &self.opt.arg_zone); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -488,8 +490,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -500,7 +501,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.zone_views().list_resources(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "service-name" => { call = call.service_name(value.unwrap_or("")); @@ -547,8 +548,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -557,10 +557,10 @@ impl Engine { fn _zone_views_remove_resources(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ZoneViewsRemoveResourcesRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -580,18 +580,19 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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 = Some(Default::default()); } - request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.resources.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -610,8 +611,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -620,10 +620,10 @@ impl Engine { fn _zone_views_set_service(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ZoneViewsSetServiceRequest = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -643,9 +643,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -673,8 +674,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -694,7 +694,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_zone_views { + } + else if self.opt.cmd_zone_views { if self.opt.cmd_add_resources { call_result = self._zone_views_add_resources(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -736,21 +737,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "resourceviews1-beta2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "resourceviews1-beta2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "resourceviews1-beta2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "resourceviews1-beta2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Resourceviews::new(hyper::Client::new(), auth), + hub: api::Resourceviews::new(client, auth), }; match engine._doit(true) { @@ -770,12 +787,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 8c89ecfe3b..235673471f 100644 --- a/gen/resourceviews1_beta2/Cargo.toml +++ b/gen/resourceviews1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-resourceviews1_beta2" version = "0.1.5+20150302" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/compute/" diff --git a/gen/resourceviews1_beta2/README.md b/gen/resourceviews1_beta2/README.md index adbe212e51..ba40b120eb 100644 --- a/gen/resourceviews1_beta2/README.md +++ b/gen/resourceviews1_beta2/README.md @@ -100,7 +100,7 @@ let mut hub = Resourceviews::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: ZoneViewsRemoveResourcesRequest = Default::default(); +let mut req = ZoneViewsRemoveResourcesRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/resourceviews1_beta2/src/cmn.rs b/gen/resourceviews1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/resourceviews1_beta2/src/cmn.rs +++ b/gen/resourceviews1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/resourceviews1_beta2/src/lib.rs b/gen/resourceviews1_beta2/src/lib.rs index 03d56f74ef..e9e4119d48 100644 --- a/gen/resourceviews1_beta2/src/lib.rs +++ b/gen/resourceviews1_beta2/src/lib.rs @@ -101,7 +101,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: ZoneViewsRemoveResourcesRequest = Default::default(); +//! let mut req = ZoneViewsRemoveResourcesRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -292,7 +292,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ZoneViewsRemoveResourcesRequest = Default::default(); +/// let mut req = ZoneViewsRemoveResourcesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -371,11 +371,11 @@ impl<'a, C, A> Resourceviews<C, A> pub struct ZoneViewsListResourcesResponse { /// A token used for pagination. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The formatted JSON that is requested by the user. - pub items: Vec<ListResourceResponseItem>, + pub items: Option<Vec<ListResourceResponseItem>>, /// The URL of a Compute Engine network to which the resources in the view belong. - pub network: String, + pub network: Option<String>, } impl ResponseResult for ZoneViewsListResourcesResponse {} @@ -394,14 +394,14 @@ impl ResponseResult for ZoneViewsListResourcesResponse {} pub struct ZoneViewsList { /// A token used for pagination. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The result that contains all resource views that meet the criteria. - pub items: Vec<ResourceView>, + pub items: Option<Vec<ResourceView>>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for ZoneViewsList {} @@ -450,11 +450,11 @@ impl RequestValue for ZoneViewsAddResourcesRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarnings { /// [Output only] Optional human-readable details for this warning. - pub message: String, + pub message: Option<String>, /// [Output only] The warning type identifier for this warning. - pub code: String, + pub code: Option<String>, /// [Output only] Metadata for this warning in key:value format. - pub data: Vec<OperationWarningsData>, + pub data: Option<Vec<OperationWarningsData>>, } impl NestedType for OperationWarnings {} @@ -474,16 +474,16 @@ impl Part for OperationWarnings {} pub struct OperationList { /// A token used to continue a truncated list request (output only). #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The operation resources. - pub items: Vec<Operation>, + pub items: Option<Vec<Operation>>, /// Type of resource. - pub kind: String, + pub kind: Option<String>, /// Unique identifier for the resource; defined by the server (output only). - pub id: String, + pub id: Option<String>, /// Server defined URL for this resource (output only). #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl ResponseResult for OperationList {} @@ -540,9 +540,9 @@ impl ResponseResult for ResourceView {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListResourceResponseItem { /// The list of service end points on the resource. - pub endpoints: HashMap<String, Vec<i32>>, + pub endpoints: Option<HashMap<String, Vec<i32>>>, /// The full URL of the resource. - pub resource: String, + pub resource: Option<String>, } impl Part for ListResourceResponseItem {} @@ -555,11 +555,11 @@ impl Part for ListResourceResponseItem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationErrorErrors { /// [Output Only] An optional, human-readable error message. - pub message: String, + pub message: Option<String>, /// [Output Only] The error type identifier for this error. - pub code: String, + pub code: Option<String>, /// [Output Only] Indicates the field in the request which caused the error. This property is optional. - pub location: String, + pub location: Option<String>, } impl NestedType for OperationErrorErrors {} @@ -573,9 +573,9 @@ impl Part for OperationErrorErrors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Label { /// Key of the label. - pub key: String, + pub key: Option<String>, /// Value of the label. - pub value: String, + pub value: Option<String>, } impl Part for Label {} @@ -588,7 +588,7 @@ impl Part for Label {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// [Output Only] The array of errors encountered while processing this operation. - pub errors: Vec<OperationErrorErrors>, + pub errors: Option<Vec<OperationErrorErrors>>, } impl NestedType for OperationError {} @@ -630,9 +630,9 @@ impl RequestValue for ZoneViewsSetServiceRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ZoneViewsGetServiceResponse { /// The service information. - pub endpoints: Vec<ServiceEndpoint>, + pub endpoints: Option<Vec<ServiceEndpoint>>, /// The fingerprint of the service information. - pub fingerprint: String, + pub fingerprint: Option<String>, } impl ResponseResult for ZoneViewsGetServiceResponse {} @@ -655,61 +655,61 @@ impl ResponseResult for ZoneViewsGetServiceResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// [Output Only] Status of the operation. - pub status: String, + pub status: Option<String>, /// [Output Only] The time that this operation was requested, in RFC3339 text format. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option<String>, /// [Output Only] If there are issues with this operation, a warning is returned. - pub warnings: Vec<OperationWarnings>, + pub warnings: Option<Vec<OperationWarnings>>, /// [Output Only] If errors occurred during processing of this operation, this field will be populated. - pub error: OperationError, + pub error: Option<OperationError>, /// [Output Only] Unique target ID which identifies a particular incarnation of the target. #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option<String>, /// [Output only] URL of the resource the operation is mutating. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option<String>, /// [Output Only] The time that this operation was started by the server, in RFC3339 text format. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// [Output only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project. #[serde(rename="clientOperationId")] - pub client_operation_id: String, + pub client_operation_id: Option<String>, /// [Output Only] The time that this operation was requested, in RFC3339 text format. #[serde(rename="creationTimestamp")] - pub creation_timestamp: String, + pub creation_timestamp: Option<String>, /// [Output Only] Unique identifier for the resource, generated by the server. - pub id: String, + pub id: Option<String>, /// [Output only] Type of the resource. - pub kind: String, + pub kind: Option<String>, /// [Output Only] Name of the resource. - pub name: String, + pub name: Option<String>, /// [Output Only] URL of the zone where the operation resides. Only available when performing per-zone operations. - pub zone: String, + pub zone: Option<String>, /// [Output Only] URL of the region where the operation resides. Only available when performing regional operations. - pub region: String, + pub region: Option<String>, /// [Output Only] Server-defined fully-qualified URL for this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// [Output only] Type of the operation. Operations include insert, update, and delete. #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option<String>, /// [Output only] If operation fails, the HTTP error message returned. #[serde(rename="httpErrorMessage")] - pub http_error_message: String, + pub http_error_message: Option<String>, /// [Output only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses. - pub progress: i32, + pub progress: Option<i32>, /// [Output Only] The time that this operation was completed, in RFC3339 text format. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// [Output only] If operation fails, the HTTP error status code returned. #[serde(rename="httpErrorStatusCode")] - pub http_error_status_code: i32, + pub http_error_status_code: Option<i32>, /// [Output Only] An optional textual description of the current status of the operation. #[serde(rename="statusMessage")] - pub status_message: String, + pub status_message: Option<String>, /// [Output Only] User who requested the operation, for example: user@example.com. - pub user: String, + pub user: Option<String>, } impl ResponseResult for Operation {} @@ -722,9 +722,9 @@ impl ResponseResult for Operation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ServiceEndpoint { /// The name of the service endpoint. - pub name: String, + pub name: Option<String>, /// The port of the service endpoint. - pub port: i32, + pub port: Option<i32>, } impl Part for ServiceEndpoint {} @@ -737,9 +737,9 @@ impl Part for ServiceEndpoint {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationWarningsData { /// [Output Only] Metadata key for this warning. - pub key: String, + pub key: Option<String>, /// [Output Only] Metadata value for this warning. - pub value: String, + pub value: Option<String>, } impl NestedType for OperationWarningsData {} @@ -1110,7 +1110,7 @@ impl<'a, C, A> ZoneOperationMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ZoneViewsRemoveResourcesRequest = Default::default(); +/// let mut req = ZoneViewsRemoveResourcesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1206,16 +1206,20 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1388,7 +1392,7 @@ impl<'a, C, A> ZoneViewRemoveResourceCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ZoneViewsAddResourcesRequest = Default::default(); +/// let mut req = ZoneViewsAddResourcesRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1484,16 +1488,20 @@ impl<'a, C, A> ZoneViewAddResourceCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1776,16 +1784,20 @@ impl<'a, C, A> ZoneViewListResourceCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2065,16 +2077,20 @@ impl<'a, C, A> ZoneViewGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2327,16 +2343,20 @@ impl<'a, C, A> ZoneViewListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2500,7 +2520,7 @@ impl<'a, C, A> ZoneViewListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ResourceView = Default::default(); +/// let mut req = ResourceView::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2594,16 +2614,20 @@ impl<'a, C, A> ZoneViewInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2851,16 +2875,20 @@ impl<'a, C, A> ZoneViewDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3020,7 +3048,7 @@ impl<'a, C, A> ZoneViewDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ZoneViewsSetServiceRequest = Default::default(); +/// let mut req = ZoneViewsSetServiceRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3116,16 +3144,20 @@ impl<'a, C, A> ZoneViewSetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3388,16 +3420,20 @@ impl<'a, C, A> ZoneViewGetServiceCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -3649,16 +3685,20 @@ impl<'a, C, A> ZoneOperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3916,16 +3956,20 @@ impl<'a, C, A> ZoneOperationListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/siteverification1-cli/Cargo.toml b/gen/siteverification1-cli/Cargo.toml index 265f8182aa..b8bf7cfd93 100644 --- a/gen/siteverification1-cli/Cargo.toml +++ b/gen/siteverification1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-siteverification1-cli" version = "0.0.1+20131007" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/site-verification/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/siteverification1-cli/src/cmn.rs b/gen/siteverification1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/siteverification1-cli/src/cmn.rs +++ b/gen/siteverification1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/siteverification1-cli/src/main.rs b/gen/siteverification1-cli/src/main.rs index 144164985a..3cf95696f9 100644 --- a/gen/siteverification1-cli/src/main.rs +++ b/gen/siteverification1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -38,6 +39,12 @@ Configuration: 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. "); mod cmn; @@ -61,7 +68,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.web_resource().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -92,7 +99,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -103,7 +109,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.web_resource().get(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -135,8 +141,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -145,10 +150,10 @@ impl Engine { fn _web_resource_get_token(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SiteVerificationWebResourceGettokenRequest = Default::default(); + let mut request = api::SiteVerificationWebResourceGettokenRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -168,9 +173,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -186,11 +192,11 @@ impl Engine { }, "site.identifier" => { request_site_init(&mut request); - request.site.as_mut().unwrap().identifier = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -209,8 +215,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -219,10 +224,10 @@ impl Engine { fn _web_resource_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SiteVerificationWebResourceResource = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -242,9 +247,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -257,20 +263,20 @@ impl Engine { match &field_name.to_string()[..] { "owners" => { if request.owners.is_none() { - request.owners = Some(Default::default()); + request.owners = Some(Default::default()); } - request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -289,8 +295,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -301,7 +306,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.web_resource().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -333,8 +338,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -343,10 +347,10 @@ impl Engine { fn _web_resource_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SiteVerificationWebResourceResource = Default::default(); + let mut request = api::SiteVerificationWebResourceResource::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -366,9 +370,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -381,20 +386,20 @@ impl Engine { match &field_name.to_string()[..] { "owners" => { if request.owners.is_none() { - request.owners = Some(Default::default()); + request.owners = Some(Default::default()); } - request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -413,8 +418,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -423,10 +427,10 @@ impl Engine { fn _web_resource_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SiteVerificationWebResourceResource = Default::default(); + let mut request = api::SiteVerificationWebResourceResource::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -446,9 +450,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -461,20 +466,20 @@ impl Engine { match &field_name.to_string()[..] { "owners" => { if request.owners.is_none() { - request.owners = Some(Default::default()); + request.owners = Some(Default::default()); } - request.owners.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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 = value.unwrap_or("").to_string(); + 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_ = value.unwrap_or("").to_string(); + request.site.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, _ => { err.issues.push(CLIError::Field(FieldError::Unknown(field_name.to_string()))); @@ -493,8 +498,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -544,21 +548,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "siteverification1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "siteverification1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "siteverification1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "siteverification1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::SiteVerification::new(hyper::Client::new(), auth), + hub: api::SiteVerification::new(client, auth), }; match engine._doit(true) { @@ -578,12 +598,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/siteverification1/Cargo.toml b/gen/siteverification1/Cargo.toml index 2a87f151f5..10679347e6 100644 --- a/gen/siteverification1/Cargo.toml +++ b/gen/siteverification1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-siteverification1" version = "0.1.5+20131007" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/site-verification/" diff --git a/gen/siteverification1/README.md b/gen/siteverification1/README.md index 6637a877d7..fd9b31fbde 100644 --- a/gen/siteverification1/README.md +++ b/gen/siteverification1/README.md @@ -96,7 +96,7 @@ let mut hub = SiteVerification::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: SiteVerificationWebResourceResource = Default::default(); +let mut req = SiteVerificationWebResourceResource::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/siteverification1/src/cmn.rs b/gen/siteverification1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/siteverification1/src/cmn.rs +++ b/gen/siteverification1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/siteverification1/src/lib.rs b/gen/siteverification1/src/lib.rs index dfcacc4aa0..eeab0f9b26 100644 --- a/gen/siteverification1/src/lib.rs +++ b/gen/siteverification1/src/lib.rs @@ -97,7 +97,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: SiteVerificationWebResourceResource = Default::default(); +//! let mut req = SiteVerificationWebResourceResource::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -276,7 +276,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SiteVerificationWebResourceResource = Default::default(); +/// let mut req = SiteVerificationWebResourceResource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -351,7 +351,7 @@ impl<'a, C, A> SiteVerification<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteVerificationWebResourceListResponse { /// The list of sites that are owned by the authenticated user. - pub items: Vec<SiteVerificationWebResourceResource>, + pub items: Option<Vec<SiteVerificationWebResourceResource>>, } impl ResponseResult for SiteVerificationWebResourceListResponse {} @@ -364,10 +364,10 @@ impl ResponseResult for SiteVerificationWebResourceListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteVerificationWebResourceResourceSite { /// The site identifier. If the type is set to SITE, the identifier is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain name. - pub identifier: String, + pub identifier: Option<String>, /// The site type. Can be SITE or INET_DOMAIN (domain name). #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for SiteVerificationWebResourceResourceSite {} @@ -402,10 +402,10 @@ impl RequestValue for SiteVerificationWebResourceGettokenRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct SiteVerificationWebResourceGettokenRequestSite { /// The site identifier. If the type is set to SITE, the identifier is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain name. - pub identifier: String, + pub identifier: Option<String>, /// The type of resource to be verified. Can be SITE or INET_DOMAIN (domain name). #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for SiteVerificationWebResourceGettokenRequestSite {} @@ -450,9 +450,9 @@ impl ResponseResult for SiteVerificationWebResourceResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteVerificationWebResourceGettokenResponse { /// The verification token. The token must be placed appropriately in order for verification to succeed. - pub token: String, + pub token: Option<String>, /// The verification method to use in conjunction with this token. For FILE, the token should be placed in the top-level directory of the site, stored inside a file of the same name. For META, the token should be placed in the HEAD tag of the default page that is loaded for the site. For DNS, the token should be placed in a TXT record of the domain. - pub method: String, + pub method: Option<String>, } impl ResponseResult for SiteVerificationWebResourceGettokenResponse {} @@ -738,16 +738,20 @@ impl<'a, C, A> WebResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -887,7 +891,7 @@ impl<'a, C, A> WebResourceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SiteVerificationWebResourceResource = Default::default(); +/// let mut req = SiteVerificationWebResourceResource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -979,16 +983,20 @@ impl<'a, C, A> WebResourcePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1196,16 +1204,20 @@ impl<'a, C, A> WebResourceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1415,16 +1427,20 @@ impl<'a, C, A> WebResourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1554,7 +1570,7 @@ impl<'a, C, A> WebResourceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SiteVerificationWebResourceGettokenRequest = Default::default(); +/// let mut req = SiteVerificationWebResourceGettokenRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1620,16 +1636,20 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1772,7 +1792,7 @@ impl<'a, C, A> WebResourceGetTokenCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SiteVerificationWebResourceResource = Default::default(); +/// let mut req = SiteVerificationWebResourceResource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1864,16 +1884,20 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2026,7 +2050,7 @@ impl<'a, C, A> WebResourceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SiteVerificationWebResourceResource = Default::default(); +/// let mut req = SiteVerificationWebResourceResource::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2094,16 +2118,20 @@ impl<'a, C, A> WebResourceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/spectrum1_explorer-cli/Cargo.toml b/gen/spectrum1_explorer-cli/Cargo.toml index d9f9d6f572..fcd39aecb4 100644 --- a/gen/spectrum1_explorer-cli/Cargo.toml +++ b/gen/spectrum1_explorer-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-spectrum1_explorer-cli" version = "0.0.1+20150112" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/spectrum" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/spectrum1_explorer-cli/src/cmn.rs b/gen/spectrum1_explorer-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/spectrum1_explorer-cli/src/cmn.rs +++ b/gen/spectrum1_explorer-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/spectrum1_explorer-cli/src/main.rs b/gen/spectrum1_explorer-cli/src/main.rs index da0c3bc022..7d9e4eb4f6 100644 --- a/gen/spectrum1_explorer-cli/src/main.rs +++ b/gen/spectrum1_explorer-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -33,6 +34,12 @@ Configuration: 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. "); mod cmn; @@ -54,10 +61,10 @@ struct Engine { impl Engine { fn _paws_get_spectrum(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsGetSpectrumRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -77,9 +84,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -101,6 +109,20 @@ impl Engine { } } + fn request_location_point_center_init(request: &mut api::PawsGetSpectrumRequest) { + request_location_point_init(request); + if request.location.as_mut().unwrap().point.as_mut().unwrap().center.is_none() { + request.location.as_mut().unwrap().point.as_mut().unwrap().center = Some(Default::default()); + } + } + + fn request_location_point_init(request: &mut api::PawsGetSpectrumRequest) { + request_location_init(request); + if request.location.as_mut().unwrap().point.is_none() { + request.location.as_mut().unwrap().point = Some(Default::default()); + } + } + fn request_master_device_desc_init(request: &mut api::PawsGetSpectrumRequest) { if request.master_device_desc.is_none() { request.master_device_desc = Some(Default::default()); @@ -113,46 +135,119 @@ impl Engine { } } + fn request_owner_operator_adr_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_owner_operator_email_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().email.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_owner_operator_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_init(request); + if request.owner.as_mut().unwrap().operator.is_none() { + request.owner.as_mut().unwrap().operator = Some(Default::default()); + } + } + + fn request_owner_operator_org_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().org.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_owner_operator_tel_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel = Some(Default::default()); + } + } + + fn request_owner_owner_adr_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_owner_owner_email_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().email.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_owner_owner_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_init(request); + if request.owner.as_mut().unwrap().owner.is_none() { + request.owner.as_mut().unwrap().owner = Some(Default::default()); + } + } + + fn request_owner_owner_org_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().org.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_owner_owner_tel_init(request: &mut api::PawsGetSpectrumRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "device-desc.serial-number" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-technology-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-tvbd-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-category" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "device-desc.ruleset-ids" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-emissions-class" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "device-desc.manufacturer-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "device-desc.model-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "version" => { request_device_desc_init(&mut request); @@ -160,15 +255,15 @@ impl Engine { }, "antenna.height-type" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_type = value.unwrap_or("").to_string(); + request.antenna.as_mut().unwrap().height_type = Some(value.unwrap_or("").to_string()); }, "antenna.height-uncertainty" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_uncertainty = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number"); + request.antenna.as_mut().unwrap().height_uncertainty = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number")); }, "antenna.height" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number"); + request.antenna.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number")); }, "request-type" => { request_antenna_init(&mut request); @@ -176,147 +271,150 @@ impl Engine { }, "master-device-desc.etsi-en-device-type" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "master-device-desc.fcc-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.serial-number" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-technology-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.fcc-tvbd-device-type" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-device-category" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "master-device-desc.ruleset-ids" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.master_device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.master_device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.master_device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-device-emissions-class" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "master-device-desc.manufacturer-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.model-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "location.confidence" => { request_location_init(&mut request); - request.location.as_mut().unwrap().confidence = arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer"); + request.location.as_mut().unwrap().confidence = Some(arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer")); }, "location.point.semi-minor-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_minor_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number"); + request_location_point_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_minor_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number")); }, "location.point.center.latitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number")); }, "location.point.center.longitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number")); }, "location.point.semi-major-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_major_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_major_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number")); }, "location.point.orientation" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.orientation = arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().orientation = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number")); }, "owner.operator.org.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.org.text = value.unwrap_or("").to_string(); + request_owner_operator_org_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.operator.tel.uri" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.tel.uri = value.unwrap_or("").to_string(); + request_owner_operator_tel_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "owner.operator.email.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.email.text = value.unwrap_or("").to_string(); + request_owner_operator_email_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.operator.fn" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.fn_ = value.unwrap_or("").to_string(); + request_owner_operator_email_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.code" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.code = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.locality" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.locality = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.country" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.country = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.region" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.region = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.pobox" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.pobox = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.street" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.street = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "owner.owner.org.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.org.text = value.unwrap_or("").to_string(); + request_owner_owner_org_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.owner.tel.uri" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.tel.uri = value.unwrap_or("").to_string(); + request_owner_owner_tel_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "owner.owner.email.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.email.text = value.unwrap_or("").to_string(); + request_owner_owner_email_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.owner.fn" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.fn_ = value.unwrap_or("").to_string(); + request_owner_owner_email_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.code" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.code = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.locality" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.locality = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.country" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.country = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.region" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.region = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.pobox" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.pobox = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.street" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.street = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "type" => { request_owner_init(&mut request); @@ -339,8 +437,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -349,10 +446,10 @@ impl Engine { fn _paws_get_spectrum_batch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsGetSpectrumBatchRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -372,9 +469,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -402,46 +500,119 @@ impl Engine { } } + fn request_owner_operator_adr_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_owner_operator_email_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().email.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_owner_operator_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_init(request); + if request.owner.as_mut().unwrap().operator.is_none() { + request.owner.as_mut().unwrap().operator = Some(Default::default()); + } + } + + fn request_owner_operator_org_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().org.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_owner_operator_tel_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_operator_init(request); + if request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel.is_none() { + request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel = Some(Default::default()); + } + } + + fn request_owner_owner_adr_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_owner_owner_email_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().email.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_owner_owner_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_init(request); + if request.owner.as_mut().unwrap().owner.is_none() { + request.owner.as_mut().unwrap().owner = Some(Default::default()); + } + } + + fn request_owner_owner_org_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().org.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_owner_owner_tel_init(request: &mut api::PawsGetSpectrumBatchRequest) { + request_owner_owner_init(request); + if request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel.is_none() { + request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "device-desc.serial-number" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-technology-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-tvbd-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-category" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "device-desc.ruleset-ids" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-emissions-class" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "device-desc.manufacturer-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "device-desc.model-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "version" => { request_device_desc_init(&mut request); @@ -449,15 +620,15 @@ impl Engine { }, "antenna.height-type" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_type = value.unwrap_or("").to_string(); + request.antenna.as_mut().unwrap().height_type = Some(value.unwrap_or("").to_string()); }, "antenna.height-uncertainty" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_uncertainty = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number"); + request.antenna.as_mut().unwrap().height_uncertainty = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number")); }, "antenna.height" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number"); + request.antenna.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number")); }, "request-type" => { request_antenna_init(&mut request); @@ -465,123 +636,126 @@ impl Engine { }, "master-device-desc.etsi-en-device-type" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "master-device-desc.fcc-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.serial-number" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-technology-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.fcc-tvbd-device-type" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-device-category" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "master-device-desc.ruleset-ids" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.master_device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.master_device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.master_device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "master-device-desc.etsi-en-device-emissions-class" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "master-device-desc.manufacturer-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "master-device-desc.model-id" => { request_master_device_desc_init(&mut request); - request.master_device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.master_device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "owner.operator.org.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.org.text = value.unwrap_or("").to_string(); + request_owner_operator_org_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.operator.tel.uri" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.tel.uri = value.unwrap_or("").to_string(); + request_owner_operator_tel_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "owner.operator.email.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.email.text = value.unwrap_or("").to_string(); + request_owner_operator_email_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.operator.fn" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.fn_ = value.unwrap_or("").to_string(); + request_owner_operator_email_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.code" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.code = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.locality" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.locality = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.country" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.country = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.region" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.region = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.pobox" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.pobox = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "owner.operator.adr.street" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().operator.adr.street = value.unwrap_or("").to_string(); + request_owner_operator_adr_init(&mut request); + request.owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "owner.owner.org.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.org.text = value.unwrap_or("").to_string(); + request_owner_owner_org_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.owner.tel.uri" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.tel.uri = value.unwrap_or("").to_string(); + request_owner_owner_tel_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "owner.owner.email.text" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.email.text = value.unwrap_or("").to_string(); + request_owner_owner_email_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "owner.owner.fn" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.fn_ = value.unwrap_or("").to_string(); + request_owner_owner_email_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.code" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.code = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.locality" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.locality = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.country" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.country = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.region" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.region = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.pobox" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.pobox = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "owner.owner.adr.street" => { - request_owner_init(&mut request); - request.owner.as_mut().unwrap().owner.adr.street = value.unwrap_or("").to_string(); + request_owner_owner_adr_init(&mut request); + request.owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "type" => { request_owner_init(&mut request); @@ -604,8 +778,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -614,10 +787,10 @@ impl Engine { fn _paws_init(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsInitRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -637,9 +810,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -655,46 +829,63 @@ impl Engine { } } + fn request_location_point_center_init(request: &mut api::PawsInitRequest) { + request_location_point_init(request); + if request.location.as_mut().unwrap().point.as_mut().unwrap().center.is_none() { + request.location.as_mut().unwrap().point.as_mut().unwrap().center = Some(Default::default()); + } + } + + fn request_location_point_init(request: &mut api::PawsInitRequest) { + request_location_init(request); + if request.location.as_mut().unwrap().point.is_none() { + request.location.as_mut().unwrap().point = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "device-desc.serial-number" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-technology-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-tvbd-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-category" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "device-desc.ruleset-ids" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-emissions-class" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "device-desc.manufacturer-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "device-desc.model-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "type" => { request_device_desc_init(&mut request); @@ -702,27 +893,27 @@ impl Engine { }, "location.confidence" => { request_location_init(&mut request); - request.location.as_mut().unwrap().confidence = arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer"); + request.location.as_mut().unwrap().confidence = Some(arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer")); }, "location.point.semi-minor-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_minor_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number"); + request_location_point_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_minor_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number")); }, "location.point.center.latitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number")); }, "location.point.center.longitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number")); }, "location.point.semi-major-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_major_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_major_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number")); }, "location.point.orientation" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.orientation = arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().orientation = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number")); }, "version" => { request_location_init(&mut request); @@ -745,8 +936,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -755,10 +945,10 @@ impl Engine { fn _paws_notify_spectrum_use(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsNotifySpectrumUseRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -778,9 +968,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -796,46 +987,63 @@ impl Engine { } } + fn request_location_point_center_init(request: &mut api::PawsNotifySpectrumUseRequest) { + request_location_point_init(request); + if request.location.as_mut().unwrap().point.as_mut().unwrap().center.is_none() { + request.location.as_mut().unwrap().point.as_mut().unwrap().center = Some(Default::default()); + } + } + + fn request_location_point_init(request: &mut api::PawsNotifySpectrumUseRequest) { + request_location_init(request); + if request.location.as_mut().unwrap().point.is_none() { + request.location.as_mut().unwrap().point = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "device-desc.serial-number" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-technology-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-tvbd-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-category" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "device-desc.ruleset-ids" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-emissions-class" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "device-desc.manufacturer-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "device-desc.model-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "type" => { request_device_desc_init(&mut request); @@ -843,27 +1051,27 @@ impl Engine { }, "location.confidence" => { request_location_init(&mut request); - request.location.as_mut().unwrap().confidence = arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer"); + request.location.as_mut().unwrap().confidence = Some(arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer")); }, "location.point.semi-minor-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_minor_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number"); + request_location_point_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_minor_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number")); }, "location.point.center.latitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number")); }, "location.point.center.longitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number")); }, "location.point.semi-major-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_major_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_major_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number")); }, "location.point.orientation" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.orientation = arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().orientation = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number")); }, "version" => { request_location_init(&mut request); @@ -886,8 +1094,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -896,10 +1103,10 @@ impl Engine { fn _paws_register(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsRegisterRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -919,9 +1126,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -943,144 +1151,231 @@ impl Engine { } } + fn request_device_owner_operator_adr_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_operator_init(request); + if request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.is_none() { + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_device_owner_operator_email_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_operator_init(request); + if request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().email.is_none() { + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_device_owner_operator_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_init(request); + if request.device_owner.as_mut().unwrap().operator.is_none() { + request.device_owner.as_mut().unwrap().operator = Some(Default::default()); + } + } + + fn request_device_owner_operator_org_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_operator_init(request); + if request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().org.is_none() { + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_device_owner_operator_tel_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_operator_init(request); + if request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().tel.is_none() { + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().tel = Some(Default::default()); + } + } + + fn request_device_owner_owner_adr_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_owner_init(request); + if request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.is_none() { + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr = Some(Default::default()); + } + } + + fn request_device_owner_owner_email_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_owner_init(request); + if request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().email.is_none() { + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().email = Some(Default::default()); + } + } + + fn request_device_owner_owner_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_init(request); + if request.device_owner.as_mut().unwrap().owner.is_none() { + request.device_owner.as_mut().unwrap().owner = Some(Default::default()); + } + } + + fn request_device_owner_owner_org_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_owner_init(request); + if request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().org.is_none() { + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().org = Some(Default::default()); + } + } + + fn request_device_owner_owner_tel_init(request: &mut api::PawsRegisterRequest) { + request_device_owner_owner_init(request); + if request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().tel.is_none() { + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().tel = Some(Default::default()); + } + } + fn request_location_init(request: &mut api::PawsRegisterRequest) { if request.location.is_none() { request.location = Some(Default::default()); } } + fn request_location_point_center_init(request: &mut api::PawsRegisterRequest) { + request_location_point_init(request); + if request.location.as_mut().unwrap().point.as_mut().unwrap().center.is_none() { + request.location.as_mut().unwrap().point.as_mut().unwrap().center = Some(Default::default()); + } + } + + fn request_location_point_init(request: &mut api::PawsRegisterRequest) { + request_location_init(request); + if request.location.as_mut().unwrap().point.is_none() { + request.location.as_mut().unwrap().point = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "device-desc.etsi-en-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_id = Some(value.unwrap_or("").to_string()); }, "device-desc.serial-number" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().serial_number = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().serial_number = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-technology-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_technology_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_technology_id = Some(value.unwrap_or("").to_string()); }, "device-desc.fcc-tvbd-device-type" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().fcc_tvbd_device_type = Some(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-category" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_category = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_category = Some(value.unwrap_or("").to_string()); }, "device-desc.ruleset-ids" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().ruleset_ids.push(value.unwrap_or("").to_string()); + if request.device_desc.as_mut().unwrap().ruleset_ids.is_none() { + request.device_desc.as_mut().unwrap().ruleset_ids = Some(Default::default()); + } + request.device_desc.as_mut().unwrap().ruleset_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "device-desc.etsi-en-device-emissions-class" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().etsi_en_device_emissions_class = Some(value.unwrap_or("").to_string()); }, "device-desc.manufacturer-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().manufacturer_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().manufacturer_id = Some(value.unwrap_or("").to_string()); }, "device-desc.model-id" => { request_device_desc_init(&mut request); - request.device_desc.as_mut().unwrap().model_id = value.unwrap_or("").to_string(); + request.device_desc.as_mut().unwrap().model_id = Some(value.unwrap_or("").to_string()); }, "antenna.height-type" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_type = value.unwrap_or("").to_string(); + request.antenna.as_mut().unwrap().height_type = Some(value.unwrap_or("").to_string()); }, "antenna.height-uncertainty" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height_uncertainty = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number"); + request.antenna.as_mut().unwrap().height_uncertainty = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height-uncertainty", "number")); }, "antenna.height" => { request_antenna_init(&mut request); - request.antenna.as_mut().unwrap().height = arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number"); + request.antenna.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("0.0"), err, "antenna.height", "number")); }, "device-owner.operator.org.text" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.org.text = value.unwrap_or("").to_string(); + request_device_owner_operator_org_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.tel.uri" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.tel.uri = value.unwrap_or("").to_string(); + request_device_owner_operator_tel_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.email.text" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.email.text = value.unwrap_or("").to_string(); + request_device_owner_operator_email_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.fn" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.fn_ = value.unwrap_or("").to_string(); + request_device_owner_operator_email_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.code" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.code = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.locality" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.locality = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.country" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.country = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.region" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.region = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.pobox" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.pobox = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "device-owner.operator.adr.street" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().operator.adr.street = value.unwrap_or("").to_string(); + request_device_owner_operator_adr_init(&mut request); + request.device_owner.as_mut().unwrap().operator.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.org.text" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.org.text = value.unwrap_or("").to_string(); + request_device_owner_owner_org_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().org.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.tel.uri" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.tel.uri = value.unwrap_or("").to_string(); + request_device_owner_owner_tel_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().tel.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.email.text" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.email.text = value.unwrap_or("").to_string(); + request_device_owner_owner_email_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().email.as_mut().unwrap().text = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.fn" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.fn_ = value.unwrap_or("").to_string(); + request_device_owner_owner_email_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().fn_ = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.code" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.code = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().code = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.locality" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.locality = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().locality = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.country" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.country = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.region" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.region = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().region = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.pobox" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.pobox = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().pobox = Some(value.unwrap_or("").to_string()); }, "device-owner.owner.adr.street" => { - request_device_owner_init(&mut request); - request.device_owner.as_mut().unwrap().owner.adr.street = value.unwrap_or("").to_string(); + request_device_owner_owner_adr_init(&mut request); + request.device_owner.as_mut().unwrap().owner.as_mut().unwrap().adr.as_mut().unwrap().street = Some(value.unwrap_or("").to_string()); }, "version" => { request_device_owner_init(&mut request); @@ -1088,27 +1383,27 @@ impl Engine { }, "location.confidence" => { request_location_init(&mut request); - request.location.as_mut().unwrap().confidence = arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer"); + request.location.as_mut().unwrap().confidence = Some(arg_from_str(value.unwrap_or("-0"), err, "location.confidence", "integer")); }, "location.point.semi-minor-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_minor_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number"); + request_location_point_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_minor_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-minor-axis", "number")); }, "location.point.center.latitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.latitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.latitude", "number")); }, "location.point.center.longitude" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.center.longitude = arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().center.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.center.longitude", "number")); }, "location.point.semi-major-axis" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.semi_major_axis = arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().semi_major_axis = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.semi-major-axis", "number")); }, "location.point.orientation" => { - request_location_init(&mut request); - request.location.as_mut().unwrap().point.orientation = arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number"); + request_location_point_center_init(&mut request); + request.location.as_mut().unwrap().point.as_mut().unwrap().orientation = Some(arg_from_str(value.unwrap_or("0.0"), err, "location.point.orientation", "number")); }, "type" => { request_location_init(&mut request); @@ -1131,8 +1426,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1141,10 +1435,10 @@ impl Engine { fn _paws_verify_device(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PawsVerifyDeviceRequest = Default::default(); + let mut request = api::PawsVerifyDeviceRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1164,9 +1458,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1194,8 +1489,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1243,21 +1537,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "spectrum1-explorer-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "spectrum1-explorer-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "spectrum1-explorer", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "spectrum1-explorer", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Spectrum::new(hyper::Client::new(), auth), + hub: api::Spectrum::new(client, auth), }; match engine._doit(true) { @@ -1277,12 +1587,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 cfd5c78074..b402c2a01f 100644 --- a/gen/spectrum1_explorer/Cargo.toml +++ b/gen/spectrum1_explorer/Cargo.toml @@ -5,7 +5,7 @@ name = "google-spectrum1_explorer" version = "0.1.5+20150112" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/spectrum" diff --git a/gen/spectrum1_explorer/README.md b/gen/spectrum1_explorer/README.md index 31beb90fc0..5be3b49180 100644 --- a/gen/spectrum1_explorer/README.md +++ b/gen/spectrum1_explorer/README.md @@ -93,7 +93,7 @@ let mut hub = Spectrum::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: PawsGetSpectrumBatchRequest = Default::default(); +let mut req = PawsGetSpectrumBatchRequest::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/spectrum1_explorer/src/cmn.rs b/gen/spectrum1_explorer/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/spectrum1_explorer/src/cmn.rs +++ b/gen/spectrum1_explorer/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/spectrum1_explorer/src/lib.rs b/gen/spectrum1_explorer/src/lib.rs index 94753f28cc..20455de0b6 100644 --- a/gen/spectrum1_explorer/src/lib.rs +++ b/gen/spectrum1_explorer/src/lib.rs @@ -94,7 +94,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: PawsGetSpectrumBatchRequest = Default::default(); +//! let mut req = PawsGetSpectrumBatchRequest::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -247,7 +247,7 @@ pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsGetSpectrumBatchRequest = Default::default(); +/// let mut req = PawsGetSpectrumBatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -317,11 +317,11 @@ impl<'a, C, A> Spectrum<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoLocation { /// The location confidence level, as an integer percentage, may be required, depending on the regulatory domain. When the parameter is optional and not provided, its value is assumed to be 95. Valid values range from 0 to 99, since, in practice, 100-percent confidence is not achievable. The confidence value is meaningful only when geolocation refers to a point with uncertainty. - pub confidence: i32, + pub confidence: Option<i32>, /// If present, indicates that the geolocation represents a region. Database support for regions is optional. - pub region: GeoLocationPolygon, + pub region: Option<GeoLocationPolygon>, /// If present, indicates that the geolocation represents a point. Paradoxically, a point is parameterized using an ellipse, where the center represents the location of the point and the distances along the major and minor axes represent the uncertainty. The uncertainty values may be required, depending on the regulatory domain. - pub point: GeoLocationEllipse, + pub point: Option<GeoLocationEllipse>, } impl Part for GeoLocation {} @@ -334,15 +334,15 @@ impl Part for GeoLocation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoLocationEllipse { /// A required geo-spatial point representing the center of the ellipse. - pub center: GeoLocationPoint, + pub center: Option<GeoLocationPoint>, /// A floating-point number that expresses the location uncertainty along the minor axis of the ellipse. May be required by the regulatory domain. When the uncertainty is optional, the default value is 0. #[serde(rename="semiMinorAxis")] - pub semi_minor_axis: f64, + pub semi_minor_axis: Option<f64>, /// A floating-point number that expresses the orientation of the ellipse, representing the rotation, in degrees, of the semi-major axis from North towards the East. For example, when the uncertainty is greatest along the North-South direction, orientation is 0 degrees; conversely, if the uncertainty is greatest along the East-West direction, orientation is 90 degrees. When orientation is not present, the orientation is assumed to be 0. - pub orientation: f64, + pub orientation: Option<f64>, /// A floating-point number that expresses the location uncertainty along the major axis of the ellipse. May be required by the regulatory domain. When the uncertainty is optional, the default value is 0. #[serde(rename="semiMajorAxis")] - pub semi_major_axis: f64, + pub semi_major_axis: Option<f64>, } impl Part for GeoLocationEllipse {} @@ -355,7 +355,7 @@ impl Part for GeoLocationEllipse {} #[derive(Default, Clone, Debug, Serialize)] pub struct VcardTypedText { /// The text string associated with this item. For example, for an org field: ACME, inc. For an email field: smith@example.com. - pub text: String, + pub text: Option<String>, } impl Part for VcardTypedText {} @@ -409,9 +409,9 @@ impl RequestValue for PawsNotifySpectrumUseRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct DeviceOwner { /// The vCard contact information for the device operator is optional, but may be required by specific regulatory domains. - pub operator: Vcard, + pub operator: Option<Vcard>, /// The vCard contact information for the individual or business that owns the device is required. - pub owner: Vcard, + pub owner: Option<Vcard>, } impl Part for DeviceOwner {} @@ -427,10 +427,10 @@ impl Part for DeviceOwner {} pub struct EventTime { /// The exclusive end of the event. It will be present. #[serde(rename="stopTime")] - pub stop_time: String, + pub stop_time: Option<String>, /// The inclusive start of the event. It will be present. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, } impl Part for EventTime {} @@ -444,16 +444,16 @@ impl Part for EventTime {} pub struct FrequencyRange { /// The required inclusive start of the frequency range (in Hertz). #[serde(rename="startHz")] - pub start_hz: f64, + pub start_hz: Option<f64>, /// The database may include a channel identifier, when applicable. When it is included, the device should treat it as informative. The length of the identifier should not exceed 16 characters. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The required exclusive end of the frequency range (in Hertz). #[serde(rename="stopHz")] - pub stop_hz: f64, + pub stop_hz: Option<f64>, /// The maximum total power level (EIRP)—computed over the corresponding operating bandwidth—that is permitted within the frequency range. Depending on the context in which the frequency-range element appears, this value may be required. For example, it is required in the available-spectrum response, available-spectrum-batch response, and spectrum-use notification message, but it should not be present (it is not applicable) when the frequency range appears inside a device-capabilities message. #[serde(rename="maxPowerDBm")] - pub max_power_d_bm: f64, + pub max_power_d_bm: Option<f64>, } impl Part for FrequencyRange {} @@ -472,38 +472,38 @@ impl Part for FrequencyRange {} pub struct PawsGetSpectrumBatchResponse { /// The available spectrum batch response must contain a geo-spectrum schedule list, The list may be empty if spectrum is not available. The database may return more than one geo-spectrum schedule to represent future changes to the available spectrum. How far in advance a schedule may be provided depends upon the applicable regulatory domain. The database may return available spectrum for fewer geolocations than requested. The device must not make assumptions about the order of the entries in the list, and must use the geolocation value in each geo-spectrum schedule entry to match available spectrum to a location. #[serde(rename="geoSpectrumSchedules")] - pub geo_spectrum_schedules: Vec<GeoSpectrumSchedule>, + pub geo_spectrum_schedules: Option<Vec<GeoSpectrumSchedule>>, /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsGetSpectrumBatchResponse". - pub kind: String, + pub kind: Option<String>, /// The database must return in its available spectrum response the device descriptor information it received in the master device's available spectrum batch request. #[serde(rename="deviceDesc")] - pub device_desc: DeviceDescriptor, + pub device_desc: Option<DeviceDescriptor>, /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs. #[serde(rename="databaseChange")] - pub database_change: DbUpdateSpec, + pub database_change: Option<DbUpdateSpec>, /// The database may return a constraint on the allowed maximum total bandwidth (in Hertz), which does not need to be contiguous. A regulatory domain may require the database to return this parameter. When this parameter is present in the available spectrum batch response, the device must apply this constraint to its spectrum-selection logic to ensure that total bandwidth does not exceed this value. #[serde(rename="maxTotalBwHz")] - pub max_total_bw_hz: f64, + pub max_total_bw_hz: Option<f64>, /// The database may return a constraint on the allowed maximum contiguous bandwidth (in Hertz). A regulatory domain may require the database to return this parameter. When this parameter is present in the response, the device must apply this constraint to its spectrum-selection logic to ensure that no single block of spectrum has bandwidth that exceeds this value. #[serde(rename="maxContiguousBwHz")] - pub max_contiguous_bw_hz: f64, + pub max_contiguous_bw_hz: Option<f64>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// The database includes a timestamp of the form, YYYY-MM-DDThh:mm:ssZ (Internet timestamp format per RFC3339), in its available spectrum batch response. The timestamp should be used by the device as a reference for the start and stop times specified in the response spectrum schedules. - pub timestamp: String, + pub timestamp: Option<String>, /// The database should return ruleset information, which identifies the applicable regulatory authority and ruleset for the available spectrum batch response. If included, the device must use the corresponding ruleset to interpret the response. Values provided in the returned ruleset information, such as maxLocationChange, take precedence over any conflicting values provided in the ruleset information returned in a prior initialization response sent by the database to the device. #[serde(rename="rulesetInfo")] - pub ruleset_info: RulesetInfo, + pub ruleset_info: Option<RulesetInfo>, /// For regulatory domains that require a spectrum-usage report from devices, the database must return true for this parameter if the geo-spectrum schedules list is not empty; otherwise, the database should either return false or omit this parameter. If this parameter is present and its value is true, the device must send a spectrum use notify message to the database; otherwise, the device should not send the notification. #[serde(rename="needsSpectrumReport")] - pub needs_spectrum_report: bool, + pub needs_spectrum_report: Option<bool>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl ResponseResult for PawsGetSpectrumBatchResponse {} @@ -516,7 +516,7 @@ impl ResponseResult for PawsGetSpectrumBatchResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct VcardTelephone { /// A nested telephone URI of the form: tel:+1-123-456-7890. - pub uri: String, + pub uri: Option<String>, } impl Part for VcardTelephone {} @@ -530,12 +530,12 @@ impl Part for VcardTelephone {} pub struct DeviceValidity { /// The validity status: true if the device is valid for operation, false otherwise. It will always be present. #[serde(rename="isValid")] - pub is_valid: bool, + pub is_valid: Option<bool>, /// If the device identifier is not valid, the database may include a reason. The reason may be in any language. The length of the value should not exceed 128 characters. - pub reason: String, + pub reason: Option<String>, /// The descriptor of the device for which the validity check was requested. It will always be present. #[serde(rename="deviceDesc")] - pub device_desc: DeviceDescriptor, + pub device_desc: Option<DeviceDescriptor>, } impl Part for DeviceValidity {} @@ -554,21 +554,21 @@ impl Part for DeviceValidity {} pub struct PawsInitResponse { /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs. #[serde(rename="databaseChange")] - pub database_change: DbUpdateSpec, + pub database_change: Option<DbUpdateSpec>, /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsInitResponse". - pub kind: String, + pub kind: Option<String>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The rulesetInfo parameter must be included in the response. This parameter specifies the regulatory domain and parameters applicable to that domain. The database must include the authority field, which defines the regulatory domain for the location specified in the INIT_REQ message. #[serde(rename="rulesetInfo")] - pub ruleset_info: RulesetInfo, + pub ruleset_info: Option<RulesetInfo>, } impl ResponseResult for PawsInitResponse {} @@ -586,16 +586,16 @@ impl ResponseResult for PawsInitResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PawsNotifySpectrumUseResponse { /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsNotifySpectrumUseResponse". - pub kind: String, + pub kind: Option<String>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl ResponseResult for PawsNotifySpectrumUseResponse {} @@ -614,21 +614,21 @@ impl ResponseResult for PawsNotifySpectrumUseResponse {} pub struct PawsVerifyDeviceResponse { /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs. #[serde(rename="databaseChange")] - pub database_change: DbUpdateSpec, + pub database_change: Option<DbUpdateSpec>, /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsVerifyDeviceResponse". - pub kind: String, + pub kind: Option<String>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// A device validities list is required in the device validation response to report whether each slave device listed in a previous device validation request is valid. The number of entries must match the number of device descriptors listed in the previous device validation request. #[serde(rename="deviceValidities")] - pub device_validities: Vec<DeviceValidity>, + pub device_validities: Option<Vec<DeviceValidity>>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl ResponseResult for PawsVerifyDeviceResponse {} @@ -642,12 +642,12 @@ impl ResponseResult for PawsVerifyDeviceResponse {} pub struct AntennaCharacteristics { /// If the height is required, then the height type (AGL for above ground level or AMSL for above mean sea level) is also required. The default is AGL. #[serde(rename="heightType")] - pub height_type: String, + pub height_type: Option<String>, /// The height uncertainty in meters. Whether this is required depends on the regulatory domain. #[serde(rename="heightUncertainty")] - pub height_uncertainty: f64, + pub height_uncertainty: Option<f64>, /// The antenna height in meters. Whether the antenna height is required depends on the device type and the regulatory domain. Note that the height may be negative. - pub height: f64, + pub height: Option<f64>, } impl Part for AntennaCharacteristics {} @@ -660,9 +660,9 @@ impl Part for AntennaCharacteristics {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoLocationPoint { /// A required floating-point number that expresses the latitude in degrees using the WGS84 datum. For details on this encoding, see the National Imagery and Mapping Agency's Technical Report TR8350.2. - pub latitude: f64, + pub latitude: Option<f64>, /// A required floating-point number that expresses the longitude in degrees using the WGS84 datum. For details on this encoding, see the National Imagery and Mapping Agency's Technical Report TR8350.2. - pub longitude: f64, + pub longitude: Option<f64>, } impl Part for GeoLocationPoint {} @@ -681,18 +681,18 @@ impl Part for GeoLocationPoint {} pub struct PawsRegisterResponse { /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs. #[serde(rename="databaseChange")] - pub database_change: DbUpdateSpec, + pub database_change: Option<DbUpdateSpec>, /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsRegisterResponse". - pub kind: String, + pub kind: Option<String>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl ResponseResult for PawsRegisterResponse {} @@ -710,16 +710,16 @@ impl ResponseResult for PawsRegisterResponse {} #[derive(Default, Clone, Debug, Serialize)] pub struct Vcard { /// The organization associated with the registering entity. - pub org: VcardTypedText, + pub org: Option<VcardTypedText>, /// A telephone number that can be used to call the contact. - pub tel: VcardTelephone, + pub tel: Option<VcardTelephone>, /// An email address that can be used to reach the contact. - pub email: VcardTypedText, + pub email: Option<VcardTypedText>, /// The full name of the contact person. For example: John A. Smith. #[serde(rename="fn")] - pub fn_: String, + pub fn_: Option<String>, /// The street address of the entity. - pub adr: VcardAddress, + pub adr: Option<VcardAddress>, } impl Part for Vcard {} @@ -776,7 +776,7 @@ impl RequestValue for PawsGetSpectrumBatchRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DbUpdateSpec { /// A required list of one or more databases. A device should update its preconfigured list of databases to replace (only) the database that provided the response with the specified entries. - pub databases: Vec<DatabaseSpec>, + pub databases: Option<Vec<DatabaseSpec>>, } impl Part for DbUpdateSpec {} @@ -794,7 +794,7 @@ pub struct GeoLocationPolygon { /// - The edges of a polygon are defined by the shortest path between two points in space (not a geodesic curve). Consequently, the length between two adjacent vertices should be restricted to a maximum of 130 km. /// - All vertices are assumed to be at the same altitude. /// - Polygon shapes should be restricted to a maximum of 15 vertices (16 points that include the repeated vertex). - pub exterior: Vec<GeoLocationPoint>, + pub exterior: Option<Vec<GeoLocationPoint>>, } impl Part for GeoLocationPolygon {} @@ -808,9 +808,9 @@ impl Part for GeoLocationPolygon {} pub struct GeoSpectrumSchedule { /// A list of available spectrum profiles and associated times. It will always be present, and at least one schedule must be included (though it may be empty if there is no available spectrum). More than one schedule may be included to represent future changes to the available spectrum. #[serde(rename="spectrumSchedules")] - pub spectrum_schedules: Vec<SpectrumSchedule>, + pub spectrum_schedules: Option<Vec<SpectrumSchedule>>, /// The geolocation identifies the location at which the spectrum schedule applies. It will always be present. - pub location: GeoLocation, + pub location: Option<GeoLocation>, } impl Part for GeoSpectrumSchedule {} @@ -853,17 +853,17 @@ impl RequestValue for PawsInitRequest {} #[derive(Default, Clone, Debug, Serialize)] pub struct VcardAddress { /// The postal code associated with the address. For example: 94423. - pub code: String, + pub code: Option<String>, /// The street number and name. For example: 123 Any St. - pub street: String, + pub street: Option<String>, /// The city or local equivalent portion of the address. For example: San Jose. - pub locality: String, + pub locality: Option<String>, /// The country name. For example: US. - pub country: String, + pub country: Option<String>, /// The state or local equivalent portion of the address. For example: CA. - pub region: String, + pub region: Option<String>, /// An optional post office box number. - pub pobox: String, + pub pobox: Option<String>, } impl Part for VcardAddress {} @@ -877,36 +877,36 @@ impl Part for VcardAddress {} pub struct DeviceDescriptor { /// Specifies the ETSI white space device type. Valid values are single-letter strings, such as A, B, etc. Consult the ETSI documentation for details about the device types. #[serde(rename="etsiEnDeviceType")] - pub etsi_en_device_type: String, + pub etsi_en_device_type: Option<String>, /// Specifies the device's FCC certification identifier. The value is an identifier string whose length should not exceed 32 characters. Note that, in practice, a valid FCC ID may be limited to 19 characters. #[serde(rename="fccId")] - pub fcc_id: String, + pub fcc_id: Option<String>, /// The manufacturer's device serial number; required by the applicable regulatory domain. The length of the value must not exceed 64 characters. #[serde(rename="serialNumber")] - pub serial_number: String, + pub serial_number: Option<String>, /// Specifies the ETSI white space device technology identifier. The string value must not exceed 64 characters in length. Consult the ETSI documentation for details about the device types. #[serde(rename="etsiEnTechnologyId")] - pub etsi_en_technology_id: String, + pub etsi_en_technology_id: Option<String>, /// Specifies the TV Band White Space device type, as defined by the FCC. Valid values are FIXED, MODE_1, MODE_2. #[serde(rename="fccTvbdDeviceType")] - pub fcc_tvbd_device_type: String, + pub fcc_tvbd_device_type: Option<String>, /// Specifies the ETSI white space device category. Valid values are the strings master and slave. This field is case-insensitive. Consult the ETSI documentation for details about the device types. #[serde(rename="etsiEnDeviceCategory")] - pub etsi_en_device_category: String, + pub etsi_en_device_category: Option<String>, /// The list of identifiers for rulesets supported by the device. A database may require that the device provide this list before servicing the device requests. If the database does not support any of the rulesets specified in the list, the database may refuse to service the device requests. If present, the list must contain at least one entry. /// /// For information about the valid requests, see section 9.2 of the PAWS specification. Currently, FccTvBandWhiteSpace-2010 is the only supported ruleset. #[serde(rename="rulesetIds")] - pub ruleset_ids: Vec<String>, + pub ruleset_ids: Option<Vec<String>>, /// Specifies the ETSI white space device emissions class. The values are represented by numeric strings, such as 1, 2, etc. Consult the ETSI documentation for details about the device types. #[serde(rename="etsiEnDeviceEmissionsClass")] - pub etsi_en_device_emissions_class: String, + pub etsi_en_device_emissions_class: Option<String>, /// The manufacturer's ID may be required by the regulatory domain. This should represent the name of the device manufacturer, should be consistent across all devices from the same manufacturer, and should be distinct from that of other manufacturers. The string value must not exceed 64 characters in length. #[serde(rename="manufacturerId")] - pub manufacturer_id: String, + pub manufacturer_id: Option<String>, /// The device's model ID may be required by the regulatory domain. The string value must not exceed 64 characters in length. #[serde(rename="modelId")] - pub model_id: String, + pub model_id: Option<String>, } impl Part for DeviceDescriptor {} @@ -920,15 +920,15 @@ impl Part for DeviceDescriptor {} pub struct RulesetInfo { /// The identifiers of the rulesets supported for the device's location. The database should include at least one applicable ruleset in the initialization response. The device may use the ruleset identifiers to determine parameters to include in subsequent requests. Within the context of the available-spectrum responses, the database should include the identifier of the ruleset that it used to determine the available-spectrum response. If included, the device must use the specified ruleset to interpret the response. If the device does not support the indicated ruleset, it must not operate in the spectrum governed by the ruleset. #[serde(rename="rulesetIds")] - pub ruleset_ids: Vec<String>, + pub ruleset_ids: Option<Vec<String>>, /// The maximum duration, in seconds, between requests for available spectrum. It is required in the initialization response, but optional otherwise. The device must contact the database to get available spectrum no less frequently than this duration. If the new spectrum information indicates that the device is using spectrum that is no longer available, it must immediately cease use of those frequencies under rules for database-managed spectrum. If this value is provided within the context of an available-spectrum response, it takes precedence over the value within the initialization response. #[serde(rename="maxPollingSecs")] - pub max_polling_secs: i32, + pub max_polling_secs: Option<i32>, /// The regulatory domain to which the ruleset belongs is required. It must be a 2-letter country code. The device should use this to determine additional device behavior required by the associated regulatory domain. - pub authority: String, + pub authority: Option<String>, /// The maximum location change in meters is required in the initialization response, but optional otherwise. When the device changes location by more than this specified distance, it must contact the database to get the available spectrum for the new location. If the device is using spectrum that is no longer available, it must immediately cease use of the spectrum under rules for database-managed spectrum. If this value is provided within the context of an available-spectrum response, it takes precedence over the value within the initialization response. #[serde(rename="maxLocationChange")] - pub max_location_change: f64, + pub max_location_change: Option<f64>, } impl Part for RulesetInfo {} @@ -941,9 +941,9 @@ impl Part for RulesetInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatabaseSpec { /// The display name for a database. - pub name: String, + pub name: Option<String>, /// The corresponding URI of the database. - pub uri: String, + pub uri: Option<String>, } impl Part for DatabaseSpec {} @@ -991,10 +991,10 @@ impl RequestValue for PawsRegisterRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SpectrumMessage { /// The bandwidth (in Hertz) for which permissible power levels are specified. For example, FCC regulation would require only one spectrum specification at 6MHz bandwidth, but Ofcom regulation would require two specifications, at 0.1MHz and 8MHz. This parameter may be empty if there is no available spectrum. It will be present otherwise. - pub bandwidth: f64, + pub bandwidth: Option<f64>, /// The list of frequency ranges and permissible power levels. The list may be empty if there is no available spectrum, otherwise it will be present. #[serde(rename="frequencyRanges")] - pub frequency_ranges: Vec<FrequencyRange>, + pub frequency_ranges: Option<Vec<FrequencyRange>>, } impl Part for SpectrumMessage {} @@ -1012,39 +1012,39 @@ impl Part for SpectrumMessage {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PawsGetSpectrumResponse { /// Identifies what kind of resource this is. Value: the fixed string "spectrum#pawsGetSpectrumResponse". - pub kind: String, + pub kind: Option<String>, /// The database must return, in its available spectrum response, the device descriptor information it received in the master device's available spectrum request. #[serde(rename="deviceDesc")] - pub device_desc: DeviceDescriptor, + pub device_desc: Option<DeviceDescriptor>, /// A database may include the databaseChange parameter to notify a device of a change to its database URI, providing one or more alternate database URIs. The device should use this information to update its list of pre-configured databases by (only) replacing its entry for the responding database with the list of alternate URIs. #[serde(rename="databaseChange")] - pub database_change: DbUpdateSpec, + pub database_change: Option<DbUpdateSpec>, /// The database may return a constraint on the allowed maximum total bandwidth (in Hertz), which need not be contiguous. A regulatory domain may require the database to return this parameter. When this parameter is present in the available spectrum response, the device must apply this constraint to its spectrum-selection logic to ensure that total bandwidth does not exceed this value. #[serde(rename="maxTotalBwHz")] - pub max_total_bw_hz: f64, + pub max_total_bw_hz: Option<f64>, /// The available spectrum response must contain a spectrum schedule list. The list may be empty if spectrum is not available. The database may return more than one spectrum schedule to represent future changes to the available spectrum. How far in advance a schedule may be provided depends on the applicable regulatory domain. #[serde(rename="spectrumSchedules")] - pub spectrum_schedules: Vec<SpectrumSchedule>, + pub spectrum_schedules: Option<Vec<SpectrumSchedule>>, /// The database may return a constraint on the allowed maximum contiguous bandwidth (in Hertz). A regulatory domain may require the database to return this parameter. When this parameter is present in the response, the device must apply this constraint to its spectrum-selection logic to ensure that no single block of spectrum has bandwidth that exceeds this value. #[serde(rename="maxContiguousBwHz")] - pub max_contiguous_bw_hz: f64, + pub max_contiguous_bw_hz: Option<f64>, /// The PAWS version. Must be exactly 1.0. /// /// Required field. - pub version: String, + pub version: Option<String>, /// The database includes a timestamp of the form YYYY-MM-DDThh:mm:ssZ (Internet timestamp format per RFC3339) in its available spectrum response. The timestamp should be used by the device as a reference for the start and stop times specified in the response spectrum schedules. - pub timestamp: String, + pub timestamp: Option<String>, /// The database should return ruleset information, which identifies the applicable regulatory authority and ruleset for the available spectrum response. If included, the device must use the corresponding ruleset to interpret the response. Values provided in the returned ruleset information, such as maxLocationChange, take precedence over any conflicting values provided in the ruleset information returned in a prior initialization response sent by the database to the device. #[serde(rename="rulesetInfo")] - pub ruleset_info: RulesetInfo, + pub ruleset_info: Option<RulesetInfo>, /// For regulatory domains that require a spectrum-usage report from devices, the database must return true for this parameter if the spectrum schedule list is not empty; otherwise, the database will either return false or omit this parameter. If this parameter is present and its value is true, the device must send a spectrum use notify message to the database; otherwise, the device must not send the notification. #[serde(rename="needsSpectrumReport")] - pub needs_spectrum_report: bool, + pub needs_spectrum_report: Option<bool>, /// The message type (e.g., INIT_REQ, AVAIL_SPECTRUM_REQ, ...). /// /// Required field. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl ResponseResult for PawsGetSpectrumResponse {} @@ -1058,7 +1058,7 @@ impl ResponseResult for PawsGetSpectrumResponse {} pub struct DeviceCapabilities { /// An optional list of frequency ranges supported by the device. Each element must contain start and stop frequencies in which the device can operate. Channel identifiers are optional. When specified, the database should not return available spectrum that falls outside these ranges or channel IDs. #[serde(rename="frequencyRanges")] - pub frequency_ranges: Vec<FrequencyRange>, + pub frequency_ranges: Option<Vec<FrequencyRange>>, } impl Part for DeviceCapabilities {} @@ -1072,9 +1072,9 @@ impl Part for DeviceCapabilities {} pub struct SpectrumSchedule { /// The event time expresses when the spectrum profile is valid. It will always be present. #[serde(rename="eventTime")] - pub event_time: EventTime, + pub event_time: Option<EventTime>, /// A list of spectrum messages representing the usable profile. It will always be present, but may be empty when there is no available spectrum. - pub spectra: Vec<SpectrumMessage>, + pub spectra: Option<Vec<SpectrumMessage>>, } impl Part for SpectrumSchedule {} @@ -1325,7 +1325,7 @@ impl<'a, C, A> PawMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsNotifySpectrumUseRequest = Default::default(); +/// let mut req = PawsNotifySpectrumUseRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1524,7 +1524,7 @@ impl<'a, C, A> PawNotifySpectrumUseCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsRegisterRequest = Default::default(); +/// let mut req = PawsRegisterRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1723,7 +1723,7 @@ impl<'a, C, A> PawRegisterCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsGetSpectrumRequest = Default::default(); +/// let mut req = PawsGetSpectrumRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1922,7 +1922,7 @@ impl<'a, C, A> PawGetSpectrumCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsInitRequest = Default::default(); +/// let mut req = PawsInitRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2121,7 +2121,7 @@ impl<'a, C, A> PawInitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsGetSpectrumBatchRequest = Default::default(); +/// let mut req = PawsGetSpectrumBatchRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2320,7 +2320,7 @@ impl<'a, C, A> PawGetSpectrumBatchCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PawsVerifyDeviceRequest = Default::default(); +/// let mut req = PawsVerifyDeviceRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. diff --git a/gen/sqladmin1_beta4-cli/Cargo.toml b/gen/sqladmin1_beta4-cli/Cargo.toml index a7e54fd539..69ad2ce1dc 100644 --- a/gen/sqladmin1_beta4-cli/Cargo.toml +++ b/gen/sqladmin1_beta4-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-sqladmin1_beta4-cli" version = "0.0.1+20150305" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/cloud-sql/docs/admin-api/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/sqladmin1_beta4-cli/src/cmn.rs b/gen/sqladmin1_beta4-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/sqladmin1_beta4-cli/src/cmn.rs +++ b/gen/sqladmin1_beta4-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/sqladmin1_beta4-cli/src/main.rs b/gen/sqladmin1_beta4-cli/src/main.rs index 8b4f12654f..d25be95365 100644 --- a/gen/sqladmin1_beta4-cli/src/main.rs +++ b/gen/sqladmin1_beta4-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -66,6 +67,12 @@ Configuration: 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. "); mod cmn; @@ -89,7 +96,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.backup_runs().get(&self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -121,8 +128,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -133,7 +139,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.backup_runs().list(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -171,8 +177,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -183,7 +188,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.databases().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -215,8 +220,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -227,7 +231,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.databases().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -259,8 +263,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -269,10 +272,10 @@ impl Engine { fn _databases_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Database = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -292,9 +295,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -340,8 +344,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -352,7 +355,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.databases().list(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -384,8 +387,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -394,10 +396,10 @@ impl Engine { fn _databases_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Database = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -417,9 +419,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -465,8 +468,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -475,10 +477,10 @@ impl Engine { fn _databases_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Database = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -498,9 +500,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -546,8 +549,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -558,7 +560,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.flags().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -590,8 +592,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -600,10 +601,10 @@ impl Engine { fn _instances_clone(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstancesCloneRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -623,12 +624,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.clone_context.as_mut().unwrap().bin_log_coordinates = Some(Default::default()); + } + } + fn request_clone_context_init(request: &mut api::InstancesCloneRequest) { if request.clone_context.is_none() { request.clone_context = Some(Default::default()); @@ -637,24 +646,24 @@ impl Engine { match &field_name.to_string()[..] { "clone-context.bin-log-coordinates.bin-log-position" => { - request_clone_context_init(&mut request); - request.clone_context.as_mut().unwrap().bin_log_coordinates.bin_log_position = value.unwrap_or("").to_string(); + 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()); }, "clone-context.bin-log-coordinates.kind" => { - request_clone_context_init(&mut request); - request.clone_context.as_mut().unwrap().bin_log_coordinates.kind = value.unwrap_or("").to_string(); + request_clone_context_bin_log_coordinates_init(&mut request); + request.clone_context.as_mut().unwrap().bin_log_coordinates.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "clone-context.bin-log-coordinates.bin-log-file-name" => { - request_clone_context_init(&mut request); - request.clone_context.as_mut().unwrap().bin_log_coordinates.bin_log_file_name = value.unwrap_or("").to_string(); + request_clone_context_bin_log_coordinates_init(&mut request); + request.clone_context.as_mut().unwrap().bin_log_coordinates.as_mut().unwrap().bin_log_file_name = Some(value.unwrap_or("").to_string()); }, "clone-context.kind" => { - request_clone_context_init(&mut request); - request.clone_context.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request_clone_context_bin_log_coordinates_init(&mut request); + request.clone_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "clone-context.destination-instance-name" => { - request_clone_context_init(&mut request); - request.clone_context.as_mut().unwrap().destination_instance_name = value.unwrap_or("").to_string(); + request_clone_context_bin_log_coordinates_init(&mut request); + 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()))); @@ -673,8 +682,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -685,7 +693,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().delete(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -717,8 +725,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -727,10 +734,10 @@ impl Engine { fn _instances_export(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstancesExportRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -750,42 +757,63 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.export_context.as_mut().unwrap().csv_export_options = Some(Default::default()); + } + } + fn request_export_context_init(request: &mut api::InstancesExportRequest) { if request.export_context.is_none() { request.export_context = Some(Default::default()); } } + fn request_export_context_sql_export_options_init(request: &mut api::InstancesExportRequest) { + request_export_context_init(request); + if request.export_context.as_mut().unwrap().sql_export_options.is_none() { + request.export_context.as_mut().unwrap().sql_export_options = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "export-context.kind" => { request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.export_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "export-context.file-type" => { request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().file_type = value.unwrap_or("").to_string(); + request.export_context.as_mut().unwrap().file_type = Some(value.unwrap_or("").to_string()); }, "export-context.uri" => { request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().uri = value.unwrap_or("").to_string(); + request.export_context.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "export-context.csv-export-options.select-query" => { - request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().csv_export_options.select_query = value.unwrap_or("").to_string(); + request_export_context_csv_export_options_init(&mut request); + request.export_context.as_mut().unwrap().csv_export_options.as_mut().unwrap().select_query = Some(value.unwrap_or("").to_string()); }, "export-context.databases" => { - request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().databases.push(value.unwrap_or("").to_string()); + request_export_context_csv_export_options_init(&mut request); + if request.export_context.as_mut().unwrap().databases.is_none() { + request.export_context.as_mut().unwrap().databases = Some(Default::default()); + } + request.export_context.as_mut().unwrap().databases.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "export-context.sql-export-options.tables" => { - request_export_context_init(&mut request); - request.export_context.as_mut().unwrap().sql_export_options.tables.push(value.unwrap_or("").to_string()); + request_export_context_sql_export_options_init(&mut request); + if request.export_context.as_mut().unwrap().sql_export_options.as_mut().unwrap().tables.is_none() { + request.export_context.as_mut().unwrap().sql_export_options.as_mut().unwrap().tables = Some(Default::default()); + } + 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()))); @@ -804,8 +832,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -816,7 +843,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().get(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -848,8 +875,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -858,10 +884,10 @@ impl Engine { fn _instances_import(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstancesImportRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -881,12 +907,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_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() { + request.import_context.as_mut().unwrap().csv_import_options = Some(Default::default()); + } + } + fn request_import_context_init(request: &mut api::InstancesImportRequest) { if request.import_context.is_none() { request.import_context = Some(Default::default()); @@ -896,27 +930,30 @@ impl Engine { match &field_name.to_string()[..] { "import-context.file-type" => { request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().file_type = value.unwrap_or("").to_string(); + request.import_context.as_mut().unwrap().file_type = Some(value.unwrap_or("").to_string()); }, "import-context.database" => { request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().database = value.unwrap_or("").to_string(); + request.import_context.as_mut().unwrap().database = Some(value.unwrap_or("").to_string()); }, "import-context.uri" => { request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().uri = value.unwrap_or("").to_string(); + request.import_context.as_mut().unwrap().uri = Some(value.unwrap_or("").to_string()); }, "import-context.kind" => { request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.import_context.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "import-context.csv-import-options.table" => { - request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().csv_import_options.table = value.unwrap_or("").to_string(); + request_import_context_csv_import_options_init(&mut request); + request.import_context.as_mut().unwrap().csv_import_options.as_mut().unwrap().table = Some(value.unwrap_or("").to_string()); }, "import-context.csv-import-options.columns" => { - request_import_context_init(&mut request); - request.import_context.as_mut().unwrap().csv_import_options.columns.push(value.unwrap_or("").to_string()); + request_import_context_csv_import_options_init(&mut request); + if request.import_context.as_mut().unwrap().csv_import_options.as_mut().unwrap().columns.is_none() { + request.import_context.as_mut().unwrap().csv_import_options.as_mut().unwrap().columns = Some(Default::default()); + } + 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()))); @@ -935,8 +972,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -945,10 +981,10 @@ impl Engine { fn _instances_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DatabaseInstance = Default::default(); + let mut request = api::DatabaseInstance::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -968,9 +1004,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -986,26 +1023,54 @@ impl Engine { } } + fn request_replica_configuration_mysql_replica_configuration_init(request: &mut api::DatabaseInstance) { + request_replica_configuration_init(request); + if request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.is_none() { + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration = Some(Default::default()); + } + } + fn request_server_ca_cert_init(request: &mut api::DatabaseInstance) { if request.server_ca_cert.is_none() { request.server_ca_cert = Some(Default::default()); } } + fn request_settings_backup_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().backup_configuration.is_none() { + request.settings.as_mut().unwrap().backup_configuration = Some(Default::default()); + } + } + fn request_settings_init(request: &mut api::DatabaseInstance) { if request.settings.is_none() { request.settings = Some(Default::default()); } } + fn request_settings_ip_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().ip_configuration.is_none() { + request.settings.as_mut().unwrap().ip_configuration = Some(Default::default()); + } + } + + fn request_settings_location_preference_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().location_preference.is_none() { + request.settings.as_mut().unwrap().location_preference = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "on-premises-configuration.host-port" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().host_port = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().host_port = Some(value.unwrap_or("").to_string()); }, "kind" => { request_on_premises_configuration_init(&mut request); @@ -1021,46 +1086,46 @@ impl Engine { }, "server-ca-cert.cert-serial-number" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert_serial_number = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert_serial_number = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.kind" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.sha1-fingerprint" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.common-name" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().common_name = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().common_name = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.instance" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().instance = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().instance = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.cert" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.expiration-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().expiration_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().expiration_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.create-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().create_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().create_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.self-link" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "replica-names" => { request_server_ca_cert_init(&mut request); if request.replica_names.is_none() { - request.replica_names = Some(Default::default()); + request.replica_names = Some(Default::default()); } - request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "project" => { request_server_ca_cert_init(&mut request); @@ -1072,75 +1137,78 @@ impl Engine { }, "settings.kind" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.authorized-gae-applications" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().authorized_gae_applications.push(value.unwrap_or("").to_string()); + if request.settings.as_mut().unwrap().authorized_gae_applications.is_none() { + request.settings.as_mut().unwrap().authorized_gae_applications = Some(Default::default()); + } + request.settings.as_mut().unwrap().authorized_gae_applications.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "settings.activation-policy" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().activation_policy = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().activation_policy = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.kind = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean")); }, "settings.backup-configuration.start-time" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.start_time = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().start_time = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.binary-log-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.binary_log_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().binary_log_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean")); }, "settings.ip-configuration.ipv4-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.ipv4_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().ipv4_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean")); }, "settings.ip-configuration.require-ssl" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.require_ssl = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().require_ssl = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean")); }, "settings.tier" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().tier = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().tier = Some(value.unwrap_or("").to_string()); }, "settings.database-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().database_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().database_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean")); }, "settings.replication-type" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().replication_type = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().replication_type = Some(value.unwrap_or("").to_string()); }, "settings.crash-safe-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().crash_safe_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().crash_safe_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean")); }, "settings.pricing-plan" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().pricing_plan = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().pricing_plan = Some(value.unwrap_or("").to_string()); }, "settings.settings-version" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().settings_version = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().settings_version = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.kind = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.zone" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.zone = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().zone = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.follow-gae-application" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.follow_gae_application = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().follow_gae_application = Some(value.unwrap_or("").to_string()); }, "master-instance-name" => { request_settings_init(&mut request); @@ -1164,51 +1232,51 @@ impl Engine { }, "replica-configuration.kind" => { request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.username" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.username = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.kind" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.kind = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.connect-retry-interval" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.connect_retry_interval = arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().connect_retry_interval = Some(arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer")); }, "replica-configuration.mysql-replica-configuration.ssl-cipher" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ssl_cipher = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ssl_cipher = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.ca-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ca_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ca_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.master-heartbeat-period" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.master_heartbeat_period = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().master_heartbeat_period = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.verify-server-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.verify_server_certificate = arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().verify_server_certificate = Some(arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean")); }, "replica-configuration.mysql-replica-configuration.dump-file-path" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.dump_file_path = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().dump_file_path = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.password" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.password = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-key" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_key = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_key = Some(value.unwrap_or("").to_string()); }, "database-version" => { request_replica_configuration_init(&mut request); @@ -1243,8 +1311,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1255,7 +1322,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1293,8 +1360,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1303,10 +1369,10 @@ impl Engine { fn _instances_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DatabaseInstance = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1326,9 +1392,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1344,26 +1411,54 @@ impl Engine { } } + fn request_replica_configuration_mysql_replica_configuration_init(request: &mut api::DatabaseInstance) { + request_replica_configuration_init(request); + if request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.is_none() { + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration = Some(Default::default()); + } + } + fn request_server_ca_cert_init(request: &mut api::DatabaseInstance) { if request.server_ca_cert.is_none() { request.server_ca_cert = Some(Default::default()); } } + fn request_settings_backup_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().backup_configuration.is_none() { + request.settings.as_mut().unwrap().backup_configuration = Some(Default::default()); + } + } + fn request_settings_init(request: &mut api::DatabaseInstance) { if request.settings.is_none() { request.settings = Some(Default::default()); } } + fn request_settings_ip_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().ip_configuration.is_none() { + request.settings.as_mut().unwrap().ip_configuration = Some(Default::default()); + } + } + + fn request_settings_location_preference_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().location_preference.is_none() { + request.settings.as_mut().unwrap().location_preference = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "on-premises-configuration.host-port" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().host_port = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().host_port = Some(value.unwrap_or("").to_string()); }, "kind" => { request_on_premises_configuration_init(&mut request); @@ -1379,46 +1474,46 @@ impl Engine { }, "server-ca-cert.cert-serial-number" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert_serial_number = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert_serial_number = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.kind" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.sha1-fingerprint" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.common-name" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().common_name = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().common_name = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.instance" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().instance = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().instance = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.cert" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.expiration-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().expiration_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().expiration_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.create-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().create_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().create_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.self-link" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "replica-names" => { request_server_ca_cert_init(&mut request); if request.replica_names.is_none() { - request.replica_names = Some(Default::default()); + request.replica_names = Some(Default::default()); } - request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "project" => { request_server_ca_cert_init(&mut request); @@ -1430,75 +1525,78 @@ impl Engine { }, "settings.kind" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.authorized-gae-applications" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().authorized_gae_applications.push(value.unwrap_or("").to_string()); + if request.settings.as_mut().unwrap().authorized_gae_applications.is_none() { + request.settings.as_mut().unwrap().authorized_gae_applications = Some(Default::default()); + } + request.settings.as_mut().unwrap().authorized_gae_applications.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "settings.activation-policy" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().activation_policy = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().activation_policy = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.kind = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean")); }, "settings.backup-configuration.start-time" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.start_time = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().start_time = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.binary-log-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.binary_log_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().binary_log_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean")); }, "settings.ip-configuration.ipv4-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.ipv4_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().ipv4_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean")); }, "settings.ip-configuration.require-ssl" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.require_ssl = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().require_ssl = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean")); }, "settings.tier" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().tier = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().tier = Some(value.unwrap_or("").to_string()); }, "settings.database-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().database_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().database_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean")); }, "settings.replication-type" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().replication_type = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().replication_type = Some(value.unwrap_or("").to_string()); }, "settings.crash-safe-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().crash_safe_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().crash_safe_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean")); }, "settings.pricing-plan" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().pricing_plan = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().pricing_plan = Some(value.unwrap_or("").to_string()); }, "settings.settings-version" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().settings_version = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().settings_version = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.kind = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.zone" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.zone = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().zone = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.follow-gae-application" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.follow_gae_application = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().follow_gae_application = Some(value.unwrap_or("").to_string()); }, "master-instance-name" => { request_settings_init(&mut request); @@ -1522,51 +1620,51 @@ impl Engine { }, "replica-configuration.kind" => { request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.username" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.username = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.kind" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.kind = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.connect-retry-interval" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.connect_retry_interval = arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().connect_retry_interval = Some(arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer")); }, "replica-configuration.mysql-replica-configuration.ssl-cipher" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ssl_cipher = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ssl_cipher = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.ca-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ca_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ca_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.master-heartbeat-period" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.master_heartbeat_period = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().master_heartbeat_period = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.verify-server-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.verify_server_certificate = arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().verify_server_certificate = Some(arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean")); }, "replica-configuration.mysql-replica-configuration.dump-file-path" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.dump_file_path = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().dump_file_path = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.password" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.password = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-key" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_key = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_key = Some(value.unwrap_or("").to_string()); }, "database-version" => { request_replica_configuration_init(&mut request); @@ -1601,8 +1699,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1613,7 +1710,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().promote_replica(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1645,8 +1742,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1657,7 +1753,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().reset_ssl_config(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1689,8 +1785,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1701,7 +1796,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().restart(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1733,8 +1828,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1743,10 +1837,10 @@ impl Engine { fn _instances_restore_backup(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InstancesRestoreBackupRequest = Default::default(); + let mut request = api::InstancesRestoreBackupRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1766,9 +1860,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1781,11 +1876,11 @@ impl Engine { match &field_name.to_string()[..] { "restore-backup-context.kind" => { request_restore_backup_context_init(&mut request); - request.restore_backup_context.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + 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()))); @@ -1804,8 +1899,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1816,7 +1910,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().start_replica(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1848,8 +1942,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1860,7 +1953,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.instances().stop_replica(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1892,8 +1985,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1902,10 +1994,10 @@ impl Engine { fn _instances_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::DatabaseInstance = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1925,9 +2017,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1943,26 +2036,54 @@ impl Engine { } } + fn request_replica_configuration_mysql_replica_configuration_init(request: &mut api::DatabaseInstance) { + request_replica_configuration_init(request); + if request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.is_none() { + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration = Some(Default::default()); + } + } + fn request_server_ca_cert_init(request: &mut api::DatabaseInstance) { if request.server_ca_cert.is_none() { request.server_ca_cert = Some(Default::default()); } } + fn request_settings_backup_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().backup_configuration.is_none() { + request.settings.as_mut().unwrap().backup_configuration = Some(Default::default()); + } + } + fn request_settings_init(request: &mut api::DatabaseInstance) { if request.settings.is_none() { request.settings = Some(Default::default()); } } + fn request_settings_ip_configuration_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().ip_configuration.is_none() { + request.settings.as_mut().unwrap().ip_configuration = Some(Default::default()); + } + } + + fn request_settings_location_preference_init(request: &mut api::DatabaseInstance) { + request_settings_init(request); + if request.settings.as_mut().unwrap().location_preference.is_none() { + request.settings.as_mut().unwrap().location_preference = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "on-premises-configuration.kind" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "on-premises-configuration.host-port" => { request_on_premises_configuration_init(&mut request); - request.on_premises_configuration.as_mut().unwrap().host_port = value.unwrap_or("").to_string(); + request.on_premises_configuration.as_mut().unwrap().host_port = Some(value.unwrap_or("").to_string()); }, "kind" => { request_on_premises_configuration_init(&mut request); @@ -1978,46 +2099,46 @@ impl Engine { }, "server-ca-cert.cert-serial-number" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert_serial_number = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert_serial_number = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.kind" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.sha1-fingerprint" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().sha1_fingerprint = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.common-name" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().common_name = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().common_name = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.instance" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().instance = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().instance = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.cert" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().cert = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().cert = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.expiration-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().expiration_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().expiration_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.create-time" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().create_time = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().create_time = Some(value.unwrap_or("").to_string()); }, "server-ca-cert.self-link" => { request_server_ca_cert_init(&mut request); - request.server_ca_cert.as_mut().unwrap().self_link = value.unwrap_or("").to_string(); + request.server_ca_cert.as_mut().unwrap().self_link = Some(value.unwrap_or("").to_string()); }, "replica-names" => { request_server_ca_cert_init(&mut request); if request.replica_names.is_none() { - request.replica_names = Some(Default::default()); + request.replica_names = Some(Default::default()); } - request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); + request.replica_names.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "project" => { request_server_ca_cert_init(&mut request); @@ -2029,75 +2150,78 @@ impl Engine { }, "settings.kind" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.authorized-gae-applications" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().authorized_gae_applications.push(value.unwrap_or("").to_string()); + if request.settings.as_mut().unwrap().authorized_gae_applications.is_none() { + request.settings.as_mut().unwrap().authorized_gae_applications = Some(Default::default()); + } + request.settings.as_mut().unwrap().authorized_gae_applications.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "settings.activation-policy" => { request_settings_init(&mut request); - request.settings.as_mut().unwrap().activation_policy = value.unwrap_or("").to_string(); + request.settings.as_mut().unwrap().activation_policy = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.kind = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.enabled", "boolean")); }, "settings.backup-configuration.start-time" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.start_time = value.unwrap_or("").to_string(); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().start_time = Some(value.unwrap_or("").to_string()); }, "settings.backup-configuration.binary-log-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().backup_configuration.binary_log_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean"); + request_settings_backup_configuration_init(&mut request); + request.settings.as_mut().unwrap().backup_configuration.as_mut().unwrap().binary_log_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.backup-configuration.binary-log-enabled", "boolean")); }, "settings.ip-configuration.ipv4-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.ipv4_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().ipv4_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.ipv4-enabled", "boolean")); }, "settings.ip-configuration.require-ssl" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().ip_configuration.require_ssl = arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().ip_configuration.as_mut().unwrap().require_ssl = Some(arg_from_str(value.unwrap_or("false"), err, "settings.ip-configuration.require-ssl", "boolean")); }, "settings.tier" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().tier = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().tier = Some(value.unwrap_or("").to_string()); }, "settings.database-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().database_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().database_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.database-replication-enabled", "boolean")); }, "settings.replication-type" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().replication_type = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().replication_type = Some(value.unwrap_or("").to_string()); }, "settings.crash-safe-replication-enabled" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().crash_safe_replication_enabled = arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean"); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().crash_safe_replication_enabled = Some(arg_from_str(value.unwrap_or("false"), err, "settings.crash-safe-replication-enabled", "boolean")); }, "settings.pricing-plan" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().pricing_plan = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().pricing_plan = Some(value.unwrap_or("").to_string()); }, "settings.settings-version" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().settings_version = value.unwrap_or("").to_string(); + request_settings_ip_configuration_init(&mut request); + request.settings.as_mut().unwrap().settings_version = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.kind" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.kind = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.zone" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.zone = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().zone = Some(value.unwrap_or("").to_string()); }, "settings.location-preference.follow-gae-application" => { - request_settings_init(&mut request); - request.settings.as_mut().unwrap().location_preference.follow_gae_application = value.unwrap_or("").to_string(); + request_settings_location_preference_init(&mut request); + request.settings.as_mut().unwrap().location_preference.as_mut().unwrap().follow_gae_application = Some(value.unwrap_or("").to_string()); }, "master-instance-name" => { request_settings_init(&mut request); @@ -2121,51 +2245,51 @@ impl Engine { }, "replica-configuration.kind" => { request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + request.replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.username" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.username = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().username = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.kind" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.kind = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.connect-retry-interval" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.connect_retry_interval = arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().connect_retry_interval = Some(arg_from_str(value.unwrap_or("-0"), err, "replica-configuration.mysql-replica-configuration.connect-retry-interval", "integer")); }, "replica-configuration.mysql-replica-configuration.ssl-cipher" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ssl_cipher = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ssl_cipher = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.ca-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.ca_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().ca_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_certificate = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_certificate = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.master-heartbeat-period" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.master_heartbeat_period = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().master_heartbeat_period = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.verify-server-certificate" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.verify_server_certificate = arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean"); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().verify_server_certificate = Some(arg_from_str(value.unwrap_or("false"), err, "replica-configuration.mysql-replica-configuration.verify-server-certificate", "boolean")); }, "replica-configuration.mysql-replica-configuration.dump-file-path" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.dump_file_path = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().dump_file_path = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.password" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.password = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().password = Some(value.unwrap_or("").to_string()); }, "replica-configuration.mysql-replica-configuration.client-key" => { - request_replica_configuration_init(&mut request); - request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.client_key = value.unwrap_or("").to_string(); + request_replica_configuration_mysql_replica_configuration_init(&mut request); + request.replica_configuration.as_mut().unwrap().mysql_replica_configuration.as_mut().unwrap().client_key = Some(value.unwrap_or("").to_string()); }, "database-version" => { request_replica_configuration_init(&mut request); @@ -2200,8 +2324,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2212,7 +2335,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operations().get(&self.opt.arg_project, &self.opt.arg_operation); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2244,8 +2367,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2256,7 +2378,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.operations().list(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2294,8 +2416,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2306,7 +2427,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.ssl_certs().delete(&self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_sha1_fingerprint); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2338,8 +2459,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2350,7 +2470,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.ssl_certs().get(&self.opt.arg_project, &self.opt.arg_instance, &self.opt.arg_sha1_fingerprint); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2382,8 +2502,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2392,10 +2511,10 @@ impl Engine { fn _ssl_certs_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::SslCertsInsertRequest = Default::default(); + let mut request = api::SslCertsInsertRequest::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2415,9 +2534,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2442,8 +2562,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2454,7 +2573,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.ssl_certs().list(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2486,8 +2605,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2498,7 +2616,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tiers().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2530,8 +2648,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2542,7 +2659,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2574,8 +2691,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2584,10 +2700,10 @@ impl Engine { fn _users_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::User = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2607,9 +2723,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2652,8 +2769,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2664,7 +2780,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.users().list(&self.opt.arg_project, &self.opt.arg_instance); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2696,8 +2812,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2706,10 +2821,10 @@ impl Engine { fn _users_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::User = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -2729,9 +2844,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2774,8 +2890,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2795,7 +2910,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_databases { + } + else if self.opt.cmd_databases { if self.opt.cmd_delete { call_result = self._databases_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2811,13 +2927,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_flags { + } + else if self.opt.cmd_flags { if self.opt.cmd_list { call_result = self._flags_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_instances { + } + else if self.opt.cmd_instances { if self.opt.cmd_clone { call_result = self._instances_clone(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -2851,7 +2969,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_operations { + } + else if self.opt.cmd_operations { if self.opt.cmd_get { call_result = self._operations_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -2859,7 +2978,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_ssl_certs { + } + else if self.opt.cmd_ssl_certs { if self.opt.cmd_delete { call_result = self._ssl_certs_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -2871,13 +2991,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_tiers { + } + else if self.opt.cmd_tiers { if self.opt.cmd_list { call_result = self._tiers_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_users { + } + else if self.opt.cmd_users { if self.opt.cmd_delete { call_result = self._users_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -2909,21 +3031,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "sqladmin1-beta4-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "sqladmin1-beta4-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "sqladmin1-beta4", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "sqladmin1-beta4", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::SQLAdmin::new(hyper::Client::new(), auth), + hub: api::SQLAdmin::new(client, auth), }; match engine._doit(true) { @@ -2943,12 +3081,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + 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 e0f132efb8..1719e75c72 100644 --- a/gen/sqladmin1_beta4/Cargo.toml +++ b/gen/sqladmin1_beta4/Cargo.toml @@ -5,7 +5,7 @@ name = "google-sqladmin1_beta4" version = "0.1.5+20150305" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/cloud-sql/docs/admin-api/" diff --git a/gen/sqladmin1_beta4/README.md b/gen/sqladmin1_beta4/README.md index 1e57969784..c0a8c86c86 100644 --- a/gen/sqladmin1_beta4/README.md +++ b/gen/sqladmin1_beta4/README.md @@ -129,7 +129,7 @@ let mut hub = SQLAdmin::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: User = Default::default(); +let mut req = User::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/sqladmin1_beta4/src/cmn.rs b/gen/sqladmin1_beta4/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/sqladmin1_beta4/src/cmn.rs +++ b/gen/sqladmin1_beta4/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/sqladmin1_beta4/src/lib.rs b/gen/sqladmin1_beta4/src/lib.rs index 1b4f34e5ce..32c9b1a820 100644 --- a/gen/sqladmin1_beta4/src/lib.rs +++ b/gen/sqladmin1_beta4/src/lib.rs @@ -130,7 +130,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: User = Default::default(); +//! let mut req = User::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -309,7 +309,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -393,6 +393,21 @@ impl<'a, C, A> SQLAdmin<C, A> // ############ // SCHEMAS ### // ########## +/// Database instance operation errors list wrapper. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperationErrors { + /// This is always sql#operationErrors. + pub kind: Option<String>, + /// The list of errors encountered while processing this operation. + pub errors: Option<Vec<OperationError>>, +} + +impl Part for OperationErrors {} + + /// A database instance backup run resource. /// /// # Activities @@ -406,30 +421,30 @@ impl<'a, C, A> SQLAdmin<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BackupRun { /// The status of this run. - pub status: String, + pub status: Option<String>, /// This is always sql#backupRun. - pub kind: String, + pub kind: Option<String>, /// The start time of the backup window during which this the backup was attempted in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="windowStartTime")] - pub window_start_time: String, + pub window_start_time: Option<String>, /// A unique identifier for this backup run. Note that this is unique only within the scope of a particular Cloud SQL instance. - pub id: String, + pub id: Option<String>, /// Name of the database instance. - pub instance: String, + pub instance: Option<String>, /// The time the backup operation actually started in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, /// Information about why the backup operation failed. This is only present if the run has the FAILED status. - pub error: OperationError, + pub error: Option<OperationError>, /// The time the backup operation completed in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// The time the run was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="enqueuedTime")] - pub enqueued_time: String, + pub enqueued_time: Option<String>, /// The URI of this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl Resource for BackupRun {} @@ -444,10 +459,10 @@ impl ResponseResult for BackupRun {} pub struct SslCertDetail { /// The public information about the cert. #[serde(rename="certInfo")] - pub cert_info: SslCert, + pub cert_info: Option<SslCert>, /// The private key for the client cert, in pem format. Keep private in order to protect your security. #[serde(rename="certPrivateKey")] - pub cert_private_key: String, + pub cert_private_key: Option<String>, } impl Part for SslCertDetail {} @@ -469,28 +484,28 @@ impl Part for SslCertDetail {} pub struct SslCert { /// Serial number, as extracted from the certificate. #[serde(rename="certSerialNumber")] - pub cert_serial_number: String, + pub cert_serial_number: Option<String>, /// This is always sql#sslCert. - pub kind: String, + pub kind: Option<String>, /// Sha1 Fingerprint. #[serde(rename="sha1Fingerprint")] - pub sha1_fingerprint: String, + pub sha1_fingerprint: Option<String>, /// User supplied name. Constrained to [a-zA-Z.-_ ]+. #[serde(rename="commonName")] - pub common_name: String, + pub common_name: Option<String>, /// Name of the database instance. - pub instance: String, + pub instance: Option<String>, /// PEM representation. - pub cert: String, + pub cert: Option<String>, /// The time when the certificate expires in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="expirationTime")] - pub expiration_time: String, + pub expiration_time: Option<String>, /// The time when the certificate was created in RFC 3339 format, for example 2012-11-15T16:19:00.094Z #[serde(rename="createTime")] - pub create_time: String, + pub create_time: Option<String>, /// no description provided #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, } impl Resource for SslCert {} @@ -504,10 +519,10 @@ impl ResponseResult for SslCert {} #[derive(Default, Clone, Debug, Serialize)] pub struct RestoreBackupContext { /// This is always sql#restoreBackupContext. - pub kind: String, + pub kind: Option<String>, /// The ID of the backup run to restore from. #[serde(rename="backupRunId")] - pub backup_run_id: String, + pub backup_run_id: Option<String>, } impl Part for RestoreBackupContext {} @@ -521,7 +536,7 @@ impl Part for RestoreBackupContext {} pub struct ExportContextCsvExportOptions { /// The select query used to extract the data. #[serde(rename="selectQuery")] - pub select_query: String, + pub select_query: Option<String>, } impl NestedType for ExportContextCsvExportOptions {} @@ -535,15 +550,15 @@ impl Part for ExportContextCsvExportOptions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BackupConfiguration { /// This is always sql#backupConfiguration. - pub kind: String, + pub kind: Option<String>, /// Whether this configuration is enabled. - pub enabled: bool, + pub enabled: Option<bool>, /// Whether binary log is enabled. If backup configuration is disabled, binary log must be disabled as well. #[serde(rename="binaryLogEnabled")] - pub binary_log_enabled: bool, + pub binary_log_enabled: Option<bool>, /// Start time for the daily backup configuration in UTC timezone in the 24 hour format - HH:MM. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, } impl Part for BackupConfiguration {} @@ -575,10 +590,10 @@ impl RequestValue for InstancesCloneRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReplicaConfiguration { /// This is always sql#replicaConfiguration. - pub kind: String, - /// MySQL specific configuration when replicating from a MySQL on-premises master. + pub kind: Option<String>, + /// MySQL specific configuration when replicating from a MySQL on-premises master. Replication configuration information such as the username, password, certificates, and keys are not stored in the instance metadata. The configuration information is used only to set up the replication connection and is stored by MySQL in a file named master.info in the data directory. #[serde(rename="mysqlReplicaConfiguration")] - pub mysql_replica_configuration: MySqlReplicaConfiguration, + pub mysql_replica_configuration: Option<MySqlReplicaConfiguration>, } impl Part for ReplicaConfiguration {} @@ -596,13 +611,13 @@ impl Part for ReplicaConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SslCertsInsertResponse { /// This is always sql#sslCertsInsert. - pub kind: String, + pub kind: Option<String>, /// The new client certificate and private key. The new certificate will not work until the instance is restarted. #[serde(rename="clientCert")] - pub client_cert: SslCertDetail, + pub client_cert: Option<SslCertDetail>, /// The server Certificate Authority's certificate. If this is missing you can force a new one to be generated by calling resetSslConfig method on instances resource. #[serde(rename="serverCaCert")] - pub server_ca_cert: SslCert, + pub server_ca_cert: Option<SslCert>, } impl ResponseResult for SslCertsInsertResponse {} @@ -621,11 +636,11 @@ impl ResponseResult for SslCertsInsertResponse {} pub struct OperationsListResponse { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of operation resources. - pub items: Vec<Operation>, + pub items: Option<Vec<Operation>>, /// This is always sql#operationsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for OperationsListResponse {} @@ -643,9 +658,9 @@ impl ResponseResult for OperationsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TiersListResponse { /// List of tiers. - pub items: Vec<Tier>, + pub items: Option<Vec<Tier>>, /// This is always sql#tiersList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for TiersListResponse {} @@ -661,16 +676,16 @@ pub struct ImportContext { /// SQL: The file contains SQL statements. /// CSV: The file contains CSV data. #[serde(rename="fileType")] - pub file_type: String, + pub file_type: Option<String>, /// Options for importing data as CSV. #[serde(rename="csvImportOptions")] - pub csv_import_options: ImportContextCsvImportOptions, + pub csv_import_options: Option<ImportContextCsvImportOptions>, /// A path to the file in Google Cloud Storage from which the import is made. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are supported when fileType is SQL. - pub uri: String, + pub uri: Option<String>, /// This is always sql#importContext. - pub kind: String, + pub kind: Option<String>, /// The database (for example, guestbook) to which the import is made. If fileType is SQL and no database is specified, it is assumed that the database is specified in the file to be imported. If fileType is CSV, it must be specified. - pub database: String, + pub database: Option<String>, } impl Part for ImportContext {} @@ -684,10 +699,10 @@ impl Part for ImportContext {} pub struct IpMapping { /// The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. This field is only available when the IP is scheduled to be retired. #[serde(rename="timeToRetire")] - pub time_to_retire: String, + pub time_to_retire: Option<String>, /// The IP address assigned. #[serde(rename="ipAddress")] - pub ip_address: String, + pub ip_address: Option<String>, } impl Part for IpMapping {} @@ -701,21 +716,21 @@ impl Part for IpMapping {} pub struct ExportContext { /// Options for exporting data as CSV. #[serde(rename="csvExportOptions")] - pub csv_export_options: ExportContextCsvExportOptions, + pub csv_export_options: Option<ExportContextCsvExportOptions>, /// This is always sql#exportContext. - pub kind: String, + pub kind: Option<String>, /// Databases (for example, guestbook) from which the export is made. If fileType is SQL and no database is specified, all databases are exported. If fileType is CSV, you can optionally specify at most one database to export. If csvExportOptions.selectQuery also specifies the database, this field will be ignored. - pub databases: Vec<String>, + pub databases: Option<Vec<String>>, /// The file type for the specified uri. /// SQL: The file contains SQL statements. /// CSV: The file contains CSV data. #[serde(rename="fileType")] - pub file_type: String, + pub file_type: Option<String>, /// Options for exporting data as SQL statements. #[serde(rename="sqlExportOptions")] - pub sql_export_options: ExportContextSqlExportOptions, + pub sql_export_options: Option<ExportContextSqlExportOptions>, /// The path to the file in Google Cloud Storage where the export will be stored. The URI is in the form gs://bucketName/fileName. If the file already exists, the operation fails. If fileType is SQL and the filename ends with .gz, the contents are compressed. - pub uri: String, + pub uri: Option<String>, } impl Part for ExportContext {} @@ -734,11 +749,11 @@ impl Part for ExportContext {} pub struct BackupRunsListResponse { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of backup runs in reverse chronological order of the enqueued time. - pub items: Vec<BackupRun>, + pub items: Option<Vec<BackupRun>>, /// This is always sql#backupRunsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for BackupRunsListResponse {} @@ -791,9 +806,9 @@ impl ResponseResult for Database {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ImportContextCsvImportOptions { /// The table to which CSV data is imported. - pub table: String, + pub table: Option<String>, /// The columns to which CSV data is imported. If not specified, all columns of the database table are loaded with CSV data. - pub columns: Vec<String>, + pub columns: Option<Vec<String>>, } impl NestedType for ImportContextCsvImportOptions {} @@ -808,13 +823,13 @@ impl Part for ImportContextCsvImportOptions {} pub struct IpConfiguration { /// Whether the mysqld should default to 'REQUIRE X509' for users connecting over IP. #[serde(rename="requireSsl")] - pub require_ssl: bool, + pub require_ssl: Option<bool>, /// Whether the instance should be assigned an IP address or not. #[serde(rename="ipv4Enabled")] - pub ipv4_enabled: bool, + pub ipv4_enabled: Option<bool>, /// The list of external networks that are allowed to connect to the instance using the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). #[serde(rename="authorizedNetworks")] - pub authorized_networks: Vec<AclEntry>, + pub authorized_networks: Option<Vec<AclEntry>>, } impl Part for IpConfiguration {} @@ -827,11 +842,11 @@ impl Part for IpConfiguration {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperationError { /// This is always sql#operationError. - pub kind: String, + pub kind: Option<String>, /// Identifies the specific error that occurred. - pub code: String, + pub code: Option<String>, /// Additional information about the error encountered. - pub message: String, + pub message: Option<String>, } impl Part for OperationError {} @@ -942,12 +957,12 @@ impl Resource for Tier {} pub struct CloneContext { /// Binary log coordinates, if specified, indentify the the position up to which the source instance should be cloned. If not specified, the source instance is cloned up to the most recent binary log coordintes. #[serde(rename="binLogCoordinates")] - pub bin_log_coordinates: BinLogCoordinates, + pub bin_log_coordinates: Option<BinLogCoordinates>, /// This is always sql#cloneContext. - pub kind: String, + pub kind: Option<String>, /// Name of the Cloud SQL instance to be created as a clone. #[serde(rename="destinationInstanceName")] - pub destination_instance_name: String, + pub destination_instance_name: Option<String>, } impl Part for CloneContext {} @@ -979,9 +994,9 @@ impl RequestValue for InstancesRestoreBackupRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatabaseFlags { /// The name of the flag. These flags are passed at instance startup, so include both MySQL server options and MySQL system variables. Flags should be specified with underscores, not hyphens. For more information, see Configuring MySQL Flags in the Google Cloud SQL documentation, as well as the official MySQL documentation for server options and system variables. - pub name: String, + pub name: Option<String>, /// The value of the flag. Booleans should be set to on for true and off for false. This field must be omitted if the flag doesn't take a value. - pub value: String, + pub value: Option<String>, } impl Part for DatabaseFlags {} @@ -999,9 +1014,9 @@ impl Part for DatabaseFlags {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FlagsListResponse { /// List of flags. - pub items: Vec<Flag>, + pub items: Option<Vec<Flag>>, /// This is always sql#flagsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for FlagsListResponse {} @@ -1014,35 +1029,35 @@ impl ResponseResult for FlagsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MySqlReplicaConfiguration { /// The username for the replication connection. - pub username: String, + pub username: Option<String>, /// This is always sql#mysqlReplicaConfiguration. - pub kind: String, + pub kind: Option<String>, /// The password for the replication connection. - pub password: String, + pub password: Option<String>, /// A list of permissible ciphers to use for SSL encryption. #[serde(rename="sslCipher")] - pub ssl_cipher: String, + pub ssl_cipher: Option<String>, /// PEM representation of the trusted CA's x509 certificate. #[serde(rename="caCertificate")] - pub ca_certificate: String, + pub ca_certificate: Option<String>, /// PEM representation of the slave's x509 certificate. #[serde(rename="clientCertificate")] - pub client_certificate: String, + pub client_certificate: Option<String>, /// Interval in milliseconds between replication heartbeats. #[serde(rename="masterHeartbeatPeriod")] - pub master_heartbeat_period: String, + pub master_heartbeat_period: Option<String>, /// Whether or not to check the master's Common Name value in the certificate that it sends during the SSL handshake. #[serde(rename="verifyServerCertificate")] - pub verify_server_certificate: bool, + pub verify_server_certificate: Option<bool>, /// Path to a SQL dump file in Google Cloud Storage from which the slave instance is to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip files (.gz) are also supported. Dumps should have the binlog co-ordinates from which replication should begin. This can be accomplished by setting --master-data to 1 when using mysqldump. #[serde(rename="dumpFilePath")] - pub dump_file_path: String, + pub dump_file_path: Option<String>, /// Seconds to wait between connect retries. MySQL's default is 60 seconds. #[serde(rename="connectRetryInterval")] - pub connect_retry_interval: i32, + pub connect_retry_interval: Option<i32>, /// PEM representation of the slave's private key. The corresponsing public key is encoded in the client's certificate. #[serde(rename="clientKey")] - pub client_key: String, + pub client_key: Option<String>, } impl Part for MySqlReplicaConfiguration {} @@ -1056,44 +1071,44 @@ impl Part for MySqlReplicaConfiguration {} pub struct Settings { /// The database flags passed to the instance at startup. #[serde(rename="databaseFlags")] - pub database_flags: Vec<DatabaseFlags>, + pub database_flags: Option<Vec<DatabaseFlags>>, /// This is always sql#settings. - pub kind: String, + pub kind: Option<String>, /// The App Engine app IDs that can access this instance. #[serde(rename="authorizedGaeApplications")] - pub authorized_gae_applications: Vec<String>, + pub authorized_gae_applications: Option<Vec<String>>, /// The activation policy for this instance. This specifies when the instance should be activated and is applicable only when the instance state is RUNNABLE. This can be one of the following. /// ALWAYS: The instance should always be active. /// NEVER: The instance should never be activated. /// ON_DEMAND: The instance is activated upon receiving requests. #[serde(rename="activationPolicy")] - pub activation_policy: String, + pub activation_policy: Option<String>, /// The daily backup configuration for the instance. #[serde(rename="backupConfiguration")] - pub backup_configuration: BackupConfiguration, + pub backup_configuration: Option<BackupConfiguration>, /// The settings for IP Management. This allows to enable or disable the instance IP and manage which external networks can connect to the instance. #[serde(rename="ipConfiguration")] - pub ip_configuration: IpConfiguration, - /// no description provided + pub ip_configuration: Option<IpConfiguration>, + /// Configuration specific to read replica instances. Indicates whether database flags for crash-safe replication are enabled. #[serde(rename="crashSafeReplicationEnabled")] - pub crash_safe_replication_enabled: bool, + pub crash_safe_replication_enabled: Option<bool>, /// Configuration specific to read replica instances. Indicates whether replication is enabled or not. #[serde(rename="databaseReplicationEnabled")] - pub database_replication_enabled: bool, + pub database_replication_enabled: Option<bool>, /// The type of replication this instance uses. This can be either ASYNCHRONOUS or SYNCHRONOUS. #[serde(rename="replicationType")] - pub replication_type: String, + pub replication_type: Option<String>, /// The tier of service for this instance, for example D1, D2. For more information, see pricing. - pub tier: String, + pub tier: Option<String>, /// The pricing plan for this instance. This can be either PER_USE or PACKAGE. #[serde(rename="pricingPlan")] - pub pricing_plan: String, + pub pricing_plan: Option<String>, /// The version of instance settings. This is a required field for update method to make sure concurrent updates are handled properly. During update, use the most recent settingsVersion value for this instance and do not try to update this value. #[serde(rename="settingsVersion")] - pub settings_version: String, + pub settings_version: Option<String>, /// The location preference settings. This allows the instance to be located as near as possible to either an App Engine app or GCE zone for better performance. #[serde(rename="locationPreference")] - pub location_preference: LocationPreference, + pub location_preference: Option<LocationPreference>, } impl Part for Settings {} @@ -1130,9 +1145,9 @@ impl RequestValue for SslCertsInsertRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SslCertsListResponse { /// List of client certificates for the instance. - pub items: Vec<SslCert>, + pub items: Option<Vec<SslCert>>, /// This is always sql#sslCertsList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for SslCertsListResponse {} @@ -1146,13 +1161,13 @@ impl ResponseResult for SslCertsListResponse {} pub struct AclEntry { /// The time when this access control entry expires in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="expirationTime")] - pub expiration_time: String, + pub expiration_time: Option<String>, /// This is always sql#aclEntry. - pub kind: String, + pub kind: Option<String>, /// The whitelisted value for the access control list. - pub value: String, + pub value: Option<String>, /// An optional label to identify this entry. - pub name: String, + pub name: Option<String>, } impl Part for AclEntry {} @@ -1171,30 +1186,16 @@ impl Part for AclEntry {} pub struct InstancesListResponse { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of database instance resources. - pub items: Vec<DatabaseInstance>, + pub items: Option<Vec<DatabaseInstance>>, /// This is always sql#instancesList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for InstancesListResponse {} -/// If errors occurred during processing of this operation, this field will be populated. -/// -/// This type is not used in any activity, and only used as *part* of another schema. -/// -#[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct OperationErrorNested { - /// The list of errors encountered while processing this operation. - pub errors: Vec<OperationError>, -} - -impl NestedType for OperationErrorNested {} -impl Part for OperationErrorNested {} - - /// Database instance export request. /// /// # Activities @@ -1227,11 +1228,11 @@ impl RequestValue for InstancesExportRequest {} pub struct UsersListResponse { /// An identifier that uniquely identifies the operation. You can use this identifier to retrieve the Operations resource that has information about the operation. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// List of user resources in the instance. - pub items: Vec<User>, + pub items: Option<Vec<User>>, /// This is always sql#usersList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for UsersListResponse {} @@ -1349,9 +1350,9 @@ impl RequestValue for InstancesImportRequest {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DatabasesListResponse { /// List of database resources in the instance. - pub items: Vec<Database>, + pub items: Option<Vec<Database>>, /// This is always sql#databasesList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for DatabasesListResponse {} @@ -1365,12 +1366,12 @@ impl ResponseResult for DatabasesListResponse {} pub struct BinLogCoordinates { /// Position (offset) within the binary log file. #[serde(rename="binLogPosition")] - pub bin_log_position: String, + pub bin_log_position: Option<String>, /// This is always sql#binLogCoordinates. - pub kind: String, + pub kind: Option<String>, /// Name of the binary log file for a Cloud SQL instance. #[serde(rename="binLogFileName")] - pub bin_log_file_name: String, + pub bin_log_file_name: Option<String>, } impl Part for BinLogCoordinates {} @@ -1410,45 +1411,45 @@ impl Part for BinLogCoordinates {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Operation { /// The status of an operation. Valid values are PENDING, RUNNING, DONE, UNKNOWN. - pub status: String, + pub status: Option<String>, /// The context for import operation, if applicable. #[serde(rename="importContext")] - pub import_context: ImportContext, + pub import_context: Option<ImportContext>, /// This is always sql#operation. - pub kind: String, + pub kind: Option<String>, /// An identifier that uniquely identifies the operation. You can use this identifier to retrieve the Operations resource that has information about the operation. - pub name: String, + pub name: Option<String>, /// The context for export operation, if applicable. #[serde(rename="exportContext")] - pub export_context: ExportContext, + pub export_context: Option<ExportContext>, /// The project ID of the target instance related to this operation. #[serde(rename="targetProject")] - pub target_project: String, + pub target_project: Option<String>, /// Name of the database instance related to this operation. #[serde(rename="targetId")] - pub target_id: String, + pub target_id: Option<String>, /// The type of the operation. Valid values are CREATE, DELETE, UPDATE, RESTART, IMPORT, EXPORT, BACKUP_VOLUME, RESTORE_VOLUME, CREATE_USER, DELETE_USER, CREATE_DATABASE, DELETE_DATABASE . #[serde(rename="operationType")] - pub operation_type: String, + pub operation_type: Option<String>, /// The time this operation was enqueued in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="insertTime")] - pub insert_time: String, + pub insert_time: Option<String>, /// The URI of the instance related to the operation. #[serde(rename="targetLink")] - pub target_link: String, + pub target_link: Option<String>, /// The time this operation actually started in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="startTime")] - pub start_time: String, - /// If errors occurred during processing of this operation, this field will be populated. - pub error: OperationErrorNested, + pub start_time: Option<String>, + /// no description provided + pub error: Option<OperationErrors>, /// The time this operation finished in UTC timezone in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// The URI of this resource. #[serde(rename="selfLink")] - pub self_link: String, + pub self_link: Option<String>, /// The email address of the user who initiated this operation. - pub user: String, + pub user: Option<String>, } impl Resource for Operation {} @@ -1462,12 +1463,12 @@ impl ResponseResult for Operation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocationPreference { /// This is always sql#locationPreference. - pub kind: String, + pub kind: Option<String>, /// The AppEngine application to follow, it must be in the same region as the Cloud SQL instance. #[serde(rename="followGaeApplication")] - pub follow_gae_application: String, + pub follow_gae_application: Option<String>, /// The preferred Compute Engine zone (e.g. us-centra1-a, us-central1-b, etc.). - pub zone: String, + pub zone: Option<String>, } impl Part for LocationPreference {} @@ -1480,7 +1481,7 @@ impl Part for LocationPreference {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ExportContextSqlExportOptions { /// Tables to export, or that were exported, from the specified database. If you specify tables, specify one and only one database. - pub tables: Vec<String>, + pub tables: Option<Vec<String>>, } impl NestedType for ExportContextSqlExportOptions {} @@ -1494,10 +1495,10 @@ impl Part for ExportContextSqlExportOptions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OnPremisesConfiguration { /// This is always sql#onPremisesConfiguration. - pub kind: String, + pub kind: Option<String>, /// The host and port of the on-premises instance in host:port format #[serde(rename="hostPort")] - pub host_port: String, + pub host_port: Option<String>, } impl Part for OnPremisesConfiguration {} @@ -2668,16 +2669,20 @@ impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2924,16 +2929,20 @@ impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3164,16 +3173,20 @@ impl<'a, C, A> TierListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3396,16 +3409,20 @@ impl<'a, C, A> UserListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3642,16 +3659,20 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3821,7 +3842,7 @@ impl<'a, C, A> UserDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3919,16 +3940,20 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4111,7 +4136,7 @@ impl<'a, C, A> UserUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: User = Default::default(); +/// let mut req = User::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4205,16 +4230,20 @@ impl<'a, C, A> UserInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4460,16 +4489,20 @@ impl<'a, C, A> InstanceResetSslConfigCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4702,16 +4735,20 @@ impl<'a, C, A> InstancePromoteReplicaCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -4944,16 +4981,20 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5103,7 +5144,7 @@ impl<'a, C, A> InstanceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DatabaseInstance = Default::default(); +/// let mut req = DatabaseInstance::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5197,16 +5238,20 @@ impl<'a, C, A> InstancePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5452,16 +5497,20 @@ impl<'a, C, A> InstanceRestartCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -5694,16 +5743,20 @@ impl<'a, C, A> InstanceDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5936,16 +5989,20 @@ impl<'a, C, A> InstanceStopReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6178,16 +6235,20 @@ impl<'a, C, A> InstanceStartReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6337,7 +6398,7 @@ impl<'a, C, A> InstanceStartReplicaCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DatabaseInstance = Default::default(); +/// let mut req = DatabaseInstance::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6429,16 +6490,20 @@ impl<'a, C, A> InstanceInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6682,16 +6747,20 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6845,7 +6914,7 @@ impl<'a, C, A> InstanceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstancesImportRequest = Default::default(); +/// let mut req = InstancesImportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6939,16 +7008,20 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7111,7 +7184,7 @@ impl<'a, C, A> InstanceImportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: DatabaseInstance = Default::default(); +/// let mut req = DatabaseInstance::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7205,16 +7278,20 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7377,7 +7454,7 @@ impl<'a, C, A> InstanceUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstancesCloneRequest = Default::default(); +/// let mut req = InstancesCloneRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7471,16 +7548,20 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7643,7 +7724,7 @@ impl<'a, C, A> InstanceCloneCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstancesExportRequest = Default::default(); +/// let mut req = InstancesExportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7737,16 +7818,20 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7909,7 +7994,7 @@ impl<'a, C, A> InstanceExportCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InstancesRestoreBackupRequest = Default::default(); +/// let mut req = InstancesRestoreBackupRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8003,16 +8088,20 @@ impl<'a, C, A> InstanceRestoreBackupCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8230,16 +8319,20 @@ impl<'a, C, A> FlagListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8454,16 +8547,20 @@ impl<'a, C, A> DatabaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8623,7 +8720,7 @@ impl<'a, C, A> DatabaseDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Database = Default::default(); +/// let mut req = Database::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8719,16 +8816,20 @@ impl<'a, C, A> DatabasePatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8984,16 +9085,20 @@ impl<'a, C, A> DatabaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9143,7 +9248,7 @@ impl<'a, C, A> DatabaseListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Database = Default::default(); +/// let mut req = Database::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9237,16 +9342,20 @@ impl<'a, C, A> DatabaseInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9494,16 +9603,20 @@ impl<'a, C, A> DatabaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9663,7 +9776,7 @@ impl<'a, C, A> DatabaseGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Database = Default::default(); +/// let mut req = Database::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9759,16 +9872,20 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9941,7 +10058,7 @@ impl<'a, C, A> DatabaseUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: SslCertsInsertRequest = Default::default(); +/// let mut req = SslCertsInsertRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10035,16 +10152,20 @@ impl<'a, C, A> SslCertInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10292,16 +10413,20 @@ impl<'a, C, A> SslCertDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10546,16 +10671,20 @@ impl<'a, C, A> SslCertGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10798,16 +10927,20 @@ impl<'a, C, A> SslCertListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11050,16 +11183,20 @@ impl<'a, C, A> BackupRunListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11308,16 +11445,20 @@ impl<'a, C, A> BackupRunGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/storage1-cli/Cargo.toml b/gen/storage1-cli/Cargo.toml index 8cc39b4298..feec34a55c 100644 --- a/gen/storage1-cli/Cargo.toml +++ b/gen/storage1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-storage1-cli" version = "0.0.1+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/storage/docs/json_api/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/storage1-cli/mkdocs.yml b/gen/storage1-cli/mkdocs.yml index 5c351c1309..e03db8afcf 100644 --- a/gen/storage1-cli/mkdocs.yml +++ b/gen/storage1-cli/mkdocs.yml @@ -41,6 +41,7 @@ pages: - ['objects_insert.md', 'Objects', 'Insert'] - ['objects_list.md', 'Objects', 'List'] - ['objects_patch.md', 'Objects', 'Patch'] +- ['objects_rewrite.md', 'Objects', 'Rewrite'] - ['objects_update.md', 'Objects', 'Update'] - ['objects_watch-all.md', 'Objects', 'Watch All'] diff --git a/gen/storage1-cli/src/cmn.rs b/gen/storage1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/storage1-cli/src/cmn.rs +++ b/gen/storage1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/storage1-cli/src/main.rs b/gen/storage1-cli/src/main.rs index c3d1b62e63..c822056b2b 100644 --- a/gen/storage1-cli/src/main.rs +++ b/gen/storage1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -50,6 +51,7 @@ Usage: 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 @@ -65,6 +67,12 @@ Configuration: 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. "); mod cmn; @@ -88,7 +96,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.bucket_access_controls().delete(&self.opt.arg_bucket, &self.opt.arg_entity); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -119,7 +127,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -130,7 +137,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.bucket_access_controls().get(&self.opt.arg_bucket, &self.opt.arg_entity); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -162,8 +169,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -172,10 +178,10 @@ impl Engine { fn _bucket_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::BucketAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -195,9 +201,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -234,11 +241,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -265,8 +272,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -277,7 +283,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.bucket_access_controls().list(&self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -309,8 +315,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -319,10 +324,10 @@ impl Engine { fn _bucket_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::BucketAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -342,9 +347,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -381,11 +387,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -412,8 +418,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -422,10 +427,10 @@ impl Engine { fn _bucket_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::BucketAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -445,9 +450,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -484,11 +490,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -515,8 +521,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -527,7 +532,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.buckets().delete(&self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "if-metageneration-not-match" => { call = call.if_metageneration_not_match(value.unwrap_or("")); @@ -564,7 +569,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -575,7 +579,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.buckets().get(&self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -616,8 +620,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -626,10 +629,10 @@ impl Engine { fn _buckets_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Bucket = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -658,9 +661,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -691,11 +695,11 @@ impl Engine { match &field_name.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); - request.website.as_mut().unwrap().not_found_page = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); }, "website.main-page-suffix" => { request_website_init(&mut request); - request.website.as_mut().unwrap().main_page_suffix = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().main_page_suffix = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_website_init(&mut request); @@ -707,11 +711,11 @@ impl Engine { }, "logging.log-object-prefix" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_object_prefix = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_object_prefix = Some(value.unwrap_or("").to_string()); }, "logging.log-bucket" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_bucket = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_bucket = Some(value.unwrap_or("").to_string()); }, "name" => { request_logging_init(&mut request); @@ -739,11 +743,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "id" => { request_owner_init(&mut request); @@ -751,7 +755,7 @@ impl Engine { }, "versioning.enabled" => { request_versioning_init(&mut request); - request.versioning.as_mut().unwrap().enabled = arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean"); + request.versioning.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean")); }, "storage-class" => { request_versioning_init(&mut request); @@ -774,8 +778,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -786,7 +789,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.buckets().list(&self.opt.arg_project); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -830,8 +833,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -840,10 +842,10 @@ impl Engine { fn _buckets_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Bucket = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -878,9 +880,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -911,11 +914,11 @@ impl Engine { match &field_name.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); - request.website.as_mut().unwrap().not_found_page = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); }, "website.main-page-suffix" => { request_website_init(&mut request); - request.website.as_mut().unwrap().main_page_suffix = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().main_page_suffix = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_website_init(&mut request); @@ -927,11 +930,11 @@ impl Engine { }, "logging.log-object-prefix" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_object_prefix = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_object_prefix = Some(value.unwrap_or("").to_string()); }, "logging.log-bucket" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_bucket = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_bucket = Some(value.unwrap_or("").to_string()); }, "name" => { request_logging_init(&mut request); @@ -959,11 +962,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "id" => { request_owner_init(&mut request); @@ -971,7 +974,7 @@ impl Engine { }, "versioning.enabled" => { request_versioning_init(&mut request); - request.versioning.as_mut().unwrap().enabled = arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean"); + request.versioning.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean")); }, "storage-class" => { request_versioning_init(&mut request); @@ -994,8 +997,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1004,10 +1006,10 @@ impl Engine { fn _buckets_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Bucket = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -1042,9 +1044,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1075,11 +1078,11 @@ impl Engine { match &field_name.to_string()[..] { "website.not-found-page" => { request_website_init(&mut request); - request.website.as_mut().unwrap().not_found_page = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().not_found_page = Some(value.unwrap_or("").to_string()); }, "website.main-page-suffix" => { request_website_init(&mut request); - request.website.as_mut().unwrap().main_page_suffix = value.unwrap_or("").to_string(); + request.website.as_mut().unwrap().main_page_suffix = Some(value.unwrap_or("").to_string()); }, "self-link" => { request_website_init(&mut request); @@ -1091,11 +1094,11 @@ impl Engine { }, "logging.log-object-prefix" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_object_prefix = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_object_prefix = Some(value.unwrap_or("").to_string()); }, "logging.log-bucket" => { request_logging_init(&mut request); - request.logging.as_mut().unwrap().log_bucket = value.unwrap_or("").to_string(); + request.logging.as_mut().unwrap().log_bucket = Some(value.unwrap_or("").to_string()); }, "name" => { request_logging_init(&mut request); @@ -1123,11 +1126,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "id" => { request_owner_init(&mut request); @@ -1135,7 +1138,7 @@ impl Engine { }, "versioning.enabled" => { request_versioning_init(&mut request); - request.versioning.as_mut().unwrap().enabled = arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean"); + request.versioning.as_mut().unwrap().enabled = Some(arg_from_str(value.unwrap_or("false"), err, "versioning.enabled", "boolean")); }, "storage-class" => { request_versioning_init(&mut request); @@ -1158,8 +1161,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1168,10 +1170,10 @@ impl Engine { fn _channels_stop(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Channel = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1191,9 +1193,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1215,9 +1218,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -1247,7 +1251,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1258,7 +1261,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.default_object_access_controls().delete(&self.opt.arg_bucket, &self.opt.arg_entity); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1289,7 +1292,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1300,7 +1302,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.default_object_access_controls().get(&self.opt.arg_bucket, &self.opt.arg_entity); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1332,8 +1334,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1342,10 +1343,10 @@ impl Engine { fn _default_object_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1365,9 +1366,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1410,11 +1412,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -1441,8 +1443,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1453,7 +1454,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.default_object_access_controls().list(&self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "if-metageneration-not-match" => { call = call.if_metageneration_not_match(value.unwrap_or("")); @@ -1491,8 +1492,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1501,10 +1501,10 @@ impl Engine { fn _default_object_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1524,9 +1524,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1569,11 +1570,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -1600,8 +1601,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1610,10 +1610,10 @@ impl Engine { fn _default_object_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -1633,9 +1633,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1678,11 +1679,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -1709,8 +1710,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1721,7 +1721,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.object_access_controls().delete(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -1755,7 +1755,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1766,7 +1765,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.object_access_controls().get(&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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -1801,8 +1800,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1811,10 +1809,10 @@ impl Engine { fn _object_access_controls_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -1837,9 +1835,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1882,11 +1881,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -1913,8 +1912,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1925,7 +1923,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.object_access_controls().list(&self.opt.arg_bucket, &self.opt.arg_object); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -1960,8 +1958,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1970,10 +1967,10 @@ impl Engine { fn _object_access_controls_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -1996,9 +1993,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2041,11 +2039,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -2072,8 +2070,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2082,10 +2079,10 @@ impl Engine { fn _object_access_controls_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ObjectAccessControl = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "generation" => { call = call.generation(value.unwrap_or("")); @@ -2108,9 +2105,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2153,11 +2151,11 @@ impl Engine { }, "project-team.project-number" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().project_number = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().project_number = Some(value.unwrap_or("").to_string()); }, "project-team.team" => { request_project_team_init(&mut request); - request.project_team.as_mut().unwrap().team = value.unwrap_or("").to_string(); + request.project_team.as_mut().unwrap().team = Some(value.unwrap_or("").to_string()); }, "email" => { request_project_team_init(&mut request); @@ -2184,8 +2182,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2194,11 +2191,11 @@ impl Engine { fn _objects_compose(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ComposeRequest = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "if-metageneration-match" => { call = call.if_metageneration_match(value.unwrap_or("")); @@ -2206,15 +2203,6 @@ impl Engine { "if-generation-match" => { call = call.if_generation_match(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "destination-predefined-acl" => { call = call.destination_predefined_acl(value.unwrap_or("")); }, @@ -2239,9 +2227,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2280,11 +2269,11 @@ impl Engine { }, "destination.owner.entity-id" => { request_destination_owner_init(&mut request); - request.destination.as_mut().unwrap().owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + request.destination.as_mut().unwrap().owner.as_mut().unwrap().entity_id = Some(value.unwrap_or("").to_string()); }, "destination.owner.entity" => { request_destination_owner_init(&mut request); - request.destination.as_mut().unwrap().owner.as_mut().unwrap().entity = value.unwrap_or("").to_string(); + request.destination.as_mut().unwrap().owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "destination.cache-control" => { request_destination_owner_init(&mut request); @@ -2317,9 +2306,10 @@ impl Engine { "destination.metadata" => { request_destination_owner_init(&mut request); if request.destination.as_mut().unwrap().metadata.is_none() { - request.destination.as_mut().unwrap().metadata = Some(Default::default()); + request.destination.as_mut().unwrap().metadata = Some(Default::default()); } - request.destination.as_mut().unwrap().metadata.as_mut().unwrap().push(value.unwrap_or("").to_string()); + let (key, value) = parse_kv_arg(value.unwrap_or(""), err, true); + request.destination.as_mut().unwrap().metadata.as_mut().unwrap().insert(key.to_string(), value.unwrap_or("").to_string()); }, "destination.updated" => { request_destination_owner_init(&mut request); @@ -2378,9 +2368,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -2392,11 +2381,11 @@ impl Engine { fn _objects_copy(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Object = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source-generation" => { call = call.source_generation(value.unwrap_or("")); @@ -2428,15 +2417,6 @@ impl Engine { "if-generation-match" => { call = call.if_generation_match(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "destination-predefined-acl" => { call = call.destination_predefined_acl(value.unwrap_or("")); }, @@ -2461,9 +2441,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2488,11 +2469,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "cache-control" => { request_owner_init(&mut request); @@ -2525,9 +2506,10 @@ impl Engine { "metadata" => { request_owner_init(&mut request); if request.metadata.is_none() { - request.metadata = Some(Default::default()); + request.metadata = Some(Default::default()); } - request.metadata.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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); @@ -2586,9 +2568,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -2602,7 +2583,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.objects().delete(&self.opt.arg_bucket, &self.opt.arg_object); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "if-metageneration-not-match" => { call = call.if_metageneration_not_match(value.unwrap_or("")); @@ -2648,7 +2629,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2660,7 +2640,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.objects().get(&self.opt.arg_bucket, &self.opt.arg_object); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -2680,15 +2660,6 @@ impl Engine { "generation" => { call = call.generation(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "alt" |"fields" |"key" @@ -2722,9 +2693,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -2736,10 +2706,10 @@ impl Engine { fn _objects_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Object = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -2762,15 +2732,6 @@ impl Engine { "if-generation-match" => { call = call.if_generation_match(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "content-encoding" => { call = call.content_encoding(value.unwrap_or("")); }, @@ -2792,9 +2753,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2819,11 +2781,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "cache-control" => { request_owner_init(&mut request); @@ -2856,9 +2818,10 @@ impl Engine { "metadata" => { request_owner_init(&mut request); if request.metadata.is_none() { - request.metadata = Some(Default::default()); + request.metadata = Some(Default::default()); } - request.metadata.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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); @@ -2927,8 +2890,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); io::copy(&mut response, &mut ostream).unwrap(); None } @@ -2940,7 +2902,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.objects().list(&self.opt.arg_bucket); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "versions" => { call = call.versions(arg_from_str(value.unwrap_or("false"), err, "versions", "boolean")); @@ -2990,8 +2952,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3000,10 +2961,10 @@ impl Engine { fn _objects_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Object = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -3026,15 +2987,6 @@ impl Engine { "generation" => { call = call.generation(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "alt" |"fields" |"key" @@ -3053,9 +3005,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3080,11 +3033,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "cache-control" => { request_owner_init(&mut request); @@ -3117,9 +3070,10 @@ impl Engine { "metadata" => { request_owner_init(&mut request); if request.metadata.is_none() { - request.metadata = Some(Default::default()); + request.metadata = Some(Default::default()); } - request.metadata.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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); @@ -3178,8 +3132,205 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + 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); + 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("")); + }, + "rewrite-token" => { + call = call.rewrite_token(value.unwrap_or("")); + }, + "projection" => { + call = call.projection(value.unwrap_or("")); + }, + "max-bytes-rewritten-per-call" => { + call = call.max_bytes_rewritten_per_call(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" => { + let map = [ + ("oauth-token", "oauth_token"), + ("pretty-print", "prettyPrint"), + ("quota-user", "quotaUser"), + ("user-ip", "userIp"), + ]; + call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) + }, + _ => 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); + 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 } } @@ -3188,11 +3339,11 @@ impl Engine { fn _objects_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Object = Default::default(); + 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); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -3215,15 +3366,6 @@ impl Engine { "generation" => { call = call.generation(value.unwrap_or("")); }, - "encryption-key-hash" => { - call = call.encryption_key_hash(value.unwrap_or("")); - }, - "encryption-key" => { - call = call.encryption_key(value.unwrap_or("")); - }, - "encryption-algorithm" => { - call = call.encryption_algorithm(value.unwrap_or("")); - }, "alt" |"fields" |"key" @@ -3245,9 +3387,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3272,11 +3415,11 @@ impl Engine { }, "owner.entity-id" => { request_owner_init(&mut request); - request.owner.as_mut().unwrap().entity_id = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.owner.as_mut().unwrap().entity = Some(value.unwrap_or("").to_string()); }, "cache-control" => { request_owner_init(&mut request); @@ -3309,9 +3452,10 @@ impl Engine { "metadata" => { request_owner_init(&mut request); if request.metadata.is_none() { - request.metadata = Some(Default::default()); + request.metadata = Some(Default::default()); } - request.metadata.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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); @@ -3370,9 +3514,8 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } @@ -3384,10 +3527,10 @@ impl Engine { fn _objects_watch_all(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Channel = Default::default(); + let mut request = api::Channel::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "versions" => { call = call.versions(arg_from_str(value.unwrap_or("false"), err, "versions", "boolean")); @@ -3425,9 +3568,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3449,9 +3593,10 @@ impl Engine { }, "params" => { if request.params.is_none() { - request.params = Some(Default::default()); + request.params = Some(Default::default()); } - request.params.as_mut().unwrap().push(value.unwrap_or("").to_string()); + 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()); @@ -3482,8 +3627,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3511,7 +3655,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_buckets { + } + else if self.opt.cmd_buckets { if self.opt.cmd_delete { call_result = self._buckets_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3527,13 +3672,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_channels { + } + else if self.opt.cmd_channels { if self.opt.cmd_stop { call_result = self._channels_stop(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_default_object_access_controls { + } + else if self.opt.cmd_default_object_access_controls { if self.opt.cmd_delete { call_result = self._default_object_access_controls_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3549,7 +3696,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_object_access_controls { + } + else if self.opt.cmd_object_access_controls { if self.opt.cmd_delete { call_result = self._object_access_controls_delete(dry_run, &mut err); } else if self.opt.cmd_get { @@ -3565,7 +3713,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_objects { + } + else if self.opt.cmd_objects { if self.opt.cmd_compose { call_result = self._objects_compose(dry_run, &mut err); } else if self.opt.cmd_copy { @@ -3580,6 +3729,8 @@ impl Engine { call_result = self._objects_list(dry_run, &mut err); } else if self.opt.cmd_patch { call_result = self._objects_patch(dry_run, &mut err); + } else if self.opt.cmd_rewrite { + call_result = self._objects_rewrite(dry_run, &mut err); } else if self.opt.cmd_update { call_result = self._objects_update(dry_run, &mut err); } else if self.opt.cmd_watch_all { @@ -3607,21 +3758,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "storage1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "storage1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "storage1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "storage1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Storage::new(hyper::Client::new(), auth), + hub: api::Storage::new(client, auth), }; match engine._doit(true) { @@ -3641,12 +3808,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/storage1/Cargo.toml b/gen/storage1/Cargo.toml index ecebdb7e36..71e5e3126b 100644 --- a/gen/storage1/Cargo.toml +++ b/gen/storage1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-storage1" version = "0.1.5+20150326" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/storage/docs/json_api/" diff --git a/gen/storage1/README.md b/gen/storage1/README.md index 53dc6a3a65..74249f20e6 100644 --- a/gen/storage1/README.md +++ b/gen/storage1/README.md @@ -24,7 +24,7 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [object access controls](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControl.html) * [*delete*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlPatchCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectAccessControlUpdateCall.html) * [objects](http://byron.github.io/google-apis-rs/google_storage1/struct.Object.html) - * [*compose*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectComposeCall.html), [*copy*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectCopyCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectPatchCall.html), [*update*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectUpdateCall.html) and [*watch all*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectWatchAllCall.html) + * [*compose*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectComposeCall.html), [*copy*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectCopyCall.html), [*delete*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectDeleteCall.html), [*get*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectGetCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectListCall.html), [*patch*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectPatchCall.html), [*rewrite*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectRewriteCall.html), [*update*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectUpdateCall.html) and [*watch all*](http://byron.github.io/google-apis-rs/google_storage1/struct.ObjectWatchAllCall.html) Upload supported by ... @@ -74,16 +74,16 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.object_access_controls().get(...).doit() -let r = hub.default_object_access_controls().patch(...).doit() -let r = hub.object_access_controls().update(...).doit() -let r = hub.object_access_controls().list(...).doit() -let r = hub.object_access_controls().patch(...).doit() -let r = hub.default_object_access_controls().update(...).doit() -let r = hub.default_object_access_controls().insert(...).doit() -let r = hub.object_access_controls().insert(...).doit() -let r = hub.object_access_controls().delete(...).doit() -let r = hub.default_object_access_controls().get(...).doit() +let r = hub.objects().list(...).doit() +let r = hub.objects().rewrite(...).doit() +let r = hub.objects().copy(...).doit() +let r = hub.objects().watch_all(...).doit() +let r = hub.objects().get(...).doit() +let r = hub.objects().insert(...).doit() +let r = hub.objects().compose(...).doit() +let r = hub.objects().update(...).doit() +let r = hub.objects().delete(...).doit() +let r = hub.objects().patch(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -108,7 +108,7 @@ google-storage1 = "*" extern crate hyper; extern crate yup_oauth2 as oauth2; extern crate google_storage1 as storage1; -use storage1::ObjectAccessControl; +use storage1::Object; use storage1::{Result, Error}; use std::default::Default; use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; @@ -129,13 +129,25 @@ let mut hub = Storage::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: ObjectAccessControl = Default::default(); +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.object_access_controls().update(&req, "bucket", "object", "entity") - .generation("sed") +let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") + .source_generation("et") + .rewrite_token("dolores") + .projection("kasd") + .max_bytes_rewritten_per_call("accusam") + .if_source_metageneration_not_match("takimata") + .if_source_metageneration_match("justo") + .if_source_generation_not_match("amet.") + .if_source_generation_match("erat") + .if_metageneration_not_match("labore") + .if_metageneration_match("sea") + .if_generation_not_match("nonumy") + .if_generation_match("dolores") + .destination_predefined_acl("gubergren") .doit(); match result { diff --git a/gen/storage1/src/cmn.rs b/gen/storage1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/storage1/src/cmn.rs +++ b/gen/storage1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/storage1/src/lib.rs b/gen/storage1/src/lib.rs index 95b31f5b66..6bbae2024b 100644 --- a/gen/storage1/src/lib.rs +++ b/gen/storage1/src/lib.rs @@ -22,7 +22,7 @@ //! * [object access controls](struct.ObjectAccessControl.html) //! * [*delete*](struct.ObjectAccessControlDeleteCall.html), [*get*](struct.ObjectAccessControlGetCall.html), [*insert*](struct.ObjectAccessControlInsertCall.html), [*list*](struct.ObjectAccessControlListCall.html), [*patch*](struct.ObjectAccessControlPatchCall.html) and [*update*](struct.ObjectAccessControlUpdateCall.html) //! * [objects](struct.Object.html) -//! * [*compose*](struct.ObjectComposeCall.html), [*copy*](struct.ObjectCopyCall.html), [*delete*](struct.ObjectDeleteCall.html), [*get*](struct.ObjectGetCall.html), [*insert*](struct.ObjectInsertCall.html), [*list*](struct.ObjectListCall.html), [*patch*](struct.ObjectPatchCall.html), [*update*](struct.ObjectUpdateCall.html) and [*watch all*](struct.ObjectWatchAllCall.html) +//! * [*compose*](struct.ObjectComposeCall.html), [*copy*](struct.ObjectCopyCall.html), [*delete*](struct.ObjectDeleteCall.html), [*get*](struct.ObjectGetCall.html), [*insert*](struct.ObjectInsertCall.html), [*list*](struct.ObjectListCall.html), [*patch*](struct.ObjectPatchCall.html), [*rewrite*](struct.ObjectRewriteCall.html), [*update*](struct.ObjectUpdateCall.html) and [*watch all*](struct.ObjectWatchAllCall.html) //! //! //! Upload supported by ... @@ -74,16 +74,16 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.object_access_controls().get(...).doit() -//! let r = hub.default_object_access_controls().patch(...).doit() -//! let r = hub.object_access_controls().update(...).doit() -//! let r = hub.object_access_controls().list(...).doit() -//! let r = hub.object_access_controls().patch(...).doit() -//! let r = hub.default_object_access_controls().update(...).doit() -//! let r = hub.default_object_access_controls().insert(...).doit() -//! let r = hub.object_access_controls().insert(...).doit() -//! let r = hub.object_access_controls().delete(...).doit() -//! let r = hub.default_object_access_controls().get(...).doit() +//! let r = hub.objects().list(...).doit() +//! let r = hub.objects().rewrite(...).doit() +//! let r = hub.objects().copy(...).doit() +//! let r = hub.objects().watch_all(...).doit() +//! let r = hub.objects().get(...).doit() +//! let r = hub.objects().insert(...).doit() +//! let r = hub.objects().compose(...).doit() +//! let r = hub.objects().update(...).doit() +//! let r = hub.objects().delete(...).doit() +//! let r = hub.objects().patch(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -108,7 +108,7 @@ //! extern crate hyper; //! extern crate yup_oauth2 as oauth2; //! extern crate google_storage1 as storage1; -//! use storage1::ObjectAccessControl; +//! use storage1::Object; //! use storage1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; @@ -130,13 +130,25 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: ObjectAccessControl = Default::default(); +//! 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.object_access_controls().update(&req, "bucket", "object", "entity") -//! .generation("accusam") +//! let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +//! .source_generation("justo") +//! .rewrite_token("justo") +//! .projection("et") +//! .max_bytes_rewritten_per_call("et") +//! .if_source_metageneration_not_match("diam") +//! .if_source_metageneration_match("ipsum") +//! .if_source_generation_not_match("Lorem") +//! .if_source_generation_match("et") +//! .if_metageneration_not_match("duo") +//! .if_metageneration_match("aliquyam") +//! .if_generation_not_match("sea") +//! .if_generation_match("Lorem") +//! .destination_predefined_acl("eos") //! .doit(); //! //! match result { @@ -296,7 +308,7 @@ impl Default for Scope { /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_storage1 as storage1; -/// use storage1::ObjectAccessControl; +/// use storage1::Object; /// use storage1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; @@ -318,13 +330,25 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// 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.object_access_controls().update(&req, "bucket", "object", "entity") -/// .generation("erat") +/// let result = hub.objects().rewrite(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") +/// .source_generation("elitr") +/// .rewrite_token("amet") +/// .projection("no") +/// .max_bytes_rewritten_per_call("labore") +/// .if_source_metageneration_not_match("eirmod") +/// .if_source_metageneration_match("dolore") +/// .if_source_generation_not_match("invidunt") +/// .if_source_generation_match("aliquyam") +/// .if_metageneration_not_match("accusam") +/// .if_metageneration_match("Lorem") +/// .if_generation_not_match("sea") +/// .if_generation_match("et") +/// .destination_predefined_acl("duo") /// .doit(); /// /// match result { @@ -409,9 +433,9 @@ impl<'a, C, A> Storage<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketAccessControls { /// The list of items. - pub items: Vec<BucketAccessControl>, + pub items: Option<Vec<BucketAccessControl>>, /// The kind of item this is. For lists of bucket access control entries, this is always storage#bucketAccessControls. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for BucketAccessControls {} @@ -424,9 +448,9 @@ impl ResponseResult for BucketAccessControls {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketLifecycleRule { /// The action to take. - pub action: BucketLifecycleRuleAction, + pub action: Option<BucketLifecycleRuleAction>, /// The condition(s) under which the action will be taken. - pub condition: BucketLifecycleRuleCondition, + pub condition: Option<BucketLifecycleRuleCondition>, } impl NestedType for BucketLifecycleRule {} @@ -441,9 +465,9 @@ impl Part for BucketLifecycleRule {} pub struct ObjectAccessControlProjectTeam { /// The project number. #[serde(rename="projectNumber")] - pub project_number: String, + pub project_number: Option<String>, /// The team. Can be owners, editors, or viewers. - pub team: String, + pub team: Option<String>, } impl NestedType for ObjectAccessControlProjectTeam {} @@ -458,15 +482,15 @@ impl Part for ObjectAccessControlProjectTeam {} pub struct BucketLifecycleRuleCondition { /// Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects. #[serde(rename="isLive")] - pub is_live: bool, + pub is_live: Option<bool>, /// Relevant only for versioned objects. If the value is N, this condition is satisfied when there are at least N versions (including the live version) newer than this version of the object. #[serde(rename="numNewerVersions")] - pub num_newer_versions: i32, + pub num_newer_versions: Option<i32>, /// Age of an object (in days). This condition is satisfied when an object reaches the specified age. - pub age: i32, + pub age: Option<i32>, /// A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). This condition is satisfied when an object is created before midnight of the specified date in UTC. #[serde(rename="createdBefore")] - pub created_before: String, + pub created_before: Option<String>, } impl NestedType for BucketLifecycleRuleCondition {} @@ -481,10 +505,10 @@ impl Part for BucketLifecycleRuleCondition {} pub struct BucketWebsite { /// The custom object to return when a requested resource is not found. #[serde(rename="notFoundPage")] - pub not_found_page: String, + pub not_found_page: Option<String>, /// Behaves as the bucket's directory index where missing objects are treated as potential directories. #[serde(rename="mainPageSuffix")] - pub main_page_suffix: String, + pub main_page_suffix: Option<String>, } impl NestedType for BucketWebsite {} @@ -541,10 +565,10 @@ impl ResponseResult for Channel {} pub struct BucketLogging { /// A prefix for log object names. #[serde(rename="logObjectPrefix")] - pub log_object_prefix: String, + pub log_object_prefix: Option<String>, /// The destination bucket where the current bucket's logs should be placed. #[serde(rename="logBucket")] - pub log_bucket: String, + pub log_bucket: Option<String>, } impl NestedType for BucketLogging {} @@ -558,7 +582,7 @@ impl Part for BucketLogging {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketLifecycle { /// A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken. - pub rule: Vec<BucketLifecycleRule>, + pub rule: Option<Vec<BucketLifecycleRule>>, } impl NestedType for BucketLifecycle {} @@ -572,7 +596,7 @@ impl Part for BucketLifecycle {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketVersioning { /// While set to true, versioning is fully enabled for this bucket. - pub enabled: bool, + pub enabled: Option<bool>, } impl NestedType for BucketVersioning {} @@ -587,12 +611,13 @@ impl Part for BucketVersioning {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list objects](struct.ObjectListCall.html) (none) -/// * [update objects](struct.ObjectUpdateCall.html) (request|response) +/// * [rewrite objects](struct.ObjectRewriteCall.html) (request) /// * [copy objects](struct.ObjectCopyCall.html) (request|response) /// * [watch all objects](struct.ObjectWatchAllCall.html) (none) /// * [get objects](struct.ObjectGetCall.html) (response) /// * [insert objects](struct.ObjectInsertCall.html) (request|response) /// * [compose objects](struct.ObjectComposeCall.html) (response) +/// * [update objects](struct.ObjectUpdateCall.html) (request|response) /// * [delete objects](struct.ObjectDeleteCall.html) (none) /// * [patch objects](struct.ObjectPatchCall.html) (request|response) /// @@ -677,13 +702,13 @@ impl ResponseResult for Object {} pub struct Objects { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of items. - pub items: Vec<Object>, + pub items: Option<Vec<Object>>, /// The kind of item this is. For lists of objects, this is always storage#objects. - pub kind: String, + pub kind: Option<String>, /// The list of prefixes of objects matching-but-not-listed up to and including the requested delimiter. - pub prefixes: Vec<String>, + pub prefixes: Option<Vec<String>>, } impl ResponseResult for Objects {} @@ -696,15 +721,15 @@ impl ResponseResult for Objects {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BucketCors { /// The list of Origins eligible to receive CORS response headers. Note: "*" is permitted in the list of origins, and means "any Origin". - pub origin: Vec<String>, + pub origin: Option<Vec<String>>, /// The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains. #[serde(rename="responseHeader")] - pub response_header: Vec<String>, + pub response_header: Option<Vec<String>>, /// The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means "any method". - pub method: Vec<String>, + pub method: Option<Vec<String>>, /// The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses. #[serde(rename="maxAgeSeconds")] - pub max_age_seconds: i32, + pub max_age_seconds: Option<i32>, } impl NestedType for BucketCors {} @@ -724,9 +749,9 @@ impl Part for BucketCors {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ObjectAccessControls { /// The list of items. - pub items: Vec<String>, + pub items: Option<Vec<String>>, /// The kind of item this is. For lists of object access control entries, this is always storage#objectAccessControls. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for ObjectAccessControls {} @@ -740,9 +765,9 @@ impl ResponseResult for ObjectAccessControls {} pub struct BucketAccessControlProjectTeam { /// The project number. #[serde(rename="projectNumber")] - pub project_number: String, + pub project_number: Option<String>, /// The team. Can be owners, editors, or viewers. - pub team: String, + pub team: Option<String>, } impl NestedType for BucketAccessControlProjectTeam {} @@ -757,7 +782,7 @@ impl Part for BucketAccessControlProjectTeam {} pub struct ComposeRequestSourceObjectsObjectPreconditions { /// Only perform the composition if the generation of the source object that would be used matches this value. If this value and a generation are both specified, they must be the same value or the call will fail. #[serde(rename="ifGenerationMatch")] - pub if_generation_match: String, + pub if_generation_match: Option<String>, } impl NestedType for ComposeRequestSourceObjectsObjectPreconditions {} @@ -771,12 +796,12 @@ impl Part for ComposeRequestSourceObjectsObjectPreconditions {} #[derive(Default, Clone, Debug, Serialize)] pub struct ComposeRequestSourceObjects { /// The generation of this object to use as the source. - pub generation: String, + pub generation: Option<String>, /// The source object's name. The source object's bucket is implicitly the destination bucket. - pub name: String, + pub name: Option<String>, /// Conditions that must be met for this operation to execute. #[serde(rename="objectPreconditions")] - pub object_preconditions: ComposeRequestSourceObjectsObjectPreconditions, + pub object_preconditions: Option<ComposeRequestSourceObjectsObjectPreconditions>, } impl NestedType for ComposeRequestSourceObjects {} @@ -973,6 +998,37 @@ impl Resource for ObjectAccessControl {} impl ResponseResult for ObjectAccessControl {} +/// A Rewrite response. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [rewrite objects](struct.ObjectRewriteCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct RewriteResponse { + /// no description provided + #[serde(rename="objectSize")] + pub object_size: Option<String>, + /// The kind of item this is. + pub kind: Option<String>, + /// no description provided + pub resource: Option<Object>, + /// no description provided + pub done: Option<bool>, + /// no description provided + #[serde(rename="totalBytesRewritten")] + pub total_bytes_rewritten: Option<String>, + /// no description provided + #[serde(rename="rewriteToken")] + pub rewrite_token: Option<String>, +} + +impl ResponseResult for RewriteResponse {} + + /// The owner of the object. This will always be the uploader of the object. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -981,9 +1037,9 @@ impl ResponseResult for ObjectAccessControl {} pub struct ObjectOwner { /// The ID for the entity. #[serde(rename="entityId")] - pub entity_id: String, + pub entity_id: Option<String>, /// The entity, in the form user-userId. - pub entity: String, + pub entity: Option<String>, } impl NestedType for ObjectOwner {} @@ -998,7 +1054,7 @@ impl Part for ObjectOwner {} pub struct BucketLifecycleRuleAction { /// Type of the action. Currently, only Delete is supported. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl NestedType for BucketLifecycleRuleAction {} @@ -1013,9 +1069,9 @@ impl Part for BucketLifecycleRuleAction {} pub struct BucketOwner { /// The ID for the entity. #[serde(rename="entityId")] - pub entity_id: String, + pub entity_id: Option<String>, /// The entity, in the form project-owner-projectId. - pub entity: String, + pub entity: Option<String>, } impl NestedType for BucketOwner {} @@ -1058,11 +1114,11 @@ impl RequestValue for ComposeRequest {} pub struct Buckets { /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// The list of items. - pub items: Vec<Bucket>, + pub items: Option<Vec<Bucket>>, /// The kind of item this is. For lists of buckets, this is always storage#buckets. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Buckets {} @@ -1470,7 +1526,7 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = Storage::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `compose(...)`, `copy(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch_all(...)` +/// // like `compose(...)`, `copy(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `rewrite(...)`, `update(...)` and `watch_all(...)` /// // to build up your call. /// let rb = hub.objects(); /// # } @@ -1485,6 +1541,44 @@ impl<'a, C, A> MethodsBuilder for ObjectMethods<'a, C, A> {} impl<'a, C, A> ObjectMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Rewrites a source object to a destination object. Optionally overrides metadata. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `sourceBucket` - Name of the bucket in which to find the source object. + /// * `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> { + ObjectRewriteCall { + hub: self.hub, + _request: request.clone(), + _source_bucket: source_bucket.to_string(), + _source_object: source_object.to_string(), + _destination_bucket: destination_bucket.to_string(), + _destination_object: destination_object.to_string(), + _source_generation: Default::default(), + _rewrite_token: Default::default(), + _projection: Default::default(), + _max_bytes_rewritten_per_call: Default::default(), + _if_source_metageneration_not_match: Default::default(), + _if_source_metageneration_match: Default::default(), + _if_source_generation_not_match: Default::default(), + _if_source_generation_match: Default::default(), + _if_metageneration_not_match: Default::default(), + _if_metageneration_match: Default::default(), + _if_generation_not_match: Default::default(), + _if_generation_match: Default::default(), + _destination_predefined_acl: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Retrieves an object or its metadata. @@ -1504,9 +1598,34 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _if_generation_not_match: Default::default(), _if_generation_match: Default::default(), _generation: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an object's metadata. + /// + /// # Arguments + /// + /// * `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> { + ObjectUpdateCall { + hub: self.hub, + _request: request.clone(), + _bucket: bucket.to_string(), + _object: object.to_string(), + _projection: Default::default(), + _predefined_acl: Default::default(), + _if_metageneration_not_match: Default::default(), + _if_metageneration_match: Default::default(), + _if_generation_not_match: Default::default(), + _if_generation_match: Default::default(), + _generation: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1538,37 +1657,6 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Updates an object's metadata. - /// - /// # Arguments - /// - /// * `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> { - ObjectUpdateCall { - hub: self.hub, - _request: request.clone(), - _bucket: bucket.to_string(), - _object: object.to_string(), - _projection: Default::default(), - _predefined_acl: Default::default(), - _if_metageneration_not_match: Default::default(), - _if_metageneration_match: Default::default(), - _if_generation_not_match: Default::default(), - _if_generation_match: Default::default(), - _generation: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Stores a new object and metadata. @@ -1589,9 +1677,6 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _if_metageneration_match: Default::default(), _if_generation_not_match: Default::default(), _if_generation_match: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), _content_encoding: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1616,9 +1701,6 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _destination_object: destination_object.to_string(), _if_metageneration_match: Default::default(), _if_generation_match: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), _destination_predefined_acl: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1702,9 +1784,6 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _if_metageneration_match: Default::default(), _if_generation_not_match: Default::default(), _if_generation_match: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), _destination_predefined_acl: Default::default(), _delegate: Default::default(), _scopes: Default::default(), @@ -1734,9 +1813,6 @@ impl<'a, C, A> ObjectMethods<'a, C, A> { _if_generation_not_match: Default::default(), _if_generation_match: Default::default(), _generation: Default::default(), - _encryption_key_hash: Default::default(), - _encryption_key: Default::default(), - _encryption_algorithm: Default::default(), _delegate: Default::default(), _scopes: Default::default(), _additional_params: Default::default(), @@ -1784,28 +1860,6 @@ impl<'a, C, A> MethodsBuilder for ObjectAccessControlMethods<'a, C, A> {} impl<'a, C, A> ObjectAccessControlMethods<'a, C, A> { - /// Create a builder to help you perform the following task: - /// - /// Returns the ACL entry for the specified entity on the specified object. - /// - /// # Arguments - /// - /// * `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 get(&self, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlGetCall<'a, C, A> { - ObjectAccessControlGetCall { - hub: self.hub, - _bucket: bucket.to_string(), - _object: object.to_string(), - _entity: entity.to_string(), - _generation: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Creates a new ACL entry on the specified object. @@ -1894,6 +1948,28 @@ impl<'a, C, A> ObjectAccessControlMethods<'a, C, A> { } } + /// Create a builder to help you perform the following task: + /// + /// Returns the ACL entry for the specified entity on the specified object. + /// + /// # Arguments + /// + /// * `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 get(&self, bucket: &str, object: &str, entity: &str) -> ObjectAccessControlGetCall<'a, C, A> { + ObjectAccessControlGetCall { + hub: self.hub, + _bucket: bucket.to_string(), + _object: object.to_string(), + _entity: entity.to_string(), + _generation: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Updates an ACL entry on the specified object. @@ -2125,7 +2201,7 @@ impl<'a, C, A> BucketMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2217,16 +2293,20 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2379,7 +2459,7 @@ impl<'a, C, A> DefaultObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2473,16 +2553,20 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2645,8 +2729,8 @@ impl<'a, C, A> DefaultObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.default_object_access_controls().list("bucket") -/// .if_metageneration_not_match("gubergren") -/// .if_metageneration_match("sadipscing") +/// .if_metageneration_not_match("amet") +/// .if_metageneration_match("et") /// .doit(); /// # } /// ``` @@ -2736,16 +2820,20 @@ impl<'a, C, A> DefaultObjectAccessControlListCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2899,7 +2987,7 @@ impl<'a, C, A> DefaultObjectAccessControlListCall<'a, C, A> where C: BorrowMut<h /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2993,16 +3081,20 @@ impl<'a, C, A> DefaultObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3247,16 +3339,20 @@ impl<'a, C, A> DefaultObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3479,16 +3575,20 @@ impl<'a, C, A> DefaultObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3638,7 +3738,7 @@ impl<'a, C, A> DefaultObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BucketAccessControl = Default::default(); +/// let mut req = BucketAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3732,16 +3832,20 @@ impl<'a, C, A> BucketAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3986,16 +4090,20 @@ impl<'a, C, A> BucketAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4135,7 +4243,7 @@ impl<'a, C, A> BucketAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BucketAccessControl = Default::default(); +/// let mut req = BucketAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4227,16 +4335,20 @@ impl<'a, C, A> BucketAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4472,16 +4584,20 @@ impl<'a, C, A> BucketAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4631,7 +4747,7 @@ impl<'a, C, A> BucketAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: BucketAccessControl = Default::default(); +/// let mut req = BucketAccessControl::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4725,16 +4841,20 @@ impl<'a, C, A> BucketAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4978,16 +5098,20 @@ impl<'a, C, A> BucketAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5127,7 +5251,7 @@ impl<'a, C, A> BucketAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5192,16 +5316,20 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5307,6 +5435,456 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } +/// Rewrites a source object to a destination object. Optionally overrides metadata. +/// +/// A builder for the *rewrite* method supported by a *object* resource. +/// It is not used directly, but through a `ObjectMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_storage1 as storage1; +/// use storage1::Object; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use storage1::Storage; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Storage::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// 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") +/// .source_generation("vero") +/// .rewrite_token("sadipscing") +/// .projection("invidunt") +/// .max_bytes_rewritten_per_call("consetetur") +/// .if_source_metageneration_not_match("dolore") +/// .if_source_metageneration_match("duo") +/// .if_source_generation_not_match("aliquyam") +/// .if_source_generation_match("Lorem") +/// .if_metageneration_not_match("et") +/// .if_metageneration_match("clita") +/// .if_generation_not_match("consetetur") +/// .if_generation_match("takimata") +/// .destination_predefined_acl("nonumy") +/// .doit(); +/// # } +/// ``` +pub struct ObjectRewriteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Storage<C, A>, + _request: Object, + _source_bucket: String, + _source_object: String, + _destination_bucket: String, + _destination_object: String, + _source_generation: Option<String>, + _rewrite_token: Option<String>, + _projection: Option<String>, + _max_bytes_rewritten_per_call: Option<String>, + _if_source_metageneration_not_match: Option<String>, + _if_source_metageneration_match: Option<String>, + _if_source_generation_not_match: Option<String>, + _if_source_generation_match: Option<String>, + _if_metageneration_not_match: Option<String>, + _if_metageneration_match: Option<String>, + _if_generation_not_match: Option<String>, + _if_generation_match: Option<String>, + _destination_predefined_acl: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ObjectRewriteCall<'a, C, A> {} + +impl<'a, C, A> ObjectRewriteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, RewriteResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "storage.objects.rewrite", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((20 + self._additional_params.len())); + params.push(("sourceBucket", self._source_bucket.to_string())); + params.push(("sourceObject", self._source_object.to_string())); + params.push(("destinationBucket", self._destination_bucket.to_string())); + params.push(("destinationObject", self._destination_object.to_string())); + if let Some(value) = self._source_generation { + params.push(("sourceGeneration", value.to_string())); + } + if let Some(value) = self._rewrite_token { + params.push(("rewriteToken", value.to_string())); + } + if let Some(value) = self._projection { + params.push(("projection", value.to_string())); + } + if let Some(value) = self._max_bytes_rewritten_per_call { + params.push(("maxBytesRewrittenPerCall", value.to_string())); + } + if let Some(value) = self._if_source_metageneration_not_match { + params.push(("ifSourceMetagenerationNotMatch", value.to_string())); + } + if let Some(value) = self._if_source_metageneration_match { + params.push(("ifSourceMetagenerationMatch", value.to_string())); + } + if let Some(value) = self._if_source_generation_not_match { + params.push(("ifSourceGenerationNotMatch", value.to_string())); + } + if let Some(value) = self._if_source_generation_match { + params.push(("ifSourceGenerationMatch", value.to_string())); + } + if let Some(value) = self._if_metageneration_not_match { + params.push(("ifMetagenerationNotMatch", value.to_string())); + } + if let Some(value) = self._if_metageneration_match { + params.push(("ifMetagenerationMatch", value.to_string())); + } + if let Some(value) = self._if_generation_not_match { + params.push(("ifGenerationNotMatch", value.to_string())); + } + if let Some(value) = self._if_generation_match { + params.push(("ifGenerationMatch", value.to_string())); + } + if let Some(value) = self._destination_predefined_acl { + params.push(("destinationPredefinedAcl", value.to_string())); + } + for &field in ["alt", "sourceBucket", "sourceObject", "destinationBucket", "destinationObject", "sourceGeneration", "rewriteToken", "projection", "maxBytesRewrittenPerCall", "ifSourceMetagenerationNotMatch", "ifSourceMetagenerationMatch", "ifSourceGenerationNotMatch", "ifSourceGenerationMatch", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/storage/v1/b/{sourceBucket}/o/{sourceObject}/rewriteTo/b/{destinationBucket}/o/{destinationObject}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{sourceBucket}", "sourceBucket"), ("{sourceObject}", "sourceObject"), ("{destinationBucket}", "destinationBucket"), ("{destinationObject}", "destinationObject")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(4); + for param_name in ["sourceBucket", "sourceObject", "destinationBucket", "destinationObject"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// Name of the bucket in which to find the source object. + /// + /// Sets the *source bucket* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn source_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._source_bucket = new_value.to_string(); + self + } + /// Name of the source object. + /// + /// Sets the *source object* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn source_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._source_object = new_value.to_string(); + self + } + /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any. + /// + /// Sets the *destination bucket* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn destination_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._destination_bucket = new_value.to_string(); + self + } + /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. + /// + /// Sets the *destination object* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn destination_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._destination_object = new_value.to_string(); + self + } + /// If present, selects a specific revision of the source object (as opposed to the latest version, the default). + /// + /// Sets the *source generation* query property to the given value. + pub fn source_generation(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._source_generation = Some(new_value.to_string()); + self + } + /// Include this field (from the previous Rewrite response) on each Rewrite request after the first one, until the Rewrite response 'done' flag is true. Calls that provide a rewriteToken can omit all other request fields, but if included those fields must match the values provided in the first rewrite request. + /// + /// Sets the *rewrite token* query property to the given value. + pub fn rewrite_token(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._rewrite_token = Some(new_value.to_string()); + self + } + /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full. + /// + /// Sets the *projection* query property to the given value. + pub fn projection(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._projection = Some(new_value.to_string()); + self + } + /// The maximum number of bytes that will be rewritten per Rewrite request. Most callers shouldn't need to specify this parameter - it is primarily in place to support testing. If specified the value must be an integral multiple of 1 MiB (1048576). Also, this only applies to requests where the source and destination span locations and/or storage classes. Finally, this value must not change across Rewrite calls else you'll get an error that the rewrite token is invalid. + /// + /// Sets the *max bytes rewritten per call* query property to the given value. + pub fn max_bytes_rewritten_per_call(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._max_bytes_rewritten_per_call = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the source object's current metageneration does not match the given value. + /// + /// Sets the *if source metageneration not match* query property to the given value. + pub fn if_source_metageneration_not_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_source_metageneration_not_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the source object's current metageneration matches the given value. + /// + /// Sets the *if source metageneration match* query property to the given value. + pub fn if_source_metageneration_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_source_metageneration_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the source object's generation does not match the given value. + /// + /// Sets the *if source generation not match* query property to the given value. + pub fn if_source_generation_not_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_source_generation_not_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the source object's generation matches the given value. + /// + /// Sets the *if source generation match* query property to the given value. + pub fn if_source_generation_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_source_generation_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value. + /// + /// Sets the *if metageneration not match* query property to the given value. + pub fn if_metageneration_not_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_metageneration_not_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the destination object's current metageneration matches the given value. + /// + /// Sets the *if metageneration match* query property to the given value. + pub fn if_metageneration_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_metageneration_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the destination object's current generation does not match the given value. + /// + /// Sets the *if generation not match* query property to the given value. + pub fn if_generation_not_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_generation_not_match = Some(new_value.to_string()); + self + } + /// Makes the operation conditional on whether the destination object's current generation matches the given value. + /// + /// Sets the *if generation match* query property to the given value. + pub fn if_generation_match(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._if_generation_match = Some(new_value.to_string()); + self + } + /// Apply a predefined set of access controls to the destination object. + /// + /// Sets the *destination predefined acl* query property to the given value. + pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectRewriteCall<'a, C, A> { + self._destination_predefined_acl = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ObjectRewriteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ObjectRewriteCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ObjectRewriteCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Retrieves an object or its metadata. /// /// This method supports **media download**. To enable it, adjust the builder like this: @@ -5339,15 +5917,12 @@ impl<'a, C, A> ChannelStopCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().get("bucket", "object") -/// .projection("dolor") -/// .if_metageneration_not_match("eirmod") -/// .if_metageneration_match("elitr") -/// .if_generation_not_match("amet") -/// .if_generation_match("no") -/// .generation("labore") -/// .encryption_key_hash("eirmod") -/// .encryption_key("dolore") -/// .encryption_algorithm("invidunt") +/// .projection("takimata") +/// .if_metageneration_not_match("At") +/// .if_metageneration_match("labore") +/// .if_generation_not_match("invidunt") +/// .if_generation_match("ea") +/// .generation("sadipscing") /// .doit(); /// # } /// ``` @@ -5363,9 +5938,6 @@ pub struct ObjectGetCall<'a, C, A> _if_generation_not_match: Option<String>, _if_generation_match: Option<String>, _generation: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> @@ -5387,7 +5959,7 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau }; dlg.begin(MethodInfo { id: "storage.objects.get", http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((9 + self._additional_params.len())); params.push(("bucket", self._bucket.to_string())); params.push(("object", self._object.to_string())); if let Some(value) = self._projection { @@ -5408,16 +5980,7 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau if let Some(value) = self._generation { params.push(("generation", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } - for &field in ["bucket", "object", "projection", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm"].iter() { + for &field in ["bucket", "object", "projection", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -5483,16 +6046,20 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -5605,27 +6172,6 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau self._generation = Some(new_value.to_string()); self } - /// Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectGetCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// Provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectGetCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// Specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectGetCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -5678,332 +6224,6 @@ impl<'a, C, A> ObjectGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau } -/// Watch for changes on all objects in a bucket. -/// -/// A builder for the *watchAll* method supported by a *object* resource. -/// It is not used directly, but through a `ObjectMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_storage1 as storage1; -/// use storage1::Channel; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use storage1::Storage; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Storage::new(hyper::Client::new(), auth); -/// // As the method needs a request, you would usually fill it with the desired information -/// // into the respective structure. Some of the parts shown here might not be applicable ! -/// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::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().watch_all(&req, "bucket") -/// .versions(false) -/// .projection("Lorem") -/// .prefix("sea") -/// .page_token("et") -/// .max_results(31) -/// .delimiter("et") -/// .doit(); -/// # } -/// ``` -pub struct ObjectWatchAllCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Storage<C, A>, - _request: Channel, - _bucket: String, - _versions: Option<bool>, - _projection: Option<String>, - _prefix: Option<String>, - _page_token: Option<String>, - _max_results: Option<u32>, - _delimiter: Option<String>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ObjectWatchAllCall<'a, C, A> {} - -impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "storage.objects.watchAll", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); - params.push(("bucket", self._bucket.to_string())); - if let Some(value) = self._versions { - params.push(("versions", value.to_string())); - } - if let Some(value) = self._projection { - params.push(("projection", value.to_string())); - } - if let Some(value) = self._prefix { - params.push(("prefix", value.to_string())); - } - if let Some(value) = self._page_token { - params.push(("pageToken", value.to_string())); - } - if let Some(value) = self._max_results { - params.push(("maxResults", value.to_string())); - } - if let Some(value) = self._delimiter { - params.push(("delimiter", value.to_string())); - } - for &field in ["alt", "bucket", "versions", "projection", "prefix", "pageToken", "maxResults", "delimiter"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/storage/v1/b/{bucket}/o/watch".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{bucket}", "bucket")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); - for param_name in ["bucket"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); - let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); - let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()) - .header(ContentType(json_mime_type.clone())) - .header(ContentLength(request_size as u64)) - .body(&mut request_value_reader); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// - /// Sets the *request* property to the given value. - /// - /// Even though 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(); - self - } - /// Name of the bucket in which to look for objects. - /// - /// Sets the *bucket* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn bucket(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { - self._bucket = new_value.to_string(); - self - } - /// If true, lists all versions of a file as distinct results. - /// - /// Sets the *versions* query property to the given value. - pub fn versions(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C, A> { - self._versions = Some(new_value); - self - } - /// Set of properties to return. Defaults to noAcl. - /// - /// Sets the *projection* query property to the given value. - pub fn projection(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { - self._projection = Some(new_value.to_string()); - self - } - /// Filter results to objects whose names begin with this prefix. - /// - /// Sets the *prefix* query property to the given value. - pub fn prefix(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { - self._prefix = Some(new_value.to_string()); - self - } - /// A previously-returned page token representing part of the larger set of results to view. - /// - /// Sets the *page token* query property to the given value. - pub fn page_token(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { - self._page_token = Some(new_value.to_string()); - self - } - /// Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. - /// - /// Sets the *max results* query property to the given value. - pub fn max_results(mut self, new_value: u32) -> ObjectWatchAllCall<'a, C, A> { - self._max_results = Some(new_value); - self - } - /// Returns results in a directory-like mode. items will contain only objects whose names, aside from the prefix, do not contain delimiter. Objects whose names, aside from the prefix, contain delimiter will have their name, truncated after the delimiter, returned in prefixes. Duplicate prefixes are omitted. - /// - /// Sets the *delimiter* query property to the given value. - pub fn delimiter(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { - self._delimiter = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ObjectWatchAllCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ObjectWatchAllCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::CloudPlatform`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ObjectWatchAllCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Updates an object's metadata. /// /// This method supports **media download**. To enable it, adjust the builder like this: @@ -6036,22 +6256,19 @@ impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Object = Default::default(); +/// 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().update(&req, "bucket", "object") -/// .projection("et") -/// .predefined_acl("amet") -/// .if_metageneration_not_match("et") -/// .if_metageneration_match("consetetur") -/// .if_generation_not_match("ut") -/// .if_generation_match("ea") -/// .generation("sed") -/// .encryption_key_hash("dolor") -/// .encryption_key("dolor") -/// .encryption_algorithm("dolor") +/// .projection("nonumy") +/// .predefined_acl("sed") +/// .if_metageneration_not_match("aliquyam") +/// .if_metageneration_match("sit") +/// .if_generation_not_match("eirmod") +/// .if_generation_match("consetetur") +/// .generation("labore") /// .doit(); /// # } /// ``` @@ -6069,9 +6286,6 @@ pub struct ObjectUpdateCall<'a, C, A> _if_generation_not_match: Option<String>, _if_generation_match: Option<String>, _generation: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> @@ -6093,7 +6307,7 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: }; dlg.begin(MethodInfo { id: "storage.objects.update", http_method: hyper::method::Method::Put }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((14 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); params.push(("bucket", self._bucket.to_string())); params.push(("object", self._object.to_string())); if let Some(value) = self._projection { @@ -6117,16 +6331,7 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if let Some(value) = self._generation { params.push(("generation", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } - for &field in ["bucket", "object", "projection", "predefinedAcl", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm"].iter() { + for &field in ["bucket", "object", "projection", "predefinedAcl", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6196,16 +6401,20 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6338,27 +6547,6 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: self._generation = Some(new_value.to_string()); self } - /// For downloading encrypted objects, provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectUpdateCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// For downloading encrypted objects, provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectUpdateCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// For downloading encrypted objects, specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectUpdateCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -6411,6 +6599,336 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Watch for changes on all objects in a bucket. +/// +/// A builder for the *watchAll* method supported by a *object* resource. +/// It is not used directly, but through a `ObjectMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_storage1 as storage1; +/// use storage1::Channel; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use storage1::Storage; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Storage::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// 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.objects().watch_all(&req, "bucket") +/// .versions(true) +/// .projection("gubergren") +/// .prefix("aliquyam") +/// .page_token("eos") +/// .max_results(63) +/// .delimiter("sea") +/// .doit(); +/// # } +/// ``` +pub struct ObjectWatchAllCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Storage<C, A>, + _request: Channel, + _bucket: String, + _versions: Option<bool>, + _projection: Option<String>, + _prefix: Option<String>, + _page_token: Option<String>, + _max_results: Option<u32>, + _delimiter: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ObjectWatchAllCall<'a, C, A> {} + +impl<'a, C, A> ObjectWatchAllCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Channel)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "storage.objects.watchAll", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + params.push(("bucket", self._bucket.to_string())); + if let Some(value) = self._versions { + params.push(("versions", value.to_string())); + } + if let Some(value) = self._projection { + params.push(("projection", value.to_string())); + } + if let Some(value) = self._prefix { + params.push(("prefix", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._delimiter { + params.push(("delimiter", value.to_string())); + } + for &field in ["alt", "bucket", "versions", "projection", "prefix", "pageToken", "maxResults", "delimiter"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/storage/v1/b/{bucket}/o/watch".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{bucket}", "bucket")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1); + for param_name in ["bucket"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// Name of the bucket in which to look for objects. + /// + /// Sets the *bucket* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn bucket(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { + self._bucket = new_value.to_string(); + self + } + /// If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning. + /// + /// Sets the *versions* query property to the given value. + pub fn versions(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C, A> { + self._versions = Some(new_value); + self + } + /// Set of properties to return. Defaults to noAcl. + /// + /// Sets the *projection* query property to the given value. + pub fn projection(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { + self._projection = Some(new_value.to_string()); + self + } + /// Filter results to objects whose names begin with this prefix. + /// + /// Sets the *prefix* query property to the given value. + pub fn prefix(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { + self._prefix = Some(new_value.to_string()); + self + } + /// A previously-returned page token representing part of the larger set of results to view. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. The default value of this parameter is 1,000 items. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> ObjectWatchAllCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// Returns results in a directory-like mode. items will contain only objects whose names, aside from the prefix, do not contain delimiter. Objects whose names, aside from the prefix, contain delimiter will have their name, truncated after the delimiter, returned in prefixes. Duplicate prefixes are omitted. + /// + /// Sets the *delimiter* query property to the given value. + pub fn delimiter(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C, A> { + self._delimiter = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ObjectWatchAllCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ObjectWatchAllCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ObjectWatchAllCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Stores a new object and metadata. /// /// This method supports **media download**. To enable it, adjust the builder like this: @@ -6444,23 +6962,20 @@ impl<'a, C, A> ObjectUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Object = Default::default(); +/// let mut req = Object::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.objects().insert(&req, "bucket") -/// .projection("consetetur") -/// .predefined_acl("amet.") -/// .name("voluptua.") -/// .if_metageneration_not_match("Lorem") -/// .if_metageneration_match("gubergren") -/// .if_generation_not_match("justo") -/// .if_generation_match("sit") -/// .encryption_key_hash("vero") -/// .encryption_key("diam") -/// .encryption_algorithm("rebum.") -/// .content_encoding("consetetur") +/// .projection("ipsum") +/// .predefined_acl("aliquyam") +/// .name("dolores") +/// .if_metageneration_not_match("sit") +/// .if_metageneration_match("diam") +/// .if_generation_not_match("ut") +/// .if_generation_match("justo") +/// .content_encoding("est") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6477,9 +6992,6 @@ pub struct ObjectInsertCall<'a, C, A> _if_metageneration_match: Option<String>, _if_generation_not_match: Option<String>, _if_generation_match: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _content_encoding: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, @@ -6503,7 +7015,7 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: }; dlg.begin(MethodInfo { id: "storage.objects.insert", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((14 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len())); params.push(("bucket", self._bucket.to_string())); if let Some(value) = self._projection { params.push(("projection", value.to_string())); @@ -6526,19 +7038,10 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if let Some(value) = self._if_generation_match { params.push(("ifGenerationMatch", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } if let Some(value) = self._content_encoding { params.push(("contentEncoding", value.to_string())); } - for &field in ["bucket", "projection", "predefinedAcl", "name", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm", "contentEncoding"].iter() { + for &field in ["bucket", "projection", "predefinedAcl", "name", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "contentEncoding"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -6618,16 +7121,20 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -6849,27 +7356,6 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: self._if_generation_match = Some(new_value.to_string()); self } - /// Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectInsertCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// Provides a base64-encoded 256-bit key to encrypt the object. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectInsertCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// Specifies the encryption algorithm that would be used to encrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectInsertCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// If set, sets the contentEncoding property of the final object to this value. Setting this parameter is equivalent to setting the contentEncoding metadata property. This can be useful when uploading an object with uploadType=media to indicate the encoding of the content being uploaded. /// /// Sets the *content encoding* query property to the given value. @@ -6961,18 +7447,15 @@ impl<'a, C, A> ObjectInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ComposeRequest = Default::default(); +/// let mut req = ComposeRequest::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().compose(&req, "destinationBucket", "destinationObject") -/// .if_metageneration_match("sadipscing") -/// .if_generation_match("invidunt") -/// .encryption_key_hash("consetetur") -/// .encryption_key("dolore") -/// .encryption_algorithm("duo") -/// .destination_predefined_acl("aliquyam") +/// .if_metageneration_match("clita") +/// .if_generation_match("diam") +/// .destination_predefined_acl("justo") /// .doit(); /// # } /// ``` @@ -6985,9 +7468,6 @@ pub struct ObjectComposeCall<'a, C, A> _destination_object: String, _if_metageneration_match: Option<String>, _if_generation_match: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _destination_predefined_acl: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, @@ -7010,7 +7490,7 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: }; dlg.begin(MethodInfo { id: "storage.objects.compose", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); params.push(("destinationBucket", self._destination_bucket.to_string())); params.push(("destinationObject", self._destination_object.to_string())); if let Some(value) = self._if_metageneration_match { @@ -7019,19 +7499,10 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: if let Some(value) = self._if_generation_match { params.push(("ifGenerationMatch", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } if let Some(value) = self._destination_predefined_acl { params.push(("destinationPredefinedAcl", value.to_string())); } - for &field in ["destinationBucket", "destinationObject", "ifMetagenerationMatch", "ifGenerationMatch", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm", "destinationPredefinedAcl"].iter() { + for &field in ["destinationBucket", "destinationObject", "ifMetagenerationMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -7101,16 +7572,20 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7208,27 +7683,6 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: self._if_generation_match = Some(new_value.to_string()); self } - /// Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectComposeCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// Provides a base64-encoded 256-bit key that was used to encrypt the object, if any. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectComposeCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// Specifies the encryption algorithm that was used to encrypt the object, if any. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectComposeCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// Apply a predefined set of access controls to the destination object. /// /// Sets the *destination predefined acl* query property to the given value. @@ -7315,11 +7769,11 @@ impl<'a, C, A> ObjectComposeCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().delete("bucket", "object") -/// .if_metageneration_not_match("clita") -/// .if_metageneration_match("consetetur") -/// .if_generation_not_match("takimata") -/// .if_generation_match("nonumy") -/// .generation("kasd") +/// .if_metageneration_not_match("invidunt") +/// .if_metageneration_match("ut") +/// .if_generation_not_match("dolores") +/// .if_generation_match("eos") +/// .generation("voluptua.") /// .doit(); /// # } /// ``` @@ -7422,16 +7876,20 @@ impl<'a, C, A> ObjectDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7607,11 +8065,11 @@ impl<'a, C, A> ObjectDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // Values shown here are possibly random and not representative ! /// let result = hub.objects().list("bucket") /// .versions(false) -/// .projection("At") -/// .prefix("labore") -/// .page_token("invidunt") -/// .max_results(35) -/// .delimiter("sadipscing") +/// .projection("aliquyam") +/// .prefix("ea") +/// .page_token("ea") +/// .max_results(27) +/// .delimiter("dolor") /// .doit(); /// # } /// ``` @@ -7717,16 +8175,20 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7787,7 +8249,7 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa self._bucket = new_value.to_string(); self } - /// If true, lists all versions of a file as distinct results. + /// If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning. /// /// Sets the *versions* query property to the given value. pub fn versions(mut self, new_value: bool) -> ObjectListCall<'a, C, A> { @@ -7815,7 +8277,7 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa self._page_token = Some(new_value.to_string()); self } - /// Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. + /// Maximum number of items plus prefixes to return. As duplicate prefixes are omitted, fewer total results may be returned than requested. The default value of this parameter is 1,000 items. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: u32) -> ObjectListCall<'a, C, A> { @@ -7913,26 +8375,23 @@ impl<'a, C, A> ObjectListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Object = Default::default(); +/// 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().copy(&req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject") -/// .source_generation("aliquyam") -/// .projection("sit") -/// .if_source_metageneration_not_match("eirmod") -/// .if_source_metageneration_match("consetetur") -/// .if_source_generation_not_match("labore") -/// .if_source_generation_match("sed") -/// .if_metageneration_not_match("ea") -/// .if_metageneration_match("gubergren") -/// .if_generation_not_match("aliquyam") -/// .if_generation_match("eos") -/// .encryption_key_hash("tempor") -/// .encryption_key("sea") -/// .encryption_algorithm("labore") -/// .destination_predefined_acl("ipsum") +/// .source_generation("Lorem") +/// .projection("clita") +/// .if_source_metageneration_not_match("invidunt") +/// .if_source_metageneration_match("eirmod") +/// .if_source_generation_not_match("At") +/// .if_source_generation_match("consetetur") +/// .if_metageneration_not_match("et") +/// .if_metageneration_match("sed") +/// .if_generation_not_match("sit") +/// .if_generation_match("takimata") +/// .destination_predefined_acl("elitr") /// .doit(); /// # } /// ``` @@ -7955,9 +8414,6 @@ pub struct ObjectCopyCall<'a, C, A> _if_metageneration_match: Option<String>, _if_generation_not_match: Option<String>, _if_generation_match: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _destination_predefined_acl: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, @@ -7980,7 +8436,7 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa }; dlg.begin(MethodInfo { id: "storage.objects.copy", http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((20 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((17 + self._additional_params.len())); params.push(("sourceBucket", self._source_bucket.to_string())); params.push(("sourceObject", self._source_object.to_string())); params.push(("destinationBucket", self._destination_bucket.to_string())); @@ -8015,19 +8471,10 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa if let Some(value) = self._if_generation_match { params.push(("ifGenerationMatch", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } if let Some(value) = self._destination_predefined_acl { params.push(("destinationPredefinedAcl", value.to_string())); } - for &field in ["sourceBucket", "sourceObject", "destinationBucket", "destinationObject", "sourceGeneration", "projection", "ifSourceMetagenerationNotMatch", "ifSourceMetagenerationMatch", "ifSourceGenerationNotMatch", "ifSourceGenerationMatch", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm", "destinationPredefinedAcl"].iter() { + for &field in ["sourceBucket", "sourceObject", "destinationBucket", "destinationObject", "sourceGeneration", "projection", "ifSourceMetagenerationNotMatch", "ifSourceMetagenerationMatch", "ifSourceGenerationNotMatch", "ifSourceGenerationMatch", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "destinationPredefinedAcl"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8097,16 +8544,20 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8280,27 +8731,6 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa self._if_generation_match = Some(new_value.to_string()); self } - /// Provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectCopyCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// Provides a base64-encoded 256-bit key that was used to encrypt the object, if any. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectCopyCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// Specifies the encryption algorithm that was used to encrypt the object, if any. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectCopyCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// Apply a predefined set of access controls to the destination object. /// /// Sets the *destination predefined acl* query property to the given value. @@ -8387,22 +8817,19 @@ impl<'a, C, A> ObjectCopyCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Object = Default::default(); +/// 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().patch(&req, "bucket", "object") -/// .projection("sit") -/// .predefined_acl("diam") -/// .if_metageneration_not_match("ut") -/// .if_metageneration_match("justo") -/// .if_generation_not_match("est") -/// .if_generation_match("amet") -/// .generation("accusam") -/// .encryption_key_hash("clita") -/// .encryption_key("diam") -/// .encryption_algorithm("justo") +/// .projection("Lorem") +/// .predefined_acl("Lorem") +/// .if_metageneration_not_match("diam") +/// .if_metageneration_match("ut") +/// .if_generation_not_match("ut") +/// .if_generation_match("amet.") +/// .generation("ipsum") /// .doit(); /// # } /// ``` @@ -8420,9 +8847,6 @@ pub struct ObjectPatchCall<'a, C, A> _if_generation_not_match: Option<String>, _if_generation_match: Option<String>, _generation: Option<String>, - _encryption_key_hash: Option<String>, - _encryption_key: Option<String>, - _encryption_algorithm: Option<String>, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap<String, String>, _scopes: BTreeMap<String, ()> @@ -8444,7 +8868,7 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o }; dlg.begin(MethodInfo { id: "storage.objects.patch", http_method: hyper::method::Method::Patch }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((15 + self._additional_params.len())); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); params.push(("bucket", self._bucket.to_string())); params.push(("object", self._object.to_string())); if let Some(value) = self._projection { @@ -8468,16 +8892,7 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o if let Some(value) = self._generation { params.push(("generation", value.to_string())); } - if let Some(value) = self._encryption_key_hash { - params.push(("encryptionKeyHash", value.to_string())); - } - if let Some(value) = self._encryption_key { - params.push(("encryptionKey", value.to_string())); - } - if let Some(value) = self._encryption_algorithm { - params.push(("encryptionAlgorithm", value.to_string())); - } - for &field in ["alt", "bucket", "object", "projection", "predefinedAcl", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation", "encryptionKeyHash", "encryptionKey", "encryptionAlgorithm"].iter() { + for &field in ["alt", "bucket", "object", "projection", "predefinedAcl", "ifMetagenerationNotMatch", "ifMetagenerationMatch", "ifGenerationNotMatch", "ifGenerationMatch", "generation"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); @@ -8531,16 +8946,20 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8673,27 +9092,6 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o self._generation = Some(new_value.to_string()); self } - /// For downloading encrypted objects, provides the digest of the key for error-checking transmission. A digest is in the format of '='. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key hash* query property to the given value. - pub fn encryption_key_hash(mut self, new_value: &str) -> ObjectPatchCall<'a, C, A> { - self._encryption_key_hash = Some(new_value.to_string()); - self - } - /// For downloading encrypted objects, provides a base64-encoded 256-bit key to decrypt the object. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption key* query property to the given value. - pub fn encryption_key(mut self, new_value: &str) -> ObjectPatchCall<'a, C, A> { - self._encryption_key = Some(new_value.to_string()); - self - } - /// For downloading encrypted objects, specifies the encryption algorithm that would be used to decrypt the object. Only 'AES256' is supported currently. Algorithm, key, and key hash must be supplied together. - /// - /// Sets the *encryption algorithm* query property to the given value. - pub fn encryption_algorithm(mut self, new_value: &str) -> ObjectPatchCall<'a, C, A> { - self._encryption_algorithm = Some(new_value.to_string()); - self - } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// @@ -8746,272 +9144,6 @@ impl<'a, C, A> ObjectPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } -/// Returns the ACL entry for the specified entity on the specified object. -/// -/// A builder for the *get* method supported by a *objectAccessControl* resource. -/// It is not used directly, but through a `ObjectAccessControlMethods` instance. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_storage1 as storage1; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use storage1::Storage; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = Storage::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().get("bucket", "object", "entity") -/// .generation("ut") -/// .doit(); -/// # } -/// ``` -pub struct ObjectAccessControlGetCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a Storage<C, A>, - _bucket: String, - _object: String, - _entity: String, - _generation: Option<String>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for ObjectAccessControlGetCall<'a, C, A> {} - -impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, ObjectAccessControl)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "storage.objectAccessControls.get", - http_method: hyper::method::Method::Get }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); - params.push(("bucket", self._bucket.to_string())); - params.push(("object", self._object.to_string())); - params.push(("entity", self._entity.to_string())); - if let Some(value) = self._generation { - params.push(("generation", value.to_string())); - } - for &field in ["alt", "bucket", "object", "entity", "generation"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/storage/v1/b/{bucket}/o/{object}/acl/{entity}".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::DevstorageFullControl.as_ref().to_string(), ()); - } - - for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object"), ("{entity}", "entity")].iter() { - let mut replace_with: Option<&str> = None; - for &(name, ref value) in params.iter() { - if name == param_name { - replace_with = Some(value); - break; - } - } - url = url.replace(find_this, replace_with.expect("to find substitution value in params")); - } - { - let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); - for param_name in ["bucket", "object", "entity"].iter() { - for (index, &(ref name, _)) in params.iter().rev().enumerate() { - if name == param_name { - indices_for_removal.push(params.len() - index - 1); - break; - } - } - } - for &index in indices_for_removal.iter() { - params.remove(index); - } - } - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// Name of a bucket. - /// - /// Sets the *bucket* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { - self._bucket = new_value.to_string(); - self - } - /// Name of the object. - /// - /// Sets the *object* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn object(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { - self._object = new_value.to_string(); - self - } - /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. - /// - /// Sets the *entity* path property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn entity(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { - self._entity = new_value.to_string(); - self - } - /// If present, selects a specific revision of this object (as opposed to the latest version, the default). - /// - /// Sets the *generation* query property to the given value. - pub fn generation(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { - self._generation = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> ObjectAccessControlGetCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlGetCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::DevstorageFullControl`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> ObjectAccessControlGetCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Creates a new ACL entry on the specified object. /// /// A builder for the *insert* method supported by a *objectAccessControl* resource. @@ -9039,13 +9171,13 @@ impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::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.object_access_controls().insert(&req, "bucket", "object") -/// .generation("voluptua.") +/// .generation("sea") /// .doit(); /// # } /// ``` @@ -9138,16 +9270,20 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9317,13 +9453,13 @@ impl<'a, C, A> ObjectAccessControlInsertCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::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.object_access_controls().patch(&req, "bucket", "object", "entity") -/// .generation("ea") +/// .generation("voluptua.") /// .doit(); /// # } /// ``` @@ -9418,16 +9554,20 @@ impl<'a, C, A> ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9607,7 +9747,7 @@ impl<'a, C, A> ObjectAccessControlPatchCall<'a, C, A> where C: BorrowMut<hyper:: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.object_access_controls().list("bucket", "object") -/// .generation("dolor") +/// .generation("et") /// .doit(); /// # } /// ``` @@ -9695,16 +9835,20 @@ impl<'a, C, A> ObjectAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9861,7 +10005,7 @@ impl<'a, C, A> ObjectAccessControlListCall<'a, C, A> where C: BorrowMut<hyper::C /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.object_access_controls().delete("bucket", "object", "entity") -/// .generation("rebum.") +/// .generation("et") /// .doit(); /// # } /// ``` @@ -9950,16 +10094,20 @@ impl<'a, C, A> ObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10089,6 +10237,276 @@ impl<'a, C, A> ObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: } +/// Returns the ACL entry for the specified entity on the specified object. +/// +/// A builder for the *get* method supported by a *objectAccessControl* resource. +/// It is not used directly, but through a `ObjectAccessControlMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_storage1 as storage1; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use storage1::Storage; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = Storage::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().get("bucket", "object", "entity") +/// .generation("vero") +/// .doit(); +/// # } +/// ``` +pub struct ObjectAccessControlGetCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a Storage<C, A>, + _bucket: String, + _object: String, + _entity: String, + _generation: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for ObjectAccessControlGetCall<'a, C, A> {} + +impl<'a, C, A> ObjectAccessControlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, ObjectAccessControl)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "storage.objectAccessControls.get", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len())); + params.push(("bucket", self._bucket.to_string())); + params.push(("object", self._object.to_string())); + params.push(("entity", self._entity.to_string())); + if let Some(value) = self._generation { + params.push(("generation", value.to_string())); + } + for &field in ["alt", "bucket", "object", "entity", "generation"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/storage/v1/b/{bucket}/o/{object}/acl/{entity}".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::DevstorageFullControl.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object"), ("{entity}", "entity")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3); + for param_name in ["bucket", "object", "entity"].iter() { + for (index, &(ref name, _)) in params.iter().rev().enumerate() { + if name == param_name { + indices_for_removal.push(params.len() - index - 1); + break; + } + } + } + for &index in indices_for_removal.iter() { + params.remove(index); + } + } + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Name of a bucket. + /// + /// Sets the *bucket* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { + self._bucket = new_value.to_string(); + self + } + /// Name of the object. + /// + /// Sets the *object* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn object(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { + self._object = new_value.to_string(); + self + } + /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers. + /// + /// Sets the *entity* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn entity(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { + self._entity = new_value.to_string(); + self + } + /// If present, selects a specific revision of this object (as opposed to the latest version, the default). + /// + /// Sets the *generation* query property to the given value. + pub fn generation(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C, A> { + self._generation = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> ObjectAccessControlGetCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlGetCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::DevstorageFullControl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> ObjectAccessControlGetCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates an ACL entry on the specified object. /// /// A builder for the *update* method supported by a *objectAccessControl* resource. @@ -10116,13 +10534,13 @@ impl<'a, C, A> ObjectAccessControlDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ObjectAccessControl = Default::default(); +/// let mut req = ObjectAccessControl::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.object_access_controls().update(&req, "bucket", "object", "entity") -/// .generation("eirmod") +/// .generation("nonumy") /// .doit(); /// # } /// ``` @@ -10217,16 +10635,20 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10406,17 +10828,17 @@ impl<'a, C, A> ObjectAccessControlUpdateCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Bucket = Default::default(); +/// let mut req = Bucket::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.buckets().update(&req, "bucket") -/// .projection("consetetur") -/// .predefined_default_object_acl("et") -/// .predefined_acl("sed") -/// .if_metageneration_not_match("sit") -/// .if_metageneration_match("takimata") +/// .projection("sed") +/// .predefined_default_object_acl("no") +/// .predefined_acl("invidunt") +/// .if_metageneration_not_match("rebum.") +/// .if_metageneration_match("labore") /// .doit(); /// # } /// ``` @@ -10523,16 +10945,20 @@ impl<'a, C, A> BucketUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10720,9 +11146,9 @@ impl<'a, C, A> BucketUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().get("bucket") -/// .projection("nonumy") -/// .if_metageneration_not_match("rebum.") -/// .if_metageneration_match("Lorem") +/// .projection("elitr") +/// .if_metageneration_not_match("consetetur") +/// .if_metageneration_match("sea") /// .doit(); /// # } /// ``` @@ -10816,16 +11242,20 @@ impl<'a, C, A> BucketGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10986,8 +11416,8 @@ impl<'a, C, A> BucketGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().delete("bucket") -/// .if_metageneration_not_match("diam") -/// .if_metageneration_match("ut") +/// .if_metageneration_not_match("At") +/// .if_metageneration_match("sea") /// .doit(); /// # } /// ``` @@ -11076,16 +11506,20 @@ impl<'a, C, A> BucketDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11229,15 +11663,15 @@ impl<'a, C, A> BucketDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Bucket = Default::default(); +/// let mut req = Bucket::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.buckets().insert(&req, "project") -/// .projection("amet.") -/// .predefined_default_object_acl("ipsum") -/// .predefined_acl("ut") +/// .projection("diam") +/// .predefined_default_object_acl("accusam") +/// .predefined_acl("dolores") /// .doit(); /// # } /// ``` @@ -11312,16 +11746,20 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11495,17 +11933,17 @@ impl<'a, C, A> BucketInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Bucket = Default::default(); +/// let mut req = Bucket::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.buckets().patch(&req, "bucket") -/// .projection("sea") -/// .predefined_default_object_acl("ut") -/// .predefined_acl("eirmod") -/// .if_metageneration_not_match("sanctus") -/// .if_metageneration_match("voluptua.") +/// .projection("dolor") +/// .predefined_default_object_acl("aliquyam") +/// .predefined_acl("elitr") +/// .if_metageneration_not_match("ea") +/// .if_metageneration_match("et") /// .doit(); /// # } /// ``` @@ -11612,16 +12050,20 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11809,10 +12251,10 @@ impl<'a, C, A> BucketPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.buckets().list("project") -/// .projection("et") -/// .prefix("et") -/// .page_token("vero") -/// .max_results(65) +/// .projection("sed") +/// .prefix("dolor") +/// .page_token("sanctus") +/// .max_results(68) /// .doit(); /// # } /// ``` @@ -11886,16 +12328,20 @@ impl<'a, C, A> BucketListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/tagmanager1-cli/Cargo.toml b/gen/tagmanager1-cli/Cargo.toml deleted file mode 100644 index 0b152656ef..0000000000 --- a/gen/tagmanager1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-tagmanager1-cli" -version = "0.0.1+20150121" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with Tag Manager (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1-cli" -homepage = "https://developers.google.com/tag-manager/api/v1/" -documentation = "http://byron.github.io/google-apis-rs/google_tagmanager1_cli" -license = "MIT" -keywords = ["tagmanager", "google", "cli"] - -[[bin]] -name = "tagmanager1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-tagmanager1] -path = "../tagmanager1" diff --git a/gen/tagmanager1-cli/LICENSE.md b/gen/tagmanager1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/tagmanager1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/tagmanager1-cli/README.md b/gen/tagmanager1-cli/README.md deleted file mode 100644 index 1fcc018979..0000000000 --- a/gen/tagmanager1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO TAGMANAGER:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/tagmanager1-cli/mkdocs.yml b/gen/tagmanager1-cli/mkdocs.yml deleted file mode 100644 index 5344c3a6d5..0000000000 --- a/gen/tagmanager1-cli/mkdocs.yml +++ /dev/null @@ -1,62 +0,0 @@ -site_name: Tag Manager v0.0.1+20150121 -site_url: http://byron.github.io/google-apis-rs/google-tagmanager1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/tagmanager1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['accounts_containers-create.md', 'Accounts', 'Containers Create'] -- ['accounts_containers-delete.md', 'Accounts', 'Containers Delete'] -- ['accounts_containers-get.md', 'Accounts', 'Containers Get'] -- ['accounts_containers-list.md', 'Accounts', 'Containers List'] -- ['accounts_containers-macros-create.md', 'Accounts', 'Containers Macros Create'] -- ['accounts_containers-macros-delete.md', 'Accounts', 'Containers Macros Delete'] -- ['accounts_containers-macros-get.md', 'Accounts', 'Containers Macros Get'] -- ['accounts_containers-macros-list.md', 'Accounts', 'Containers Macros List'] -- ['accounts_containers-macros-update.md', 'Accounts', 'Containers Macros Update'] -- ['accounts_containers-rules-create.md', 'Accounts', 'Containers Rules Create'] -- ['accounts_containers-rules-delete.md', 'Accounts', 'Containers Rules Delete'] -- ['accounts_containers-rules-get.md', 'Accounts', 'Containers Rules Get'] -- ['accounts_containers-rules-list.md', 'Accounts', 'Containers Rules List'] -- ['accounts_containers-rules-update.md', 'Accounts', 'Containers Rules Update'] -- ['accounts_containers-tags-create.md', 'Accounts', 'Containers Tags Create'] -- ['accounts_containers-tags-delete.md', 'Accounts', 'Containers Tags Delete'] -- ['accounts_containers-tags-get.md', 'Accounts', 'Containers Tags Get'] -- ['accounts_containers-tags-list.md', 'Accounts', 'Containers Tags List'] -- ['accounts_containers-tags-update.md', 'Accounts', 'Containers Tags Update'] -- ['accounts_containers-triggers-create.md', 'Accounts', 'Containers Triggers Create'] -- ['accounts_containers-triggers-delete.md', 'Accounts', 'Containers Triggers Delete'] -- ['accounts_containers-triggers-get.md', 'Accounts', 'Containers Triggers Get'] -- ['accounts_containers-triggers-list.md', 'Accounts', 'Containers Triggers List'] -- ['accounts_containers-triggers-update.md', 'Accounts', 'Containers Triggers Update'] -- ['accounts_containers-update.md', 'Accounts', 'Containers Update'] -- ['accounts_containers-variables-create.md', 'Accounts', 'Containers Variables Create'] -- ['accounts_containers-variables-delete.md', 'Accounts', 'Containers Variables Delete'] -- ['accounts_containers-variables-get.md', 'Accounts', 'Containers Variables Get'] -- ['accounts_containers-variables-list.md', 'Accounts', 'Containers Variables List'] -- ['accounts_containers-variables-update.md', 'Accounts', 'Containers Variables Update'] -- ['accounts_containers-versions-create.md', 'Accounts', 'Containers Versions Create'] -- ['accounts_containers-versions-delete.md', 'Accounts', 'Containers Versions Delete'] -- ['accounts_containers-versions-get.md', 'Accounts', 'Containers Versions Get'] -- ['accounts_containers-versions-list.md', 'Accounts', 'Containers Versions List'] -- ['accounts_containers-versions-publish.md', 'Accounts', 'Containers Versions Publish'] -- ['accounts_containers-versions-restore.md', 'Accounts', 'Containers Versions Restore'] -- ['accounts_containers-versions-undelete.md', 'Accounts', 'Containers Versions Undelete'] -- ['accounts_containers-versions-update.md', 'Accounts', 'Containers Versions Update'] -- ['accounts_get.md', 'Accounts', 'Get'] -- ['accounts_list.md', 'Accounts', 'List'] -- ['accounts_permissions-create.md', 'Accounts', 'Permissions Create'] -- ['accounts_permissions-delete.md', 'Accounts', 'Permissions Delete'] -- ['accounts_permissions-get.md', 'Accounts', 'Permissions Get'] -- ['accounts_permissions-list.md', 'Accounts', 'Permissions List'] -- ['accounts_permissions-update.md', 'Accounts', 'Permissions Update'] -- ['accounts_update.md', 'Accounts', 'Update'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/tagmanager1-cli/src/cmn.rs b/gen/tagmanager1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/tagmanager1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/tagmanager1-cli/src/main.rs b/gen/tagmanager1-cli/src/main.rs deleted file mode 100644 index 41fb94ee6e..0000000000 --- a/gen/tagmanager1-cli/src/main.rs +++ /dev/null @@ -1,3483 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_tagmanager1 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::TagManager<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _accounts_containers_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Container = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "time-zone-id" => { - request.time_zone_id = Some(value.unwrap_or("").to_string()); - }, - "enabled-built-in-variable" => { - if request.enabled_built_in_variable.is_none() { - request.enabled_built_in_variable = Some(Default::default()); - } - request.enabled_built_in_variable.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "time-zone-country-id" => { - request.time_zone_country_id = Some(arg_from_str(value.unwrap_or("-0"), err, "time-zone-country-id", "int64")); - }, - "public-id" => { - request.public_id = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "domain-name" => { - if request.domain_name.is_none() { - request.domain_name = Some(Default::default()); - } - request.domain_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "usage-context" => { - if request.usage_context.is_none() { - request.usage_context = Some(Default::default()); - } - request.usage_context.as_mut().unwrap().push(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()); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_list(&self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_macros_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Macro = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "macro-id" => { - request.macro_id = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "enabling-rule-id" => { - if request.enabling_rule_id.is_none() { - request.enabling_rule_id = Some(Default::default()); - } - request.enabling_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "disabling-rule-id" => { - if request.disabling_rule_id.is_none() { - request.disabling_rule_id = Some(Default::default()); - } - request.disabling_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_macros_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_macros_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_macros_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_macros_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_macros_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_macros_list(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_macros_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Macro = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "macro-id" => { - request.macro_id = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "enabling-rule-id" => { - if request.enabling_rule_id.is_none() { - request.enabling_rule_id = Some(Default::default()); - } - request.enabling_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "disabling-rule-id" => { - if request.disabling_rule_id.is_none() { - request.disabling_rule_id = Some(Default::default()); - } - request.disabling_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request.type_ = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_rules_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Rule = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_rules_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_rules_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_rules_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_rules_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_rules_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_rules_list(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_rules_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Rule = Default::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); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_tags_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Tag = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_priority_init(request: &mut api::Tag) { - if request.priority.is_none() { - request.priority = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "blocking-trigger-id" => { - if request.blocking_trigger_id.is_none() { - request.blocking_trigger_id = Some(Default::default()); - } - request.blocking_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "tag-id" => { - request.tag_id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "priority.type" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "priority.value" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "priority.key" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "blocking-rule-id" => { - request_priority_init(&mut request); - if request.blocking_rule_id.is_none() { - request.blocking_rule_id = Some(Default::default()); - } - request.blocking_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "live-only" => { - request_priority_init(&mut request); - request.live_only = Some(arg_from_str(value.unwrap_or("false"), err, "live-only", "boolean")); - }, - "fingerprint" => { - request_priority_init(&mut request); - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "firing-rule-id" => { - request_priority_init(&mut request); - if request.firing_rule_id.is_none() { - request.firing_rule_id = Some(Default::default()); - } - request.firing_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "firing-trigger-id" => { - request_priority_init(&mut request); - if request.firing_trigger_id.is_none() { - request.firing_trigger_id = Some(Default::default()); - } - request.firing_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "type" => { - request_priority_init(&mut request); - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request_priority_init(&mut request); - request.notes = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request_priority_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_tags_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_tags_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_tags_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_tags_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_tags_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_tags_list(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_tags_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Tag = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_priority_init(request: &mut api::Tag) { - if request.priority.is_none() { - request.priority = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "blocking-trigger-id" => { - if request.blocking_trigger_id.is_none() { - request.blocking_trigger_id = Some(Default::default()); - } - request.blocking_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "tag-id" => { - request.tag_id = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "priority.type" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "priority.value" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "priority.key" => { - request_priority_init(&mut request); - request.priority.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "blocking-rule-id" => { - request_priority_init(&mut request); - if request.blocking_rule_id.is_none() { - request.blocking_rule_id = Some(Default::default()); - } - request.blocking_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "live-only" => { - request_priority_init(&mut request); - request.live_only = Some(arg_from_str(value.unwrap_or("false"), err, "live-only", "boolean")); - }, - "fingerprint" => { - request_priority_init(&mut request); - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "firing-rule-id" => { - request_priority_init(&mut request); - if request.firing_rule_id.is_none() { - request.firing_rule_id = Some(Default::default()); - } - request.firing_rule_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "firing-trigger-id" => { - request_priority_init(&mut request); - if request.firing_trigger_id.is_none() { - request.firing_trigger_id = Some(Default::default()); - } - request.firing_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "type" => { - request_priority_init(&mut request); - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request_priority_init(&mut request); - request.notes = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request_priority_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_check_validation_init(request: &mut api::Trigger) { - if request.check_validation.is_none() { - request.check_validation = Some(Default::default()); - } - } - - fn request_enable_all_videos_init(request: &mut api::Trigger) { - if request.enable_all_videos.is_none() { - request.enable_all_videos = Some(Default::default()); - } - } - - fn request_event_name_init(request: &mut api::Trigger) { - if request.event_name.is_none() { - request.event_name = Some(Default::default()); - } - } - - fn request_interval_init(request: &mut api::Trigger) { - if request.interval.is_none() { - request.interval = Some(Default::default()); - } - } - - fn request_limit_init(request: &mut api::Trigger) { - if request.limit.is_none() { - request.limit = Some(Default::default()); - } - } - - fn request_unique_trigger_id_init(request: &mut api::Trigger) { - if request.unique_trigger_id.is_none() { - request.unique_trigger_id = Some(Default::default()); - } - } - - fn request_video_percentage_list_init(request: &mut api::Trigger) { - if request.video_percentage_list.is_none() { - request.video_percentage_list = Some(Default::default()); - } - } - - fn request_wait_for_tags_init(request: &mut api::Trigger) { - if request.wait_for_tags.is_none() { - request.wait_for_tags = Some(Default::default()); - } - } - - fn request_wait_for_tags_timeout_init(request: &mut api::Trigger) { - if request.wait_for_tags_timeout.is_none() { - request.wait_for_tags_timeout = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "video-percentage-list.type" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "video-percentage-list.value" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "video-percentage-list.key" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "interval.type" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "interval.value" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "interval.key" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "wait-for-tags.type" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "wait-for-tags.value" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "wait-for-tags.key" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "container-id" => { - request_wait_for_tags_init(&mut request); - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "unique-trigger-id.type" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "unique-trigger-id.value" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "unique-trigger-id.key" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.type" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.value" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.key" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "name" => { - request_wait_for_tags_timeout_init(&mut request); - request.name = Some(value.unwrap_or("").to_string()); - }, - "event-name.type" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "event-name.value" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "event-name.key" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "trigger-id" => { - request_event_name_init(&mut request); - request.trigger_id = Some(value.unwrap_or("").to_string()); - }, - "limit.type" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "limit.value" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "limit.key" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "check-validation.type" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "check-validation.value" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "check-validation.key" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "fingerprint" => { - request_check_validation_init(&mut request); - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request_check_validation_init(&mut request); - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "enable-all-videos.type" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "enable-all-videos.value" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "enable-all-videos.key" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "account-id" => { - request_enable_all_videos_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_triggers_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_triggers_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_triggers_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_triggers_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_triggers_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_triggers_list(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_triggers_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Trigger = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_check_validation_init(request: &mut api::Trigger) { - if request.check_validation.is_none() { - request.check_validation = Some(Default::default()); - } - } - - fn request_enable_all_videos_init(request: &mut api::Trigger) { - if request.enable_all_videos.is_none() { - request.enable_all_videos = Some(Default::default()); - } - } - - fn request_event_name_init(request: &mut api::Trigger) { - if request.event_name.is_none() { - request.event_name = Some(Default::default()); - } - } - - fn request_interval_init(request: &mut api::Trigger) { - if request.interval.is_none() { - request.interval = Some(Default::default()); - } - } - - fn request_limit_init(request: &mut api::Trigger) { - if request.limit.is_none() { - request.limit = Some(Default::default()); - } - } - - fn request_unique_trigger_id_init(request: &mut api::Trigger) { - if request.unique_trigger_id.is_none() { - request.unique_trigger_id = Some(Default::default()); - } - } - - fn request_video_percentage_list_init(request: &mut api::Trigger) { - if request.video_percentage_list.is_none() { - request.video_percentage_list = Some(Default::default()); - } - } - - fn request_wait_for_tags_init(request: &mut api::Trigger) { - if request.wait_for_tags.is_none() { - request.wait_for_tags = Some(Default::default()); - } - } - - fn request_wait_for_tags_timeout_init(request: &mut api::Trigger) { - if request.wait_for_tags_timeout.is_none() { - request.wait_for_tags_timeout = Some(Default::default()); - } - } - - match &field_name.to_string()[..] { - "video-percentage-list.type" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "video-percentage-list.value" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "video-percentage-list.key" => { - request_video_percentage_list_init(&mut request); - request.video_percentage_list.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "interval.type" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "interval.value" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "interval.key" => { - request_interval_init(&mut request); - request.interval.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "wait-for-tags.type" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "wait-for-tags.value" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "wait-for-tags.key" => { - request_wait_for_tags_init(&mut request); - request.wait_for_tags.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "container-id" => { - request_wait_for_tags_init(&mut request); - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "unique-trigger-id.type" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "unique-trigger-id.value" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "unique-trigger-id.key" => { - request_unique_trigger_id_init(&mut request); - request.unique_trigger_id.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.type" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.value" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "wait-for-tags-timeout.key" => { - request_wait_for_tags_timeout_init(&mut request); - request.wait_for_tags_timeout.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "name" => { - request_wait_for_tags_timeout_init(&mut request); - request.name = Some(value.unwrap_or("").to_string()); - }, - "event-name.type" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "event-name.value" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "event-name.key" => { - request_event_name_init(&mut request); - request.event_name.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "trigger-id" => { - request_event_name_init(&mut request); - request.trigger_id = Some(value.unwrap_or("").to_string()); - }, - "limit.type" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "limit.value" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "limit.key" => { - request_limit_init(&mut request); - request.limit.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "check-validation.type" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "check-validation.value" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "check-validation.key" => { - request_check_validation_init(&mut request); - request.check_validation.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "fingerprint" => { - request_check_validation_init(&mut request); - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "type" => { - request_check_validation_init(&mut request); - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "enable-all-videos.type" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "enable-all-videos.value" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().value = value.unwrap_or("").to_string(); - }, - "enable-all-videos.key" => { - request_enable_all_videos_init(&mut request); - request.enable_all_videos.as_mut().unwrap().key = value.unwrap_or("").to_string(); - }, - "account-id" => { - request_enable_all_videos_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "time-zone-id" => { - request.time_zone_id = Some(value.unwrap_or("").to_string()); - }, - "enabled-built-in-variable" => { - if request.enabled_built_in_variable.is_none() { - request.enabled_built_in_variable = Some(Default::default()); - } - request.enabled_built_in_variable.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "time-zone-country-id" => { - request.time_zone_country_id = Some(arg_from_str(value.unwrap_or("-0"), err, "time-zone-country-id", "int64")); - }, - "public-id" => { - request.public_id = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "domain-name" => { - if request.domain_name.is_none() { - request.domain_name = Some(Default::default()); - } - request.domain_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "usage-context" => { - if request.usage_context.is_none() { - request.usage_context = Some(Default::default()); - } - request.usage_context.as_mut().unwrap().push(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()); - }, - "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&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::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "variable-id" => { - request.variable_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "enabling-trigger-id" => { - if request.enabling_trigger_id.is_none() { - request.enabling_trigger_id = Some(Default::default()); - } - request.enabling_trigger_id.as_mut().unwrap().push(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()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "disabling-trigger-id" => { - if request.disabling_trigger_id.is_none() { - request.disabling_trigger_id = Some(Default::default()); - } - request.disabling_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_variables_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_variables_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_variables_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_variables_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_variables_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_variables_list(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_variables_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Variable = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - match &field_name.to_string()[..] { - "schedule-start-ms" => { - request.schedule_start_ms = Some(value.unwrap_or("").to_string()); - }, - "schedule-end-ms" => { - request.schedule_end_ms = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request.name = Some(value.unwrap_or("").to_string()); - }, - "variable-id" => { - request.variable_id = Some(value.unwrap_or("").to_string()); - }, - "notes" => { - request.notes = Some(value.unwrap_or("").to_string()); - }, - "enabling-trigger-id" => { - if request.enabling_trigger_id.is_none() { - request.enabling_trigger_id = Some(Default::default()); - } - request.enabling_trigger_id.as_mut().unwrap().push(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()); - }, - "type" => { - request.type_ = Some(value.unwrap_or("").to_string()); - }, - "disabling-trigger-id" => { - if request.disabling_trigger_id.is_none() { - request.disabling_trigger_id = Some(Default::default()); - } - request.disabling_trigger_id.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "container-id" => { - request.container_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::CreateContainerVersionRequestVersionOptions = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_containers_versions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_list(&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); - match key { - "headers" => { - call = call.headers(arg_from_str(value.unwrap_or("false"), err, "headers", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_publish(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_publish(&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); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_restore(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_restore(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_undelete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().containers_versions_undelete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_containers_versions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::ContainerVersion = Default::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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - if let Err(field_err) = field_name.set(&*key) { - err.issues.push(field_err); - } - fn request_container_init(request: &mut api::ContainerVersion) { - if request.container.is_none() { - request.container = Some(Default::default()); - } - } - - match &field_name.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()); - }, - "container.enabled-built-in-variable" => { - request_container_init(&mut request); - if request.container.as_mut().unwrap().enabled_built_in_variable.is_none() { - request.container.as_mut().unwrap().enabled_built_in_variable = Some(Default::default()); - } - request.container.as_mut().unwrap().enabled_built_in_variable.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "container.time-zone-country-id" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().time_zone_country_id = Some(arg_from_str(value.unwrap_or("-0"), err, "container.time-zone-country-id", "int64")); - }, - "container.public-id" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().public_id = Some(value.unwrap_or("").to_string()); - }, - "container.container-id" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().container_id = Some(value.unwrap_or("").to_string()); - }, - "container.domain-name" => { - request_container_init(&mut request); - if request.container.as_mut().unwrap().domain_name.is_none() { - request.container.as_mut().unwrap().domain_name = Some(Default::default()); - } - request.container.as_mut().unwrap().domain_name.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "container.notes" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().notes = Some(value.unwrap_or("").to_string()); - }, - "container.usage-context" => { - request_container_init(&mut request); - if request.container.as_mut().unwrap().usage_context.is_none() { - request.container.as_mut().unwrap().usage_context = Some(Default::default()); - } - request.container.as_mut().unwrap().usage_context.as_mut().unwrap().push(value.unwrap_or("").to_string()); - }, - "container.fingerprint" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().fingerprint = Some(value.unwrap_or("").to_string()); - }, - "container.account-id" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().account_id = Some(value.unwrap_or("").to_string()); - }, - "container.name" => { - request_container_init(&mut request); - request.container.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); - }, - "container-id" => { - request_container_init(&mut request); - request.container_id = Some(value.unwrap_or("").to_string()); - }, - "deleted" => { - request_container_init(&mut request); - request.deleted = Some(arg_from_str(value.unwrap_or("false"), err, "deleted", "boolean")); - }, - "notes" => { - request_container_init(&mut request); - request.notes = Some(value.unwrap_or("").to_string()); - }, - "name" => { - request_container_init(&mut request); - request.name = Some(value.unwrap_or("").to_string()); - }, - "container-version-id" => { - request_container_init(&mut request); - request.container_version_id = Some(value.unwrap_or("").to_string()); - }, - "fingerprint" => { - request_container_init(&mut request); - request.fingerprint = Some(value.unwrap_or("").to_string()); - }, - "account-id" => { - request_container_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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().get(&self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_permissions_create(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::UserAccess = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - request.account_access.as_mut().unwrap().permission.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_permissions_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().permissions_delete(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _accounts_permissions_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().permissions_get(&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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_permissions_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.accounts().permissions_list(&self.opt.arg_account_id); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_permissions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::UserAccess = Default::default(); - 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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - request.account_access.as_mut().unwrap().permission.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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _accounts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Account = Default::default(); - 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); - 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::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_accounts { - if self.opt.cmd_containers_create { - call_result = self._accounts_containers_create(dry_run, &mut err); - } else if self.opt.cmd_containers_delete { - call_result = self._accounts_containers_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_get { - call_result = self._accounts_containers_get(dry_run, &mut err); - } else if self.opt.cmd_containers_list { - call_result = self._accounts_containers_list(dry_run, &mut err); - } else if self.opt.cmd_containers_macros_create { - call_result = self._accounts_containers_macros_create(dry_run, &mut err); - } else if self.opt.cmd_containers_macros_delete { - call_result = self._accounts_containers_macros_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_macros_get { - call_result = self._accounts_containers_macros_get(dry_run, &mut err); - } else if self.opt.cmd_containers_macros_list { - call_result = self._accounts_containers_macros_list(dry_run, &mut err); - } else if self.opt.cmd_containers_macros_update { - call_result = self._accounts_containers_macros_update(dry_run, &mut err); - } else if self.opt.cmd_containers_rules_create { - call_result = self._accounts_containers_rules_create(dry_run, &mut err); - } else if self.opt.cmd_containers_rules_delete { - call_result = self._accounts_containers_rules_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_rules_get { - call_result = self._accounts_containers_rules_get(dry_run, &mut err); - } else if self.opt.cmd_containers_rules_list { - call_result = self._accounts_containers_rules_list(dry_run, &mut err); - } else if self.opt.cmd_containers_rules_update { - call_result = self._accounts_containers_rules_update(dry_run, &mut err); - } else if self.opt.cmd_containers_tags_create { - call_result = self._accounts_containers_tags_create(dry_run, &mut err); - } else if self.opt.cmd_containers_tags_delete { - call_result = self._accounts_containers_tags_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_tags_get { - call_result = self._accounts_containers_tags_get(dry_run, &mut err); - } else if self.opt.cmd_containers_tags_list { - call_result = self._accounts_containers_tags_list(dry_run, &mut err); - } else if self.opt.cmd_containers_tags_update { - call_result = self._accounts_containers_tags_update(dry_run, &mut err); - } else if self.opt.cmd_containers_triggers_create { - call_result = self._accounts_containers_triggers_create(dry_run, &mut err); - } else if self.opt.cmd_containers_triggers_delete { - call_result = self._accounts_containers_triggers_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_triggers_get { - call_result = self._accounts_containers_triggers_get(dry_run, &mut err); - } else if self.opt.cmd_containers_triggers_list { - call_result = self._accounts_containers_triggers_list(dry_run, &mut err); - } else if self.opt.cmd_containers_triggers_update { - call_result = self._accounts_containers_triggers_update(dry_run, &mut err); - } else if self.opt.cmd_containers_update { - call_result = self._accounts_containers_update(dry_run, &mut err); - } else if self.opt.cmd_containers_variables_create { - call_result = self._accounts_containers_variables_create(dry_run, &mut err); - } else if self.opt.cmd_containers_variables_delete { - call_result = self._accounts_containers_variables_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_variables_get { - call_result = self._accounts_containers_variables_get(dry_run, &mut err); - } else if self.opt.cmd_containers_variables_list { - call_result = self._accounts_containers_variables_list(dry_run, &mut err); - } else if self.opt.cmd_containers_variables_update { - call_result = self._accounts_containers_variables_update(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_create { - call_result = self._accounts_containers_versions_create(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_delete { - call_result = self._accounts_containers_versions_delete(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_get { - call_result = self._accounts_containers_versions_get(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_list { - call_result = self._accounts_containers_versions_list(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_publish { - call_result = self._accounts_containers_versions_publish(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_restore { - call_result = self._accounts_containers_versions_restore(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_undelete { - call_result = self._accounts_containers_versions_undelete(dry_run, &mut err); - } else if self.opt.cmd_containers_versions_update { - call_result = self._accounts_containers_versions_update(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._accounts_get(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._accounts_list(dry_run, &mut err); - } else if self.opt.cmd_permissions_create { - call_result = self._accounts_permissions_create(dry_run, &mut err); - } else if self.opt.cmd_permissions_delete { - call_result = self._accounts_permissions_delete(dry_run, &mut err); - } else if self.opt.cmd_permissions_get { - call_result = self._accounts_permissions_get(dry_run, &mut err); - } else if self.opt.cmd_permissions_list { - call_result = self._accounts_permissions_list(dry_run, &mut err); - } else if self.opt.cmd_permissions_update { - call_result = self._accounts_permissions_update(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._accounts_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "tagmanager1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "tagmanager1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::TagManager::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/tagmanager1/Cargo.toml b/gen/tagmanager1/Cargo.toml index 6a0249ea88..6b8c7b1e77 100644 --- a/gen/tagmanager1/Cargo.toml +++ b/gen/tagmanager1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-tagmanager1" version = "0.1.5+20150121" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/tag-manager/api/v1/" diff --git a/gen/tagmanager1/README.md b/gen/tagmanager1/README.md index 2c00d22ad0..350b4d2aeb 100644 --- a/gen/tagmanager1/README.md +++ b/gen/tagmanager1/README.md @@ -138,7 +138,7 @@ let mut hub = TagManager::new(hyper::Client::new(), auth); // As the method needs a request, you would usually fill it with the desired information // into the respective structure. Some of the parts shown here might not be applicable ! // Values shown here are possibly random and not representative ! -let mut req: Trigger = Default::default(); +let mut req = Trigger::default(); // You can configure optional parameters by calling the respective setters at will, and // execute the final call using `doit()`. diff --git a/gen/tagmanager1/src/cmn.rs b/gen/tagmanager1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/tagmanager1/src/cmn.rs +++ b/gen/tagmanager1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/tagmanager1/src/lib.rs b/gen/tagmanager1/src/lib.rs index 7506bcba76..7da6223121 100644 --- a/gen/tagmanager1/src/lib.rs +++ b/gen/tagmanager1/src/lib.rs @@ -139,7 +139,7 @@ //! // As the method needs a request, you would usually fill it with the desired information //! // into the respective structure. Some of the parts shown here might not be applicable ! //! // Values shown here are possibly random and not representative ! -//! let mut req: Trigger = Default::default(); +//! let mut req = Trigger::default(); //! //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. @@ -339,7 +339,7 @@ impl Default for Scope { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Trigger = Default::default(); +/// let mut req = Trigger::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -415,7 +415,7 @@ impl<'a, C, A> TagManager<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListMacrosResponse { /// All GTM Macros of a GTM Container. - pub macros: Vec<Macro>, + pub macros: Option<Vec<Macro>>, } impl ResponseResult for ListMacrosResponse {} @@ -428,7 +428,7 @@ impl ResponseResult for ListMacrosResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountAccess { /// List of Account permissions. Valid account permissions are read and manage. - pub permission: Vec<String>, + pub permission: Option<Vec<String>>, } impl Part for AccountAccess {} @@ -557,7 +557,7 @@ impl ResponseResult for Container {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListContainersResponse { /// All Containers of a GTM Account. - pub containers: Vec<Container>, + pub containers: Option<Vec<Container>>, } impl ResponseResult for ListContainersResponse {} @@ -626,7 +626,7 @@ impl ResponseResult for Macro {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListVariablesResponse { /// All GTM Variables of a GTM Container. - pub variables: Vec<Variable>, + pub variables: Option<Vec<Variable>>, } impl ResponseResult for ListVariablesResponse {} @@ -753,7 +753,7 @@ impl ResponseResult for Rule {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListAccountsResponse { /// List of GTM Accounts that a user has access to. - pub accounts: Vec<Account>, + pub accounts: Option<Vec<Account>>, } impl ResponseResult for ListAccountsResponse {} @@ -772,10 +772,10 @@ impl ResponseResult for ListAccountsResponse {} pub struct PublishContainerVersionResponse { /// The container version created. #[serde(rename="containerVersion")] - pub container_version: ContainerVersion, + pub container_version: Option<ContainerVersion>, /// Compiler errors or not. #[serde(rename="compilerError")] - pub compiler_error: bool, + pub compiler_error: Option<bool>, } impl ResponseResult for PublishContainerVersionResponse {} @@ -862,10 +862,10 @@ impl ResponseResult for Trigger {} pub struct CreateContainerVersionResponse { /// The container version created. #[serde(rename="containerVersion")] - pub container_version: ContainerVersion, + pub container_version: Option<ContainerVersion>, /// Compiler errors or not. #[serde(rename="compilerError")] - pub compiler_error: bool, + pub compiler_error: Option<bool>, } impl ResponseResult for CreateContainerVersionResponse {} @@ -883,7 +883,7 @@ impl ResponseResult for CreateContainerVersionResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListRulesResponse { /// All GTM Rules of a GTM Container. - pub rules: Vec<Rule>, + pub rules: Option<Vec<Rule>>, } impl ResponseResult for ListRulesResponse {} @@ -897,9 +897,9 @@ impl ResponseResult for ListRulesResponse {} pub struct ContainerAccess { /// GTM Container ID. #[serde(rename="containerId")] - pub container_id: String, + pub container_id: Option<String>, /// List of Container permissions. Valid container permissions are: read, edit, delete, publish. - pub permission: Vec<String>, + pub permission: Option<Vec<String>>, } impl Part for ContainerAccess {} @@ -946,13 +946,13 @@ impl ResponseResult for UserAccess {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Parameter { /// This map parameter's parameters (must have keys; keys must be unique). - pub map: Vec<Parameter>, + pub map: Option<Vec<Parameter>>, /// This list parameter's parameters (keys will be ignored). - pub list: Vec<Parameter>, + pub list: Option<Vec<Parameter>>, /// The named key that uniquely identifies a parameter. Required for top-level parameters, as well as map values. Ignored for list values. - pub key: String, + pub key: Option<String>, /// A parameter's value (may contain macro references such as "{{myMacro}}") as appropriate to the specified type. - pub value: String, + pub value: Option<String>, /// The parameter type. Valid values are: /// - boolean: The value represents a boolean, represented as 'true' or 'false' /// - integer: The value represents a 64-bit signed integer value, in base 10 @@ -960,7 +960,7 @@ pub struct Parameter { /// - map: A map of parameters should be specified /// - template: The value represents any text; this can include macro references (even macro references that might return non-string types) #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for Parameter {} @@ -978,7 +978,7 @@ impl Part for Parameter {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListTagsResponse { /// All GTM Tags of a GTM Container. - pub tags: Vec<Tag>, + pub tags: Option<Vec<Tag>>, } impl ResponseResult for ListTagsResponse {} @@ -997,7 +997,7 @@ impl ResponseResult for ListTagsResponse {} pub struct ListAccountUsersResponse { /// All GTM AccountUsers of a GTM Account. #[serde(rename="userAccess")] - pub user_access: Vec<UserAccess>, + pub user_access: Option<Vec<UserAccess>>, } impl ResponseResult for ListAccountUsersResponse {} @@ -1038,7 +1038,7 @@ impl RequestValue for CreateContainerVersionRequestVersionOptions {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListTriggersResponse { /// All GTM Triggers of a GTM Container. - pub triggers: Vec<Trigger>, + pub triggers: Option<Vec<Trigger>>, } impl ResponseResult for ListTriggersResponse {} @@ -1051,33 +1051,33 @@ impl ResponseResult for ListTriggersResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContainerVersionHeader { /// Container version display name. - pub name: String, + pub name: Option<String>, /// A value of true indicates this container version has been deleted. - pub deleted: bool, + pub deleted: Option<bool>, /// Number of macros in the container version. #[serde(rename="numMacros")] - pub num_macros: String, + pub num_macros: Option<String>, /// GTM Container ID. #[serde(rename="containerId")] - pub container_id: String, + pub container_id: Option<String>, /// Number of tags in the container version. #[serde(rename="numTags")] - pub num_tags: String, + pub num_tags: Option<String>, /// Number of rules in the container version. #[serde(rename="numRules")] - pub num_rules: String, + pub num_rules: Option<String>, /// The Container Version ID uniquely identifies the GTM Container Version. #[serde(rename="containerVersionId")] - pub container_version_id: String, + pub container_version_id: Option<String>, /// Number of triggers in the container version. #[serde(rename="numTriggers")] - pub num_triggers: String, + pub num_triggers: Option<String>, /// GTM Account ID. #[serde(rename="accountId")] - pub account_id: String, + pub account_id: Option<String>, /// Number of variables in the container version. #[serde(rename="numVariables")] - pub num_variables: String, + pub num_variables: Option<String>, } impl Part for ContainerVersionHeader {} @@ -1146,10 +1146,10 @@ impl ResponseResult for ContainerVersion {} pub struct ListContainerVersionsResponse { /// All container version headers of a GTM Container. #[serde(rename="containerVersionHeader")] - pub container_version_header: Vec<ContainerVersionHeader>, + pub container_version_header: Option<Vec<ContainerVersionHeader>>, /// All versions of a GTM Container. #[serde(rename="containerVersion")] - pub container_version: Vec<ContainerVersion>, + pub container_version: Option<Vec<ContainerVersion>>, } impl ResponseResult for ListContainerVersionsResponse {} @@ -1217,10 +1217,10 @@ pub struct Condition { /// - At this time, the left operand (arg0) must be a reference to a macro. /// - For case-insensitive Regex matching, include a boolean parameter named ignore_case that is set to true. If not specified or set to any other value, the matching will be case sensitive. /// - To negate an operator, include a boolean parameter named negate boolean parameter that is set to true. - pub parameter: Vec<Parameter>, + pub parameter: Option<Vec<Parameter>>, /// The type of operator for this condition. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for Condition {} @@ -2327,16 +2327,20 @@ impl<'a, C, A> AccountContainerListCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2557,16 +2561,20 @@ impl<'a, C, A> AccountPermissionListCall<'a, C, A> where C: BorrowMut<hyper::Cli loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2791,16 +2799,20 @@ impl<'a, C, A> AccountContainerVersionUndeleteCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2960,7 +2972,7 @@ impl<'a, C, A> AccountContainerVersionUndeleteCall<'a, C, A> where C: BorrowMut< /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserAccess = Default::default(); +/// let mut req = UserAccess::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3052,16 +3064,20 @@ impl<'a, C, A> AccountPermissionCreateCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3296,16 +3312,20 @@ impl<'a, C, A> AccountPermissionDeleteCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3528,16 +3548,20 @@ impl<'a, C, A> AccountContainerGetCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3775,16 +3799,20 @@ impl<'a, C, A> AccountContainerVersionListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3941,7 +3969,7 @@ impl<'a, C, A> AccountContainerVersionListCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Trigger = Default::default(); +/// let mut req = Trigger::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4042,16 +4070,20 @@ impl<'a, C, A> AccountContainerTriggerUpdateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4316,16 +4348,20 @@ impl<'a, C, A> AccountContainerTriggerGetCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -4567,16 +4603,20 @@ impl<'a, C, A> AccountContainerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -4716,7 +4756,7 @@ impl<'a, C, A> AccountContainerDeleteCall<'a, C, A> where C: BorrowMut<hyper::Cl /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Container = Default::default(); +/// let mut req = Container::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4808,16 +4848,20 @@ impl<'a, C, A> AccountContainerCreateCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5054,16 +5098,20 @@ impl<'a, C, A> AccountContainerTagDeleteCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5213,7 +5261,7 @@ impl<'a, C, A> AccountContainerTagDeleteCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Rule = Default::default(); +/// let mut req = Rule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -5314,16 +5362,20 @@ impl<'a, C, A> AccountContainerRuleUpdateCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -5587,16 +5639,20 @@ impl<'a, C, A> AccountContainerRuleDeleteCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -5829,16 +5885,20 @@ impl<'a, C, A> AccountContainerTagListCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6078,16 +6138,20 @@ impl<'a, C, A> AccountContainerVersionPublishCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -6254,7 +6318,7 @@ impl<'a, C, A> AccountContainerVersionPublishCall<'a, C, A> where C: BorrowMut<h /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Tag = Default::default(); +/// let mut req = Tag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -6348,16 +6412,20 @@ impl<'a, C, A> AccountContainerTagCreateCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -6603,16 +6671,20 @@ impl<'a, C, A> AccountContainerTriggerListCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6846,16 +6918,20 @@ impl<'a, C, A> AccountContainerVersionDeleteCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7005,7 +7081,7 @@ impl<'a, C, A> AccountContainerVersionDeleteCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Account = Default::default(); +/// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7102,16 +7178,20 @@ impl<'a, C, A> AccountUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7355,16 +7435,20 @@ impl<'a, C, A> AccountContainerMacroDeleteCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7514,7 +7598,7 @@ impl<'a, C, A> AccountContainerMacroDeleteCall<'a, C, A> where C: BorrowMut<hype /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: CreateContainerVersionRequestVersionOptions = Default::default(); +/// let mut req = CreateContainerVersionRequestVersionOptions::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -7608,16 +7692,20 @@ impl<'a, C, A> AccountContainerVersionCreateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7863,16 +7951,20 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8022,7 +8114,7 @@ impl<'a, C, A> AccountPermissionGetCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Rule = Default::default(); +/// let mut req = Rule::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8116,16 +8208,20 @@ impl<'a, C, A> AccountContainerRuleCreateCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8373,16 +8469,20 @@ impl<'a, C, A> AccountContainerVersionRestoreCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -8627,16 +8727,20 @@ impl<'a, C, A> AccountContainerRuleGetCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8796,7 +8900,7 @@ impl<'a, C, A> AccountContainerRuleGetCall<'a, C, A> where C: BorrowMut<hyper::C /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Variable = Default::default(); +/// let mut req = Variable::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -8890,16 +8994,20 @@ impl<'a, C, A> AccountContainerVariableCreateCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9145,16 +9253,20 @@ impl<'a, C, A> AccountContainerVariableListCall<'a, C, A> where C: BorrowMut<hyp loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9304,7 +9416,7 @@ impl<'a, C, A> AccountContainerVariableListCall<'a, C, A> where C: BorrowMut<hyp /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Macro = Default::default(); +/// let mut req = Macro::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -9398,16 +9510,20 @@ impl<'a, C, A> AccountContainerMacroCreateCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9655,16 +9771,20 @@ impl<'a, C, A> AccountContainerTagGetCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9909,16 +10029,20 @@ impl<'a, C, A> AccountContainerVariableGetCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10162,16 +10286,20 @@ impl<'a, C, A> AccountContainerTriggerDeleteCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10404,16 +10532,20 @@ impl<'a, C, A> AccountContainerMacroListCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10563,7 +10695,7 @@ impl<'a, C, A> AccountContainerMacroListCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Trigger = Default::default(); +/// let mut req = Trigger::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10657,16 +10789,20 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10829,7 +10965,7 @@ impl<'a, C, A> AccountContainerTriggerCreateCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Macro = Default::default(); +/// let mut req = Macro::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -10930,16 +11066,20 @@ impl<'a, C, A> AccountContainerMacroUpdateCall<'a, C, A> where C: BorrowMut<hype loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11174,16 +11314,20 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11313,7 +11457,7 @@ impl<'a, C, A> AccountListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: UserAccess = Default::default(); +/// let mut req = UserAccess::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -11407,16 +11551,20 @@ impl<'a, C, A> AccountPermissionUpdateCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11663,16 +11811,20 @@ impl<'a, C, A> AccountContainerVariableDeleteCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -11903,16 +12055,20 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12052,7 +12208,7 @@ impl<'a, C, A> AccountGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Container = Default::default(); +/// let mut req = Container::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12151,16 +12307,20 @@ impl<'a, C, A> AccountContainerUpdateCall<'a, C, A> where C: BorrowMut<hyper::Cl loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12413,16 +12573,20 @@ impl<'a, C, A> AccountContainerRuleListCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12572,7 +12736,7 @@ impl<'a, C, A> AccountContainerRuleListCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Tag = Default::default(); +/// let mut req = Tag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -12673,16 +12837,20 @@ impl<'a, C, A> AccountContainerTagUpdateCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -12947,16 +13115,20 @@ impl<'a, C, A> AccountContainerMacroGetCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13116,7 +13288,7 @@ impl<'a, C, A> AccountContainerMacroGetCall<'a, C, A> where C: BorrowMut<hyper:: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ContainerVersion = Default::default(); +/// let mut req = ContainerVersion::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13217,16 +13389,20 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13406,7 +13582,7 @@ impl<'a, C, A> AccountContainerVersionUpdateCall<'a, C, A> where C: BorrowMut<hy /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Variable = Default::default(); +/// let mut req = Variable::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -13507,16 +13683,20 @@ impl<'a, C, A> AccountContainerVariableUpdateCall<'a, C, A> where C: BorrowMut<h loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13781,16 +13961,20 @@ impl<'a, C, A> AccountContainerVersionGetCall<'a, C, A> where C: BorrowMut<hyper loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/taskqueue1_beta2-cli/Cargo.toml b/gen/taskqueue1_beta2-cli/Cargo.toml deleted file mode 100644 index 472ffe5e6b..0000000000 --- a/gen/taskqueue1_beta2-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-taskqueue1_beta2-cli" -version = "0.0.1+20141111" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with taskqueue (protocol v1beta2)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2-cli" -homepage = "https://developers.google.com/appengine/docs/python/taskqueue/rest" -documentation = "http://byron.github.io/google-apis-rs/google_taskqueue1_beta2_cli" -license = "MIT" -keywords = ["taskqueue", "google", "cli"] - -[[bin]] -name = "taskqueue1-beta2" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-taskqueue1_beta2] -path = "../taskqueue1_beta2" diff --git a/gen/taskqueue1_beta2-cli/LICENSE.md b/gen/taskqueue1_beta2-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/taskqueue1_beta2-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/taskqueue1_beta2-cli/README.md b/gen/taskqueue1_beta2-cli/README.md deleted file mode 100644 index 7baaf70b4b..0000000000 --- a/gen/taskqueue1_beta2-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO TASKQUEUE:V1BETA2 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/taskqueue1_beta2-cli/mkdocs.yml b/gen/taskqueue1_beta2-cli/mkdocs.yml deleted file mode 100644 index 88e631eedb..0000000000 --- a/gen/taskqueue1_beta2-cli/mkdocs.yml +++ /dev/null @@ -1,24 +0,0 @@ -site_name: taskqueue v0.0.1+20141111 -site_url: http://byron.github.io/google-apis-rs/google-taskqueue1_beta2-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/taskqueue1_beta2-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['taskqueues_get.md', 'Taskqueues', 'Get'] -- ['tasks_delete.md', 'Tasks', 'Delete'] -- ['tasks_get.md', 'Tasks', 'Get'] -- ['tasks_insert.md', 'Tasks', 'Insert'] -- ['tasks_lease.md', 'Tasks', 'Lease'] -- ['tasks_list.md', 'Tasks', 'List'] -- ['tasks_patch.md', 'Tasks', 'Patch'] -- ['tasks_update.md', 'Tasks', 'Update'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/taskqueue1_beta2-cli/src/cmn.rs b/gen/taskqueue1_beta2-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/taskqueue1_beta2-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/taskqueue1_beta2-cli/src/main.rs b/gen/taskqueue1_beta2-cli/src/main.rs deleted file mode 100644 index d60733d421..0000000000 --- a/gen/taskqueue1_beta2-cli/src/main.rs +++ /dev/null @@ -1,628 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_taskqueue1_beta2 as api; - -use std::env; -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 --help - -All documentation details can be found TODO: <URL to github.io docs here, see #51> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Taskqueue<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _taskqueues_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.taskqueues().get(&self.opt.arg_project, &self.opt.arg_taskqueue); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "get-stats" => { - call = call.get_stats(arg_from_str(value.unwrap_or("false"), err, "get-stats", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.tasks().delete(&self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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) => { - println!("DEBUG: REMOVE ME {:?}", response); - None - } - } - } - } - - fn _tasks_get(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.tasks().get(&self.opt.arg_project, &self.opt.arg_taskqueue, &self.opt.arg_task); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Task = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "lease-timestamp" => { - request.lease_timestamp = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "retry-count" => { - request.retry_count = Some(arg_from_str(value.unwrap_or("-0"), err, "retry-count", "integer")); - }, - "tag" => { - request.tag = Some(value.unwrap_or("").to_string()); - }, - "payload-base64" => { - request.payload_base64 = Some(value.unwrap_or("").to_string()); - }, - "queue-name" => { - request.queue_name = Some(value.unwrap_or("").to_string()); - }, - "enqueue-timestamp" => { - request.enqueue_timestamp = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_lease(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let num_tasks: i32 = arg_from_str(&self.opt.arg_num_tasks, err, "<num-tasks>", "integer"); - let lease_secs: i32 = arg_from_str(&self.opt.arg_lease_secs, err, "<lease-secs>", "integer"); - let mut call = self.hub.tasks().lease(&self.opt.arg_project, &self.opt.arg_taskqueue, num_tasks, lease_secs); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "tag" => { - call = call.tag(value.unwrap_or("")); - }, - "group-by-tag" => { - call = call.group_by_tag(arg_from_str(value.unwrap_or("false"), err, "group-by-tag", "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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.tasks().list(&self.opt.arg_project, &self.opt.arg_taskqueue); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Task = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "lease-timestamp" => { - request.lease_timestamp = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "retry-count" => { - request.retry_count = Some(arg_from_str(value.unwrap_or("-0"), err, "retry-count", "integer")); - }, - "tag" => { - request.tag = Some(value.unwrap_or("").to_string()); - }, - "payload-base64" => { - request.payload_base64 = Some(value.unwrap_or("").to_string()); - }, - "queue-name" => { - request.queue_name = Some(value.unwrap_or("").to_string()); - }, - "enqueue-timestamp" => { - request.enqueue_timestamp = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _tasks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut request: api::Task = Default::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); - match key { - "alt" - |"fields" - |"key" - |"oauth-token" - |"pretty-print" - |"quota-user" - |"user-ip" => { - let map = [ - ("oauth-token", "oauth_token"), - ("pretty-print", "prettyPrint"), - ("quota-user", "quotaUser"), - ("user-ip", "userIp"), - ]; - call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")) - }, - _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), - } - } - let mut field_name: FieldCursor = Default::default(); - for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); - 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()); - }, - "lease-timestamp" => { - request.lease_timestamp = Some(value.unwrap_or("").to_string()); - }, - "id" => { - request.id = Some(value.unwrap_or("").to_string()); - }, - "retry-count" => { - request.retry_count = Some(arg_from_str(value.unwrap_or("-0"), err, "retry-count", "integer")); - }, - "tag" => { - request.tag = Some(value.unwrap_or("").to_string()); - }, - "payload-base64" => { - request.payload_base64 = Some(value.unwrap_or("").to_string()); - }, - "queue-name" => { - request.queue_name = Some(value.unwrap_or("").to_string()); - }, - "enqueue-timestamp" => { - request.enqueue_timestamp = 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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_taskqueues { - if self.opt.cmd_get { - call_result = self._taskqueues_get(dry_run, &mut err); - } else { - unreachable!(); - } - } else if self.opt.cmd_tasks { - if self.opt.cmd_delete { - call_result = self._tasks_delete(dry_run, &mut err); - } else if self.opt.cmd_get { - call_result = self._tasks_get(dry_run, &mut err); - } else if self.opt.cmd_insert { - call_result = self._tasks_insert(dry_run, &mut err); - } else if self.opt.cmd_lease { - call_result = self._tasks_lease(dry_run, &mut err); - } else if self.opt.cmd_list { - call_result = self._tasks_list(dry_run, &mut err); - } else if self.opt.cmd_patch { - call_result = self._tasks_patch(dry_run, &mut err); - } else if self.opt.cmd_update { - call_result = self._tasks_update(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "taskqueue1-beta2-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "taskqueue1-beta2", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Taskqueue::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/taskqueue1_beta2/Cargo.toml b/gen/taskqueue1_beta2/Cargo.toml index 6582039349..f64ecb67f4 100644 --- a/gen/taskqueue1_beta2/Cargo.toml +++ b/gen/taskqueue1_beta2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-taskqueue1_beta2" version = "0.1.5+20141111" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/appengine/docs/python/taskqueue/rest" diff --git a/gen/taskqueue1_beta2/src/cmn.rs b/gen/taskqueue1_beta2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/taskqueue1_beta2/src/cmn.rs +++ b/gen/taskqueue1_beta2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/taskqueue1_beta2/src/lib.rs b/gen/taskqueue1_beta2/src/lib.rs index 3bdd412754..821025782a 100644 --- a/gen/taskqueue1_beta2/src/lib.rs +++ b/gen/taskqueue1_beta2/src/lib.rs @@ -395,9 +395,9 @@ impl ResponseResult for Task {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Tasks2 { /// The actual list of tasks currently active in the TaskQueue. - pub items: Vec<Task>, + pub items: Option<Vec<Task>>, /// The kind of object returned, a list of tasks. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Tasks2 {} @@ -411,16 +411,16 @@ impl ResponseResult for Tasks2 {} pub struct TaskQueueStats { /// The timestamp (in seconds since the epoch) of the oldest unfinished task. #[serde(rename="oldestTask")] - pub oldest_task: String, + pub oldest_task: Option<String>, /// Number of tasks leased in the last minute. #[serde(rename="leasedLastMinute")] - pub leased_last_minute: String, + pub leased_last_minute: Option<String>, /// Number of tasks leased in the last hour. #[serde(rename="leasedLastHour")] - pub leased_last_hour: String, + pub leased_last_hour: Option<String>, /// Number of tasks in the queue. #[serde(rename="totalTasks")] - pub total_tasks: i32, + pub total_tasks: Option<i32>, } impl NestedType for TaskQueueStats {} @@ -435,13 +435,13 @@ impl Part for TaskQueueStats {} pub struct TaskQueueAcl { /// Email addresses of users who can "consume" tasks from the TaskQueue. This means they can Dequeue and Delete tasks from the queue. #[serde(rename="consumerEmails")] - pub consumer_emails: Vec<String>, + pub consumer_emails: Option<Vec<String>>, /// Email addresses of users who can "produce" tasks into the TaskQueue. This means they can Insert tasks into the queue. #[serde(rename="producerEmails")] - pub producer_emails: Vec<String>, + pub producer_emails: Option<Vec<String>>, /// Email addresses of users who are "admins" of the TaskQueue. This means they can control the queue, eg set ACLs for the queue. #[serde(rename="adminEmails")] - pub admin_emails: Vec<String>, + pub admin_emails: Option<Vec<String>>, } impl NestedType for TaskQueueAcl {} @@ -460,16 +460,16 @@ impl Part for TaskQueueAcl {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TaskQueue { /// The kind of REST object returned, in this case taskqueue. - pub kind: String, + pub kind: Option<String>, /// Statistics for the TaskQueue object in question. - pub stats: TaskQueueStats, + pub stats: Option<TaskQueueStats>, /// Name of the taskqueue. - pub id: String, + pub id: Option<String>, /// The number of times we should lease out tasks before giving up on them. If unset we lease them out forever until a worker deletes the task. #[serde(rename="maxLeases")] - pub max_leases: i32, + pub max_leases: Option<i32>, /// ACLs that are applicable to this TaskQueue object. - pub acl: TaskQueueAcl, + pub acl: Option<TaskQueueAcl>, } impl Resource for TaskQueue {} @@ -488,9 +488,9 @@ impl ResponseResult for TaskQueue {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Tasks { /// The actual list of tasks returned as a result of the lease operation. - pub items: Vec<Task>, + pub items: Option<Vec<Task>>, /// The kind of object returned, a list of tasks. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for Tasks {} @@ -881,16 +881,20 @@ impl<'a, C, A> TaskqueueGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1144,16 +1148,20 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -1337,7 +1345,7 @@ impl<'a, C, A> TaskLeaseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1431,16 +1439,20 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1687,16 +1699,20 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1846,7 +1862,7 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1944,16 +1960,20 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2217,16 +2237,20 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2461,16 +2485,20 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2630,7 +2658,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2728,16 +2756,20 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/tasks1-cli/Cargo.toml b/gen/tasks1-cli/Cargo.toml index 7b56ef6465..9ea5e282d0 100644 --- a/gen/tasks1-cli/Cargo.toml +++ b/gen/tasks1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-tasks1-cli" version = "0.0.1+20141121" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/tasks/firstapp" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/tasks1-cli/src/cmn.rs b/gen/tasks1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/tasks1-cli/src/cmn.rs +++ b/gen/tasks1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/tasks1-cli/src/main.rs b/gen/tasks1-cli/src/main.rs index 65f6d2ab94..41be672588 100644 --- a/gen/tasks1-cli/src/main.rs +++ b/gen/tasks1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -45,6 +46,12 @@ Configuration: 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. "); mod cmn; @@ -68,7 +75,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasklists().delete(&self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -99,7 +106,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -110,7 +116,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasklists().get(&self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -142,8 +148,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -152,10 +157,10 @@ impl Engine { fn _tasklists_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TaskList = Default::default(); + let mut request = api::TaskList::default(); let mut call = self.hub.tasklists().insert(&request); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -175,9 +180,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -217,8 +223,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -229,7 +234,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasklists().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -267,8 +272,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -277,10 +281,10 @@ impl Engine { fn _tasklists_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TaskList = Default::default(); + let mut request = api::TaskList::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -300,9 +304,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -342,8 +347,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -352,10 +356,10 @@ impl Engine { fn _tasklists_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::TaskList = Default::default(); + let mut request = api::TaskList::default(); 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -375,9 +379,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -417,8 +422,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -429,7 +433,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasks().clear(&self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -460,7 +464,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -471,7 +474,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasks().delete(&self.opt.arg_tasklist, &self.opt.arg_task); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -502,7 +505,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -513,7 +515,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasks().get(&self.opt.arg_tasklist, &self.opt.arg_task); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -545,8 +547,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -555,10 +556,10 @@ impl Engine { fn _tasks_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Task = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "previous" => { call = call.previous(value.unwrap_or("")); @@ -584,9 +585,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -650,8 +652,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -662,7 +663,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasks().list(&self.opt.arg_tasklist); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "updated-min" => { call = call.updated_min(value.unwrap_or("")); @@ -724,8 +725,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -736,7 +736,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.tasks().move_(&self.opt.arg_tasklist, &self.opt.arg_task); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "previous" => { call = call.previous(value.unwrap_or("")); @@ -774,8 +774,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -784,10 +783,10 @@ impl Engine { fn _tasks_patch(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Task = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -807,9 +806,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -873,8 +873,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -883,10 +882,10 @@ impl Engine { fn _tasks_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Task = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -906,9 +905,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -972,8 +972,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1001,7 +1000,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_tasks { + } + else if self.opt.cmd_tasks { if self.opt.cmd_clear { call_result = self._tasks_clear(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -1041,21 +1041,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "tasks1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "tasks1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "tasks1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "tasks1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::TasksHub::new(hyper::Client::new(), auth), + hub: api::TasksHub::new(client, auth), }; match engine._doit(true) { @@ -1075,12 +1091,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/tasks1/Cargo.toml b/gen/tasks1/Cargo.toml index fe82aeccd1..08de7634f9 100644 --- a/gen/tasks1/Cargo.toml +++ b/gen/tasks1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-tasks1" version = "0.1.5+20141121" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/google-apps/tasks/firstapp" diff --git a/gen/tasks1/src/cmn.rs b/gen/tasks1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/tasks1/src/cmn.rs +++ b/gen/tasks1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/tasks1/src/lib.rs b/gen/tasks1/src/lib.rs index f0050aafe6..322271d5e0 100644 --- a/gen/tasks1/src/lib.rs +++ b/gen/tasks1/src/lib.rs @@ -459,13 +459,13 @@ impl ResponseResult for TaskList {} pub struct TaskLists { /// Token that can be used to request the next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Collection of task lists. - pub items: Vec<TaskList>, + pub items: Option<Vec<TaskList>>, /// Type of the resource. This is always "tasks#taskLists". - pub kind: String, + pub kind: Option<String>, /// ETag of the resource. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for TaskLists {} @@ -478,12 +478,12 @@ impl ResponseResult for TaskLists {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TaskLinks { /// The URL. - pub link: String, + pub link: Option<String>, /// Type of the link, e.g. "email". #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The description. In HTML speak: Everything between <a> and </a>. - pub description: String, + pub description: Option<String>, } impl NestedType for TaskLinks {} @@ -503,13 +503,13 @@ impl Part for TaskLinks {} pub struct Tasks { /// Token used to access the next page of this result. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Collection of tasks. - pub items: Vec<Task>, + pub items: Option<Vec<Task>>, /// Type of the resource. This is always "tasks#tasks". - pub kind: String, + pub kind: Option<String>, /// ETag of the resource. - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for Tasks {} @@ -1035,16 +1035,20 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1254,7 +1258,7 @@ impl<'a, C, A> TaskListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1348,16 +1352,20 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1520,7 +1528,7 @@ impl<'a, C, A> TaskUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1614,16 +1622,20 @@ impl<'a, C, A> TaskPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1866,16 +1878,20 @@ impl<'a, C, A> TaskClearCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2098,16 +2114,20 @@ impl<'a, C, A> TaskMoveCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -2353,16 +2373,20 @@ impl<'a, C, A> TaskDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2585,16 +2609,20 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2744,7 +2772,7 @@ impl<'a, C, A> TaskGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Task = Default::default(); +/// let mut req = Task::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2846,16 +2874,20 @@ impl<'a, C, A> TaskInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3087,16 +3119,20 @@ impl<'a, C, A> TasklistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3240,7 +3276,7 @@ impl<'a, C, A> TasklistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TaskList = Default::default(); +/// let mut req = TaskList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3332,16 +3368,20 @@ impl<'a, C, A> TasklistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3574,16 +3614,20 @@ impl<'a, C, A> TasklistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -3713,7 +3757,7 @@ impl<'a, C, A> TasklistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TaskList = Default::default(); +/// let mut req = TaskList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3805,16 +3849,20 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3967,7 +4015,7 @@ impl<'a, C, A> TasklistPatchCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: TaskList = Default::default(); +/// let mut req = TaskList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -4033,16 +4081,20 @@ impl<'a, C, A> TasklistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -4266,16 +4318,20 @@ impl<'a, C, A> TasklistGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/translate2-cli/Cargo.toml b/gen/translate2-cli/Cargo.toml index d3eecb56f8..ac8c9091fc 100644 --- a/gen/translate2-cli/Cargo.toml +++ b/gen/translate2-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-translate2-cli" version = "0.0.1+20141123" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/translate/v2/using_rest" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/translate2-cli/src/cmn.rs b/gen/translate2-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/translate2-cli/src/cmn.rs +++ b/gen/translate2-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/translate2-cli/src/main.rs b/gen/translate2-cli/src/main.rs index eece901a26..18f49370ee 100644 --- a/gen/translate2-cli/src/main.rs +++ b/gen/translate2-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -18,9 +19,9 @@ use std::io::{self, Write}; docopt!(Options derive Debug, " Usage: - translate2 [options] detections list <q> [-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 [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> @@ -30,6 +31,12 @@ Configuration: 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. "); mod cmn; @@ -53,7 +60,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.detections().list(&self.opt.arg_q); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -85,8 +92,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -97,7 +103,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.languages().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "target" => { call = call.target(value.unwrap_or("")); @@ -132,8 +138,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -144,7 +149,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.translations().list(&self.opt.arg_q, &self.opt.arg_target); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "source" => { call = call.source(value.unwrap_or("")); @@ -185,8 +190,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -204,13 +208,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_languages { + } + else if self.opt.cmd_languages { if self.opt.cmd_list { call_result = self._languages_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_translations { + } + else if self.opt.cmd_translations { if self.opt.cmd_list { call_result = self._translations_list(dry_run, &mut err); } else { @@ -236,21 +242,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "translate2-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "translate2-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "translate2", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "translate2", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Translate::new(hyper::Client::new(), auth), + hub: api::Translate::new(client, auth), }; match engine._doit(true) { @@ -270,12 +292,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/translate2/Cargo.toml b/gen/translate2/Cargo.toml index 868c3bee3c..2059932bac 100644 --- a/gen/translate2/Cargo.toml +++ b/gen/translate2/Cargo.toml @@ -5,7 +5,7 @@ name = "google-translate2" version = "0.1.5+20141123" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/translate/v2/using_rest" diff --git a/gen/translate2/src/cmn.rs b/gen/translate2/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/translate2/src/cmn.rs +++ b/gen/translate2/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/translate2/src/lib.rs b/gen/translate2/src/lib.rs index 938e70c7da..9986d7ff27 100644 --- a/gen/translate2/src/lib.rs +++ b/gen/translate2/src/lib.rs @@ -320,7 +320,7 @@ impl<'a, C, A> Translate<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DetectionsListResponse { /// A detections contains detection results of several text - pub detections: Vec<DetectionsResource>, + pub detections: Option<Vec<DetectionsResource>>, } impl ResponseResult for DetectionsListResponse {} @@ -338,7 +338,7 @@ impl ResponseResult for DetectionsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LanguagesListResponse { /// List of source/target languages supported by the translation API. If target parameter is unspecified, the list is sorted by the ASCII code point order of the language code. If target parameter is specified, the list is sorted by the collation order of the language name in the target language. - pub languages: Vec<LanguagesResource>, + pub languages: Option<Vec<LanguagesResource>>, } impl ResponseResult for LanguagesListResponse {} @@ -354,11 +354,11 @@ impl ResponseResult for LanguagesListResponse {} pub struct DetectionsResource { /// A boolean to indicate is the language detection result reliable. #[serde(rename="isReliable")] - pub is_reliable: bool, + pub is_reliable: Option<bool>, /// The confidence of the detection resul of this language. - pub confidence: f32, + pub confidence: Option<f32>, /// The language we detect - pub language: String, + pub language: Option<String>, } impl Part for DetectionsResource {} @@ -372,10 +372,10 @@ impl Part for DetectionsResource {} pub struct TranslationsResource { /// Detected source language if source parameter is unspecified. #[serde(rename="detectedSourceLanguage")] - pub detected_source_language: String, + pub detected_source_language: Option<String>, /// The translation. #[serde(rename="translatedText")] - pub translated_text: String, + pub translated_text: Option<String>, } impl Part for TranslationsResource {} @@ -388,9 +388,9 @@ impl Part for TranslationsResource {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LanguagesResource { /// The localized name of the language if target parameter is given. - pub name: String, + pub name: Option<String>, /// The language code. - pub language: String, + pub language: Option<String>, } impl Part for LanguagesResource {} @@ -404,11 +404,11 @@ impl Part for LanguagesResource {} pub struct DetectionsResourceNested { /// A boolean to indicate is the language detection result reliable. #[serde(rename="isReliable")] - pub is_reliable: bool, + pub is_reliable: Option<bool>, /// The confidence of the detection resul of this language. - pub confidence: f32, + pub confidence: Option<f32>, /// The language we detect - pub language: String, + pub language: Option<String>, } impl NestedType for DetectionsResourceNested {} @@ -427,7 +427,7 @@ impl Part for DetectionsResourceNested {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TranslationsListResponse { /// Translations contains list of translation results of given text - pub translations: Vec<TranslationsResource>, + pub translations: Option<Vec<TranslationsResource>>, } impl ResponseResult for TranslationsListResponse {} diff --git a/gen/urlshortener1-cli/Cargo.toml b/gen/urlshortener1-cli/Cargo.toml index 97b14c9648..5166d4db8c 100644 --- a/gen/urlshortener1-cli/Cargo.toml +++ b/gen/urlshortener1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-urlshortener1-cli" version = "0.0.1+20150319" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/url-shortener/v1/getting_started" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/urlshortener1-cli/src/cmn.rs b/gen/urlshortener1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/urlshortener1-cli/src/cmn.rs +++ b/gen/urlshortener1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/urlshortener1-cli/src/main.rs b/gen/urlshortener1-cli/src/main.rs index fbcf4f8ae9..e18855c576 100644 --- a/gen/urlshortener1-cli/src/main.rs +++ b/gen/urlshortener1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -34,6 +35,12 @@ Configuration: 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. "); mod cmn; @@ -57,7 +64,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.url().get(&self.opt.arg_short_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "projection" => { call = call.projection(value.unwrap_or("")); @@ -92,8 +99,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -102,10 +108,10 @@ impl Engine { fn _url_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Url = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -125,18 +131,54 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_analytics_all_time_init(request: &mut api::Url) { + request_analytics_init(request); + if request.analytics.as_mut().unwrap().all_time.is_none() { + request.analytics.as_mut().unwrap().all_time = Some(Default::default()); + } + } + + fn request_analytics_day_init(request: &mut api::Url) { + request_analytics_init(request); + if request.analytics.as_mut().unwrap().day.is_none() { + request.analytics.as_mut().unwrap().day = Some(Default::default()); + } + } + fn request_analytics_init(request: &mut api::Url) { if request.analytics.is_none() { request.analytics = Some(Default::default()); } } + fn request_analytics_month_init(request: &mut api::Url) { + request_analytics_init(request); + if request.analytics.as_mut().unwrap().month.is_none() { + request.analytics.as_mut().unwrap().month = Some(Default::default()); + } + } + + fn request_analytics_two_hours_init(request: &mut api::Url) { + request_analytics_init(request); + if request.analytics.as_mut().unwrap().two_hours.is_none() { + request.analytics.as_mut().unwrap().two_hours = Some(Default::default()); + } + } + + fn request_analytics_week_init(request: &mut api::Url) { + request_analytics_init(request); + if request.analytics.as_mut().unwrap().week.is_none() { + request.analytics.as_mut().unwrap().week = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "status" => { request.status = Some(value.unwrap_or("").to_string()); @@ -148,44 +190,44 @@ impl Engine { request.created = Some(value.unwrap_or("").to_string()); }, "analytics.week.short-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().week.short_url_clicks = value.unwrap_or("").to_string(); + request_analytics_week_init(&mut request); + request.analytics.as_mut().unwrap().week.as_mut().unwrap().short_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.week.long-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().week.long_url_clicks = value.unwrap_or("").to_string(); + request_analytics_week_init(&mut request); + request.analytics.as_mut().unwrap().week.as_mut().unwrap().long_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.all-time.short-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().all_time.short_url_clicks = value.unwrap_or("").to_string(); + request_analytics_all_time_init(&mut request); + request.analytics.as_mut().unwrap().all_time.as_mut().unwrap().short_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.all-time.long-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().all_time.long_url_clicks = value.unwrap_or("").to_string(); + request_analytics_all_time_init(&mut request); + request.analytics.as_mut().unwrap().all_time.as_mut().unwrap().long_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.two-hours.short-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().two_hours.short_url_clicks = value.unwrap_or("").to_string(); + request_analytics_two_hours_init(&mut request); + request.analytics.as_mut().unwrap().two_hours.as_mut().unwrap().short_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.two-hours.long-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().two_hours.long_url_clicks = value.unwrap_or("").to_string(); + request_analytics_two_hours_init(&mut request); + request.analytics.as_mut().unwrap().two_hours.as_mut().unwrap().long_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.day.short-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().day.short_url_clicks = value.unwrap_or("").to_string(); + request_analytics_day_init(&mut request); + request.analytics.as_mut().unwrap().day.as_mut().unwrap().short_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.day.long-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().day.long_url_clicks = value.unwrap_or("").to_string(); + request_analytics_day_init(&mut request); + request.analytics.as_mut().unwrap().day.as_mut().unwrap().long_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.month.short-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().month.short_url_clicks = value.unwrap_or("").to_string(); + request_analytics_month_init(&mut request); + request.analytics.as_mut().unwrap().month.as_mut().unwrap().short_url_clicks = Some(value.unwrap_or("").to_string()); }, "analytics.month.long-url-clicks" => { - request_analytics_init(&mut request); - request.analytics.as_mut().unwrap().month.long_url_clicks = value.unwrap_or("").to_string(); + request_analytics_month_init(&mut request); + request.analytics.as_mut().unwrap().month.as_mut().unwrap().long_url_clicks = Some(value.unwrap_or("").to_string()); }, "long-url" => { request_analytics_init(&mut request); @@ -212,8 +254,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -224,7 +265,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.url().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-token" => { call = call.start_token(value.unwrap_or("")); @@ -262,8 +303,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -305,21 +345,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "urlshortener1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "urlshortener1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "urlshortener1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "urlshortener1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Urlshortener::new(hyper::Client::new(), auth), + hub: api::Urlshortener::new(client, auth), }; match engine._doit(true) { @@ -339,12 +395,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/urlshortener1/Cargo.toml b/gen/urlshortener1/Cargo.toml index c421e447cc..0de65ad41d 100644 --- a/gen/urlshortener1/Cargo.toml +++ b/gen/urlshortener1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-urlshortener1" version = "0.1.5+20150319" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/url-shortener/v1/getting_started" diff --git a/gen/urlshortener1/src/cmn.rs b/gen/urlshortener1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/urlshortener1/src/cmn.rs +++ b/gen/urlshortener1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/urlshortener1/src/lib.rs b/gen/urlshortener1/src/lib.rs index 86bb7108d6..9f7ffcd2b9 100644 --- a/gen/urlshortener1/src/lib.rs +++ b/gen/urlshortener1/src/lib.rs @@ -330,17 +330,17 @@ impl<'a, C, A> Urlshortener<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AnalyticsSummary { /// Click analytics over the last week. - pub week: AnalyticsSnapshot, + pub week: Option<AnalyticsSnapshot>, /// Click analytics over all time. #[serde(rename="allTime")] - pub all_time: AnalyticsSnapshot, + pub all_time: Option<AnalyticsSnapshot>, /// Click analytics over the last two hours. #[serde(rename="twoHours")] - pub two_hours: AnalyticsSnapshot, + pub two_hours: Option<AnalyticsSnapshot>, /// Click analytics over the last day. - pub day: AnalyticsSnapshot, + pub day: Option<AnalyticsSnapshot>, /// Click analytics over the last month. - pub month: AnalyticsSnapshot, + pub month: Option<AnalyticsSnapshot>, } impl Part for AnalyticsSummary {} @@ -390,17 +390,17 @@ impl ResponseResult for Url {} pub struct UrlHistory { /// A token to provide to get the next page of results. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// A list of URL resources. - pub items: Vec<Url>, + pub items: Option<Vec<Url>>, /// The fixed string "urlshortener#urlHistory". - pub kind: String, + pub kind: Option<String>, /// Number of items returned with each full "page" of results. Note that the last page could have fewer items than the "itemsPerPage" value. #[serde(rename="itemsPerPage")] - pub items_per_page: i32, + pub items_per_page: Option<i32>, /// Total number of short URLs associated with this user (may be approximate). #[serde(rename="totalItems")] - pub total_items: i32, + pub total_items: Option<i32>, } impl ResponseResult for UrlHistory {} @@ -414,18 +414,18 @@ impl ResponseResult for UrlHistory {} pub struct AnalyticsSnapshot { /// Number of clicks on this short URL. #[serde(rename="shortUrlClicks")] - pub short_url_clicks: String, + pub short_url_clicks: Option<String>, /// Top platforms or OSes, e.g. "Windows"; sorted by (descending) click counts. Only present if this data is available. - pub platforms: Vec<StringCount>, + pub platforms: Option<Vec<StringCount>>, /// Top browsers, e.g. "Chrome"; sorted by (descending) click counts. Only present if this data is available. - pub browsers: Vec<StringCount>, + pub browsers: Option<Vec<StringCount>>, /// Top countries (expressed as country codes), e.g. "US" or "DE"; sorted by (descending) click counts. Only present if this data is available. - pub countries: Vec<StringCount>, + pub countries: Option<Vec<StringCount>>, /// Top referring hosts, e.g. "www.google.com"; sorted by (descending) click counts. Only present if this data is available. - pub referrers: Vec<StringCount>, + pub referrers: Option<Vec<StringCount>>, /// Number of clicks on all goo.gl short URLs pointing to this long URL. #[serde(rename="longUrlClicks")] - pub long_url_clicks: String, + pub long_url_clicks: Option<String>, } impl Part for AnalyticsSnapshot {} @@ -438,9 +438,9 @@ impl Part for AnalyticsSnapshot {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StringCount { /// Number of clicks for this top entry, e.g. for this particular country or browser. - pub count: String, + pub count: Option<String>, /// Label assigned to this top entry, e.g. "US" or "Chrome". - pub id: String, + pub id: Option<String>, } impl Part for StringCount {} @@ -574,7 +574,7 @@ impl<'a, C, A> UrlMethods<'a, C, A> { /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Url = Default::default(); +/// let mut req = Url::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -640,16 +640,20 @@ impl<'a, C, A> UrlInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -854,16 +858,20 @@ impl<'a, C, A> UrlGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2 loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1075,16 +1083,20 @@ impl<'a, C, A> UrlListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/gen/webfonts1-cli/Cargo.toml b/gen/webfonts1-cli/Cargo.toml deleted file mode 100644 index 843891dd22..0000000000 --- a/gen/webfonts1-cli/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# DO NOT EDIT ! -# This file was generated automatically from 'src/mako/Cargo.toml.mako' -# DO NOT EDIT ! -[package] - -name = "google-webfonts1-cli" -version = "0.0.1+20140210" -authors = ["Sebastian Thiel <byronimo@gmail>"] -description = "A complete library to interact with webfonts (protocol v1)" -repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1-cli" -homepage = "https://developers.google.com/fonts/docs/developer_api" -documentation = "http://byron.github.io/google-apis-rs/google_webfonts1_cli" -license = "MIT" -keywords = ["webfonts", "google", "cli"] - -[[bin]] -name = "webfonts1" - -[dependencies] -hyper = "*" -mime = "*" -yup-oauth2 = "*" -docopt = "*" -docopt_macros = "*" -rustc-serialize = "*" -serde = ">= 0.3.0" -serde_macros = "*" - -[dependencies.google-webfonts1] -path = "../webfonts1" diff --git a/gen/webfonts1-cli/LICENSE.md b/gen/webfonts1-cli/LICENSE.md deleted file mode 100644 index ae22e6ec52..0000000000 --- a/gen/webfonts1-cli/LICENSE.md +++ /dev/null @@ -1,30 +0,0 @@ -<!--- -DO NOT EDIT ! -This file was generated automatically from 'src/mako/LICENSE.md.mako' -DO NOT EDIT ! ---> -The MIT License (MIT) -===================== - -Copyright © `2015` `Sebastian Thiel` - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the “Software”), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/webfonts1-cli/README.md b/gen/webfonts1-cli/README.md deleted file mode 100644 index 5c37fe560e..0000000000 --- a/gen/webfonts1-cli/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HELLO WEBFONTS:V1 - - -Include information about application secret files, and how we automatically write a default one. \ No newline at end of file diff --git a/gen/webfonts1-cli/mkdocs.yml b/gen/webfonts1-cli/mkdocs.yml deleted file mode 100644 index 924720343c..0000000000 --- a/gen/webfonts1-cli/mkdocs.yml +++ /dev/null @@ -1,17 +0,0 @@ -site_name: webfonts v0.0.1+20140210 -site_url: http://byron.github.io/google-apis-rs/google-webfonts1-cli -site_description: Write integrating applications with bcore - -repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/webfonts1-cli - -docs_dir: docs -site_dir: build_html - -pages: -- ['index.md', 'Home'] -- ['webfonts_list.md', 'Webfonts', 'List'] - -theme: readthedocs - -copyright: Copyright © 2015, `Sebastian Thiel` - diff --git a/gen/webfonts1-cli/src/cmn.rs b/gen/webfonts1-cli/src/cmn.rs deleted file mode 100644 index fd8d66fa4c..0000000000 --- a/gen/webfonts1-cli/src/cmn.rs +++ /dev/null @@ -1,439 +0,0 @@ -// COPY OF 'src/rust/cli/cmn.rs' -// DO NOT EDIT -use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token}; -use rustc_serialize::json; -use mime::Mime; - -use std::fs; -use std::env; -use std::io; -use std::fmt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::string::ToString; -use std::io::{Write, Read, stdout}; - -use std::default::Default; - -const FIELD_SEP: char = '.'; - -#[derive(Clone, Default)] -pub struct FieldCursor(Vec<String>); - -impl ToString for FieldCursor { - fn to_string(&self) -> String { - self.0.connect(".") - } -} - -impl FieldCursor { - pub fn set(&mut self, value: &str) -> Result<(), CLIError> { - if value.len() == 0 { - return Err(CLIError::Field(FieldError::Empty)) - } - - let mut first_is_field_sep = false; - let mut char_count: usize = 0; - let mut last_c = FIELD_SEP; - let mut num_conscutive_field_seps = 0; - - let mut field = String::new(); - let mut fields = self.0.clone(); - - let push_field = |fs: &mut Vec<String>, f: &mut String| { - if f.len() > 0 { - fs.push(f.clone()); - f.truncate(0); - } - }; - - for (cid, c) in value.chars().enumerate() { - char_count += 1; - - if c == FIELD_SEP { - if cid == 0 { - first_is_field_sep = true; - } - num_conscutive_field_seps += 1; - if cid > 0 && last_c == FIELD_SEP { - if fields.pop().is_none() { - return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string()))) - } - } else { - push_field(&mut fields, &mut field); - } - } else { - num_conscutive_field_seps = 0; - if cid == 1 { - if first_is_field_sep { - fields.truncate(0); - } - } - field.push(c); - } - - last_c = c; - } - - push_field(&mut fields, &mut field); - - if char_count == 1 && first_is_field_sep { - fields.truncate(0); - } - if char_count > 1 && num_conscutive_field_seps == 1 { - return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string()))) - } - - self.0 = fields; - Ok(()) - } - - pub fn num_fields(&self) -> usize { - self.0.len() - } -} - -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) - -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { - None => { - add_err(); - return (kv, None) - }, - Some(pos) => { - let key = &kv[..pos]; - if kv.len() <= pos + 1 { - add_err(); - return (key, None) - } - (key, Some(&kv[pos+1..])) - } - } -} - -pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> { - match fs::File::open(file_path) { - Ok(f) => Some(f), - Err(io_err) => { - err.issues.push(CLIError::Input(InputError::IOError((file_path.to_string(), io_err)))); - None - } - } -} - -pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> { - match mime.parse() { - Ok(m) => Some(m), - Err(_) => { - err.issues.push(CLIError::Input(InputError::Mime(mime.to_string()))); - None - } - } -} - -// May panic if we can't open the file - this is anticipated, we can't currently communicate this -// kind of error: TODO: fix this architecture :) -pub fn writer_from_opts(flag: bool, arg: &str) -> Box<Write> { - if !flag || arg == "-" { - Box::new(stdout()) - } else { - Box::new(fs::OpenOptions::new().create(true).write(true).open(arg).unwrap()) - } -} - - -pub fn arg_from_str<T>(arg: &str, err: &mut InvalidOptionsError, - arg_name: &'static str, - arg_type: &'static str) -> T - where T: FromStr + Default, - <T as FromStr>::Err: fmt::Display { - match FromStr::from_str(arg) { - Err(perr) => { - err.issues.push( - CLIError::ParseError((arg_name, arg_type, arg.to_string(), format!("{}", perr))) - ); - Default::default() - }, - Ok(v) => v, - } -} - -pub struct JsonTokenStorage { - pub program_name: &'static str, - pub db_dir: String, -} - -impl JsonTokenStorage { - fn path(&self, scope_hash: u64) -> PathBuf { - Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash)) - } -} - -impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } - - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) - } - } - } - None - } -} - - -#[derive(Debug)] -pub enum ApplicationSecretError { - DecoderError((String, json::DecoderError)), - FormatError(String), -} - -impl fmt::Display for ApplicationSecretError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ApplicationSecretError::DecoderError((ref path, ref err)) - => writeln!(f, "Could not decode file at '{}' with error: {}", - path, err), - ApplicationSecretError::FormatError(ref path) - => writeln!(f, "'installed' field is unset in secret file at '{}'", - path), - } - } -} - -#[derive(Debug)] -pub enum ConfigurationError { - DirectoryCreationFailed((String, io::Error)), - DirectoryUnset, - HomeExpansionFailed(String), - Secret(ApplicationSecretError), - IOError((String, io::Error)), -} - -impl fmt::Display for ConfigurationError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) - => writeln!(f, "Directory '{}' could not be created with error: {}", dir, err), - ConfigurationError::DirectoryUnset - => writeln!(f, "--config-dir was unset or empty"), - ConfigurationError::HomeExpansionFailed(ref dir) - => writeln!(f, "Couldn't find HOME directory of current user, failed to expand '{}'", dir), - ConfigurationError::Secret(ref err) - => writeln!(f, "Secret -> {}", err), - ConfigurationError::IOError((ref path, ref err)) - => writeln!(f, "IO operation failed on path '{}' with error: {}", path, err), - } - } -} - -#[derive(Debug)] -pub enum InputError { - IOError((String, io::Error)), - Mime(String), -} - -impl fmt::Display for InputError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - InputError::IOError((ref file_path, ref io_err)) - => writeln!(f, "Failed to open '{}' for reading with error: {}", file_path, io_err), - InputError::Mime(ref mime) - => writeln!(f, "'{}' is not a known mime-type", mime), - } - } -} - -#[derive(Debug)] -pub enum FieldError { - PopOnEmpty(String), - TrailingFieldSep(String), - Unknown(String), - Empty, -} - - -impl fmt::Display for FieldError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - FieldError::PopOnEmpty(ref field) - => writeln!(f, "'{}': Cannot move up on empty field cursor", field), - FieldError::TrailingFieldSep(ref field) - => writeln!(f, "'{}': Single field separator may not be last character", field), - FieldError::Unknown(ref field) - => writeln!(f, "Field '{}' does not exist", field), - FieldError::Empty - => writeln!(f, "Field names must not be empty"), - } - } -} - - -#[derive(Debug)] -pub enum CLIError { - Configuration(ConfigurationError), - ParseError((&'static str, &'static str, String, String)), - UnknownParameter(String), - InvalidKeyValueSyntax(String), - Input(InputError), - Field(FieldError), -} - -impl fmt::Display for CLIError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err), - CLIError::Input(ref err) => write!(f, "Input -> {}", err), - CLIError::Field(ref err) => write!(f, "Field -> {}", err), - CLIError::ParseError((arg_name, type_name, ref value, ref err_desc)) - => writeln!(f, "Failed to parse argument '{}' with value '{}' as {} with error: {}", - arg_name, value, type_name, err_desc), - CLIError::UnknownParameter(ref param_name) - => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - - } - } -} - -#[derive(Debug)] -pub struct InvalidOptionsError { - pub issues: Vec<CLIError>, - pub exit_code: i32, -} - -impl fmt::Display for InvalidOptionsError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - for issue in &self.issues { - try!(issue.fmt(f)); - } - Ok(()) - } -} - -impl InvalidOptionsError { - pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError { - InvalidOptionsError { - issues: vec![err], - exit_code: exit_code, - } - } - - pub fn new() -> InvalidOptionsError { - InvalidOptionsError { - issues: Vec::new(), - exit_code: 1, - } - } -} - -pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { - let trdir = dir.trim(); - if trdir.len() == 0 { - return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset)) - } - - let expanded_config_dir = - if trdir.as_bytes()[0] == b'~' { - match env::var("HOME").ok().or(env::var("UserProfile").ok()) { - None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))), - Some(mut user) => { - user.push_str(&trdir[1..]); - user - } - } - } else { - trdir.to_string() - }; - - if let Err(err) = fs::create_dir(&expanded_config_dir) { - if err.kind() != io::ErrorKind::AlreadyExists { - return Err(CLIError::Configuration( - ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err)))) - } - } - - Ok(expanded_config_dir) -} - -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { - let secret_path = Path::new(dir).join(secret_basename); - let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); - let secret_io_error = |io_err: io::Error| { - Err(CLIError::Configuration(ConfigurationError::IOError( - (secret_str(), io_err) - ))) - }; - - for _ in 0..2 { - match fs::File::open(&secret_path) { - Err(mut err) => { - if err.kind() == io::ErrorKind::NotFound { - // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); - err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { - Err(cfe) => cfe, - Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { - Err(io_err) => io_err, - Ok(_) => continue, - } - } - }; - // fall through to IO error handling - } - return secret_io_error(err) - }, - Ok(mut f) => { - let mut json_encoded_secret = String::new(); - if let Err(io_err) = f.read_to_string(&mut json_encoded_secret) { - return secret_io_error(io_err) - } - match json::decode::<ConsoleApplicationSecret>(&json_encoded_secret) { - Err(json_decode_error) => return Err(CLIError::Configuration( - ConfigurationError::Secret(ApplicationSecretError::DecoderError( - (secret_str(), json_decode_error) - )))), - Ok(console_secret) => match console_secret.installed { - Some(secret) => return Ok(secret), - None => return Err( - CLIError::Configuration( - ConfigurationError::Secret( - ApplicationSecretError::FormatError(secret_str()) - ))) - }, - } - } - } - } - unreachable!(); -} \ No newline at end of file diff --git a/gen/webfonts1-cli/src/main.rs b/gen/webfonts1-cli/src/main.rs deleted file mode 100644 index c7f0adde68..0000000000 --- a/gen/webfonts1-cli/src/main.rs +++ /dev/null @@ -1,172 +0,0 @@ -// DO NOT EDIT ! -// This file was generated automatically from 'src/mako/cli/main.rs.mako' -// DO NOT EDIT ! -#![feature(plugin, exit_status)] -#![plugin(docopt_macros)] -#![allow(unused_variables, unused_imports, dead_code, unused_mut)] - -extern crate docopt; -extern crate yup_oauth2 as oauth2; -extern crate rustc_serialize; -extern crate serde; -extern crate hyper; -extern crate mime; -extern crate google_webfonts1 as api; - -use std::env; -use std::io::{self, Write}; - -docopt!(Options derive Debug, " -Usage: - 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> - -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] -"); - -mod cmn; -use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg, - input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError}; - -use std::default::Default; -use std::str::FromStr; - -use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; -use rustc_serialize::json; - -struct Engine { - opt: Options, - hub: api::Webfonts<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>, -} - - -impl Engine { - fn _webfonts_list(&self, dry_run: bool, err: &mut InvalidOptionsError) - -> Option<api::Error> { - let mut call = self.hub.webfonts().list(); - for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); - match key { - "sort" => { - call = call.sort(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); - 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)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); - None - } - } - } - } - - fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) { - let mut err = InvalidOptionsError::new(); - let mut call_result: Option<api::Error>; - let mut err_opt: Option<InvalidOptionsError> = None; - - if self.opt.cmd_webfonts { - if self.opt.cmd_list { - call_result = self._webfonts_list(dry_run, &mut err); - } else { - unreachable!(); - } - } else { - unreachable!(); - } - - if dry_run { - if err.issues.len() > 0 { - err_opt = Some(err); - } - } - (call_result, err_opt) - } - - // Please note that this call will fail if any part of the opt can't be handled - fn new(opt: Options) -> Result<Engine, InvalidOptionsError> { - let (config_dir, secret) = { - let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) { - Err(e) => return Err(InvalidOptionsError::single(e, 3)), - Ok(p) => p, - }; - - match cmn::application_secret_from_directory(&config_dir, "webfonts1-secret.json") { - Ok(secret) => (config_dir, secret), - Err(e) => return Err(InvalidOptionsError::single(e, 4)) - } - }; - - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "webfonts1", - db_dir: config_dir.clone(), - }, None); - let engine = Engine { - opt: opt, - hub: api::Webfonts::new(hyper::Client::new(), auth), - }; - - match engine._doit(true) { - (_, Some(err)) => Err(err), - _ => Ok(engine), - } - } - - // Execute the call with all the bells and whistles, informing the caller only if there was an error. - // The absense of one indicates success. - fn doit(&self) -> Option<api::Error> { - self._doit(false).0 - } -} - -fn main() { - let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); - match Engine::new(opts) { - Err(err) => { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(err.exit_code); - }, - Ok(engine) => { - if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); - env::set_exit_status(1); - } - } - } -} \ No newline at end of file diff --git a/gen/webfonts1/Cargo.toml b/gen/webfonts1/Cargo.toml index 4fa415a81e..0d24829441 100644 --- a/gen/webfonts1/Cargo.toml +++ b/gen/webfonts1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-webfonts1" version = "0.1.5+20140210" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/fonts/docs/developer_api" diff --git a/gen/webfonts1/src/cmn.rs b/gen/webfonts1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/webfonts1/src/cmn.rs +++ b/gen/webfonts1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/webfonts1/src/lib.rs b/gen/webfonts1/src/lib.rs index a7f8168bab..ec54241041 100644 --- a/gen/webfonts1/src/lib.rs +++ b/gen/webfonts1/src/lib.rs @@ -345,9 +345,9 @@ impl Resource for Webfont {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WebfontList { /// The list of fonts currently served by the Google Fonts API. - pub items: Vec<Webfont>, + pub items: Option<Vec<Webfont>>, /// This kind represents a list of webfont objects in the webfonts service. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for WebfontList {} diff --git a/gen/webmasters3-cli/Cargo.toml b/gen/webmasters3-cli/Cargo.toml index d5cbce6f79..e22feac9be 100644 --- a/gen/webmasters3-cli/Cargo.toml +++ b/gen/webmasters3-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-webmasters3-cli" version = "0.0.1+20140908" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/webmaster-tools/v3/welcome" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/webmasters3-cli/src/cmn.rs b/gen/webmasters3-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/webmasters3-cli/src/cmn.rs +++ b/gen/webmasters3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/webmasters3-cli/src/main.rs b/gen/webmasters3-cli/src/main.rs index dff0e1a497..8d99c6e982 100644 --- a/gen/webmasters3-cli/src/main.rs +++ b/gen/webmasters3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -43,6 +44,12 @@ Configuration: 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. "); mod cmn; @@ -66,7 +73,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sitemaps().delete(&self.opt.arg_site_url, &self.opt.arg_feedpath); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -97,7 +104,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -108,7 +114,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sitemaps().get(&self.opt.arg_site_url, &self.opt.arg_feedpath); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -140,8 +146,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -152,7 +157,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sitemaps().list(&self.opt.arg_site_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "sitemap-index" => { call = call.sitemap_index(value.unwrap_or("")); @@ -187,8 +192,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -199,7 +203,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sitemaps().submit(&self.opt.arg_site_url, &self.opt.arg_feedpath); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -230,7 +234,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -241,7 +244,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().add(&self.opt.arg_site_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -272,7 +275,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -283,7 +285,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().delete(&self.opt.arg_site_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -314,7 +316,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -325,7 +326,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().get(&self.opt.arg_site_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -357,8 +358,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -369,7 +369,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.sites().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -401,8 +401,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -413,7 +412,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.urlcrawlerrorscounts().query(&self.opt.arg_site_url); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "platform" => { call = call.platform(value.unwrap_or("")); @@ -454,8 +453,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -466,7 +464,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.urlcrawlerrorssamples().get(&self.opt.arg_site_url, &self.opt.arg_url, &self.opt.arg_category, &self.opt.arg_platform); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -498,8 +496,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -510,7 +507,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.urlcrawlerrorssamples().list(&self.opt.arg_site_url, &self.opt.arg_category, &self.opt.arg_platform); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -542,8 +539,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -554,7 +550,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.urlcrawlerrorssamples().mark_as_fixed(&self.opt.arg_site_url, &self.opt.arg_url, &self.opt.arg_category, &self.opt.arg_platform); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -585,7 +581,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -609,7 +604,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_sites { + } + else if self.opt.cmd_sites { if self.opt.cmd_add { call_result = self._sites_add(dry_run, &mut err); } else if self.opt.cmd_delete { @@ -621,13 +617,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_urlcrawlerrorscounts { + } + else if self.opt.cmd_urlcrawlerrorscounts { if self.opt.cmd_query { call_result = self._urlcrawlerrorscounts_query(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_urlcrawlerrorssamples { + } + else if self.opt.cmd_urlcrawlerrorssamples { if self.opt.cmd_get { call_result = self._urlcrawlerrorssamples_get(dry_run, &mut err); } else if self.opt.cmd_list { @@ -657,21 +655,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "webmasters3-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "webmasters3-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "webmasters3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "webmasters3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::Webmasters::new(hyper::Client::new(), auth), + hub: api::Webmasters::new(client, auth), }; match engine._doit(true) { @@ -691,12 +705,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/webmasters3/Cargo.toml b/gen/webmasters3/Cargo.toml index 6fd9a22424..f5fdc50a4d 100644 --- a/gen/webmasters3/Cargo.toml +++ b/gen/webmasters3/Cargo.toml @@ -5,7 +5,7 @@ name = "google-webmasters3" version = "0.1.5+20140908" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "https://developers.google.com/webmaster-tools/v3/welcome" diff --git a/gen/webmasters3/src/cmn.rs b/gen/webmasters3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/webmasters3/src/cmn.rs +++ b/gen/webmasters3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/webmasters3/src/lib.rs b/gen/webmasters3/src/lib.rs index 9c0206b3f3..1c53a9060b 100644 --- a/gen/webmasters3/src/lib.rs +++ b/gen/webmasters3/src/lib.rs @@ -351,7 +351,7 @@ impl<'a, C, A> Webmasters<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SitemapsListResponse { /// Information about a sitemap entry. - pub sitemap: Vec<WmxSitemap>, + pub sitemap: Option<Vec<WmxSitemap>>, } impl ResponseResult for SitemapsListResponse {} @@ -364,12 +364,12 @@ impl ResponseResult for SitemapsListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WmxSitemapContent { /// The number of URLs from the sitemap that were indexed (of the content type). - pub indexed: String, + pub indexed: Option<String>, /// The specific type of content in this sitemap (for example "web", "images"). #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The number of URLs in the sitemap (of the content type). - pub submitted: String, + pub submitted: Option<String>, } impl Part for WmxSitemapContent {} @@ -382,11 +382,11 @@ impl Part for WmxSitemapContent {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlCrawlErrorCountsPerType { /// The crawl error type. - pub category: String, + pub category: Option<String>, /// Corresponding to the user agent that made the request. - pub platform: String, + pub platform: Option<String>, /// The error count entries time series. - pub entries: Vec<UrlCrawlErrorCount>, + pub entries: Option<Vec<UrlCrawlErrorCount>>, } impl Part for UrlCrawlErrorCountsPerType {} @@ -405,10 +405,10 @@ impl Part for UrlCrawlErrorCountsPerType {} pub struct WmxSite { /// The user's permission level for the site. #[serde(rename="permissionLevel")] - pub permission_level: String, + pub permission_level: Option<String>, /// The URL of the site. #[serde(rename="siteUrl")] - pub site_url: String, + pub site_url: Option<String>, } impl ResponseResult for WmxSite {} @@ -427,7 +427,7 @@ impl ResponseResult for WmxSite {} pub struct UrlCrawlErrorsCountsQueryResponse { /// The time series of the number of URL crawl errors for per error category and platform. #[serde(rename="countPerTypes")] - pub count_per_types: Vec<UrlCrawlErrorCountsPerType>, + pub count_per_types: Option<Vec<UrlCrawlErrorCountsPerType>>, } impl ResponseResult for UrlCrawlErrorsCountsQueryResponse {} @@ -440,9 +440,9 @@ impl ResponseResult for UrlCrawlErrorsCountsQueryResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UrlCrawlErrorCount { /// The error count at the given timestamp. - pub count: String, + pub count: Option<String>, /// The time (well, date) when errors were detected, in RFC 3339 format. - pub timestamp: String, + pub timestamp: Option<String>, } impl Part for UrlCrawlErrorCount {} @@ -460,28 +460,28 @@ impl Part for UrlCrawlErrorCount {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct WmxSitemap { /// Number of errors in the sitemap - issues with the sitemap itself, that needs to be fixed before it can be processed correctly. - pub errors: String, + pub errors: Option<String>, /// Number of warnings for the sitemap - issues with URLs in the sitemaps. - pub warnings: String, + pub warnings: Option<String>, /// If true, the sitemap has not been processed. #[serde(rename="isPending")] - pub is_pending: bool, + pub is_pending: Option<bool>, /// Date & time in which this sitemap was submitted. Date format is in RFC 3339 format (yyyy-mm-dd). #[serde(rename="lastSubmitted")] - pub last_submitted: String, + pub last_submitted: Option<String>, /// If true, the sitemap is a collection of sitemaps. #[serde(rename="isSitemapsIndex")] - pub is_sitemaps_index: bool, + pub is_sitemaps_index: Option<bool>, /// Date & time in which this sitemap was last downloaded. Date format is in RFC 3339 format (yyyy-mm-dd). #[serde(rename="lastDownloaded")] - pub last_downloaded: String, + pub last_downloaded: Option<String>, /// The url of the sitemap. - pub path: String, + pub path: Option<String>, /// The type of the sitemap (for example "sitemap"). #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The various content types in the sitemap. - pub contents: Vec<WmxSitemapContent>, + pub contents: Option<Vec<WmxSitemapContent>>, } impl ResponseResult for WmxSitemap {} @@ -500,7 +500,7 @@ impl ResponseResult for WmxSitemap {} pub struct SitesListResponse { /// Access level information for a Webmaster Tools site. #[serde(rename="siteEntry")] - pub site_entry: Vec<WmxSite>, + pub site_entry: Option<Vec<WmxSite>>, } impl ResponseResult for SitesListResponse {} @@ -519,17 +519,17 @@ impl ResponseResult for SitesListResponse {} pub struct UrlCrawlErrorsSample { /// Additional details about the URL, set only when calling get(). #[serde(rename="urlDetails")] - pub url_details: UrlSampleDetails, + pub url_details: Option<UrlSampleDetails>, /// The URL of an error, relative to the site. #[serde(rename="pageUrl")] - pub page_url: String, + pub page_url: Option<String>, /// The time when the URL was last crawled, in RFC 3339 format. - pub last_crawled: String, + pub last_crawled: Option<String>, /// The HTTP response code, if any. #[serde(rename="responseCode")] - pub response_code: i32, + pub response_code: Option<i32>, /// The time the error was first detected, in RFC 3339 format. - pub first_detected: String, + pub first_detected: Option<String>, } impl Resource for UrlCrawlErrorsSample {} @@ -544,10 +544,10 @@ impl ResponseResult for UrlCrawlErrorsSample {} pub struct UrlSampleDetails { /// List of sitemaps pointing at this URL. #[serde(rename="containingSitemaps")] - pub containing_sitemaps: Vec<String>, + pub containing_sitemaps: Option<Vec<String>>, /// A sample set of URLs linking to this URL. #[serde(rename="linkedFromUrls")] - pub linked_from_urls: Vec<String>, + pub linked_from_urls: Option<Vec<String>>, } impl Part for UrlSampleDetails {} @@ -566,7 +566,7 @@ impl Part for UrlSampleDetails {} pub struct UrlCrawlErrorsSamplesListResponse { /// Information about the sample URL and its crawl error. #[serde(rename="urlCrawlErrorSample")] - pub url_crawl_error_sample: Vec<UrlCrawlErrorsSample>, + pub url_crawl_error_sample: Option<Vec<UrlCrawlErrorsSample>>, } impl ResponseResult for UrlCrawlErrorsSamplesListResponse {} @@ -1081,16 +1081,20 @@ impl<'a, C, A> SitemapDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -1312,16 +1316,20 @@ impl<'a, C, A> SitemapSubmitCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -1544,16 +1552,20 @@ impl<'a, C, A> SitemapGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1789,16 +1801,20 @@ impl<'a, C, A> SitemapListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2026,16 +2042,20 @@ impl<'a, C, A> SiteGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2255,16 +2275,20 @@ impl<'a, C, A> SiteAddCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) @@ -2449,16 +2473,20 @@ impl<'a, C, A> SiteListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oaut loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2668,16 +2696,20 @@ impl<'a, C, A> SiteDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2903,16 +2935,20 @@ impl<'a, C, A> UrlcrawlerrorscountQueryCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3160,16 +3196,20 @@ impl<'a, C, A> UrlcrawlerrorssampleGetCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3424,16 +3464,20 @@ impl<'a, C, A> UrlcrawlerrorssampleListCall<'a, C, A> where C: BorrowMut<hyper:: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -3679,16 +3723,20 @@ impl<'a, C, A> UrlcrawlerrorssampleMarkAsFixedCall<'a, C, A> where C: BorrowMut< loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) diff --git a/gen/youtube3-cli/Cargo.toml b/gen/youtube3-cli/Cargo.toml index 0d92d02075..39f8a690c8 100644 --- a/gen/youtube3-cli/Cargo.toml +++ b/gen/youtube3-cli/Cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-youtube3-cli" -version = "0.0.1+20150327" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.0.1+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" homepage = "https://developers.google.com/youtube/v3" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/youtube3-cli/mkdocs.yml b/gen/youtube3-cli/mkdocs.yml index 6fcf44b4d2..44340c536a 100644 --- a/gen/youtube3-cli/mkdocs.yml +++ b/gen/youtube3-cli/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: YouTube v0.0.1+20150327 +site_name: YouTube v0.0.1+20150414 site_url: http://byron.github.io/google-apis-rs/google-youtube3-cli site_description: Write integrating applications with bcore @@ -23,6 +23,15 @@ pages: - ['channel-sections_update.md', 'Channel Sections', 'Update'] - ['channels_list.md', 'Channels', 'List'] - ['channels_update.md', 'Channels', 'Update'] +- ['comment-threads_insert.md', 'Comment Threads', 'Insert'] +- ['comment-threads_list.md', 'Comment Threads', 'List'] +- ['comment-threads_update.md', 'Comment Threads', 'Update'] +- ['comments_delete.md', 'Comments', 'Delete'] +- ['comments_insert.md', 'Comments', 'Insert'] +- ['comments_list.md', 'Comments', 'List'] +- ['comments_mark-as-spam.md', 'Comments', 'Mark As Spam'] +- ['comments_set-moderation-status.md', 'Comments', 'Set Moderation Status'] +- ['comments_update.md', 'Comments', 'Update'] - ['guide-categories_list.md', 'Guide Categories', 'List'] - ['i18n-languages_list.md', 'I18n Languages', 'List'] - ['i18n-regions_list.md', 'I18n Regions', 'List'] @@ -50,12 +59,14 @@ pages: - ['subscriptions_insert.md', 'Subscriptions', 'Insert'] - ['subscriptions_list.md', 'Subscriptions', 'List'] - ['thumbnails_set.md', 'Thumbnails', 'Set'] +- ['video-abuse-report-reasons_list.md', 'Video Abuse Report Reasons', 'List'] - ['video-categories_list.md', 'Video Categories', 'List'] - ['videos_delete.md', 'Videos', 'Delete'] - ['videos_get-rating.md', 'Videos', 'Get Rating'] - ['videos_insert.md', 'Videos', 'Insert'] - ['videos_list.md', 'Videos', 'List'] - ['videos_rate.md', 'Videos', 'Rate'] +- ['videos_report-abuse.md', 'Videos', 'Report Abuse'] - ['videos_update.md', 'Videos', 'Update'] - ['watermarks_set.md', 'Watermarks', 'Set'] - ['watermarks_unset.md', 'Watermarks', 'Unset'] diff --git a/gen/youtube3-cli/src/cmn.rs b/gen/youtube3-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/youtube3-cli/src/cmn.rs +++ b/gen/youtube3-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/youtube3-cli/src/main.rs b/gen/youtube3-cli/src/main.rs index ec0faf80a0..a79573a9b6 100644 --- a/gen/youtube3-cli/src/main.rs +++ b/gen/youtube3-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -32,6 +33,15 @@ Usage: 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>] @@ -59,12 +69,14 @@ Usage: 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>]... @@ -81,6 +93,12 @@ Configuration: 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. "); mod cmn; @@ -102,10 +120,10 @@ struct Engine { impl Engine { fn _activities_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Activity = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -125,344 +143,540 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_content_details_bulletin_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().bulletin.is_none() { + request.content_details.as_mut().unwrap().bulletin = Some(Default::default()); + } + } + + fn request_content_details_bulletin_resource_id_init(request: &mut api::Activity) { + request_content_details_bulletin_init(request); + if request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_channel_item_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().channel_item.is_none() { + request.content_details.as_mut().unwrap().channel_item = Some(Default::default()); + } + } + + fn request_content_details_channel_item_resource_id_init(request: &mut api::Activity) { + request_content_details_channel_item_init(request); + if request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_comment_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().comment.is_none() { + request.content_details.as_mut().unwrap().comment = Some(Default::default()); + } + } + + fn request_content_details_comment_resource_id_init(request: &mut api::Activity) { + request_content_details_comment_init(request); + if request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_favorite_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().favorite.is_none() { + request.content_details.as_mut().unwrap().favorite = Some(Default::default()); + } + } + + fn request_content_details_favorite_resource_id_init(request: &mut api::Activity) { + request_content_details_favorite_init(request); + if request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + fn request_content_details_init(request: &mut api::Activity) { if request.content_details.is_none() { request.content_details = Some(Default::default()); } } + fn request_content_details_like_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().like.is_none() { + request.content_details.as_mut().unwrap().like = Some(Default::default()); + } + } + + fn request_content_details_like_resource_id_init(request: &mut api::Activity) { + request_content_details_like_init(request); + if request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_playlist_item_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().playlist_item.is_none() { + request.content_details.as_mut().unwrap().playlist_item = Some(Default::default()); + } + } + + fn request_content_details_playlist_item_resource_id_init(request: &mut api::Activity) { + request_content_details_playlist_item_init(request); + if request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_promoted_item_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().promoted_item.is_none() { + request.content_details.as_mut().unwrap().promoted_item = Some(Default::default()); + } + } + + fn request_content_details_recommendation_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().recommendation.is_none() { + request.content_details.as_mut().unwrap().recommendation = Some(Default::default()); + } + } + + fn request_content_details_recommendation_resource_id_init(request: &mut api::Activity) { + request_content_details_recommendation_init(request); + if request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_recommendation_seed_resource_id_init(request: &mut api::Activity) { + request_content_details_recommendation_init(request); + if request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id.is_none() { + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id = Some(Default::default()); + } + } + + fn request_content_details_social_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().social.is_none() { + request.content_details.as_mut().unwrap().social = Some(Default::default()); + } + } + + fn request_content_details_social_resource_id_init(request: &mut api::Activity) { + request_content_details_social_init(request); + if request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_subscription_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().subscription.is_none() { + request.content_details.as_mut().unwrap().subscription = Some(Default::default()); + } + } + + fn request_content_details_subscription_resource_id_init(request: &mut api::Activity) { + request_content_details_subscription_init(request); + if request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id.is_none() { + request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_content_details_upload_init(request: &mut api::Activity) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().upload.is_none() { + request.content_details.as_mut().unwrap().upload = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::Activity) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_thumbnails_default_init(request: &mut api::Activity) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Activity) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Activity) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Activity) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Activity) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Activity) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "snippet.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.type" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "snippet.group-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().group_id = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().group_id = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "content-details.comment.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().comment.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_comment_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.comment.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().comment.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_comment_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.comment.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().comment.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_comment_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.comment.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().comment.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_comment_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().comment.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.playlist_id = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.playlist-item.playlist-item-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlist_item.playlist_item_id = value.unwrap_or("").to_string(); + request_content_details_playlist_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().playlist_item.as_mut().unwrap().playlist_item_id = Some(value.unwrap_or("").to_string()); }, "content-details.like.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().like.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_like_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.like.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().like.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_like_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.like.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().like.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_like_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.like.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().like.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_like_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().like.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.cta-type" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.cta_type = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().cta_type = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.ad-tag" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.ad_tag = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().ad_tag = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.destination-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.destination_url = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().destination_url = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.forecasting-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.forecasting_url.push(value.unwrap_or("").to_string()); + request_content_details_promoted_item_init(&mut request); + if request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().forecasting_url.is_none() { + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().forecasting_url = Some(Default::default()); + } + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().forecasting_url.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.promoted-item.impression-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.impression_url.push(value.unwrap_or("").to_string()); + request_content_details_promoted_item_init(&mut request); + if request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().impression_url.is_none() { + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().impression_url = Some(Default::default()); + } + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().impression_url.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.promoted-item.creative-view-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.creative_view_url = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().creative_view_url = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.video_id = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.description-text" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.description_text = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().description_text = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.custom-cta-button-text" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.custom_cta_button_text = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().custom_cta_button_text = Some(value.unwrap_or("").to_string()); }, "content-details.promoted-item.click-tracking-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().promoted_item.click_tracking_url = value.unwrap_or("").to_string(); + request_content_details_promoted_item_init(&mut request); + request.content_details.as_mut().unwrap().promoted_item.as_mut().unwrap().click_tracking_url = Some(value.unwrap_or("").to_string()); }, "content-details.social.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.social.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.social.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.social.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.social.image-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.image_url = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().image_url = Some(value.unwrap_or("").to_string()); }, "content-details.social.type" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.type_ = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "content-details.social.reference-url" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.reference_url = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().reference_url = Some(value.unwrap_or("").to_string()); }, "content-details.social.author" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().social.author = value.unwrap_or("").to_string(); + request_content_details_social_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().social.as_mut().unwrap().author = Some(value.unwrap_or("").to_string()); }, "content-details.favorite.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().favorite.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_favorite_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.favorite.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().favorite.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_favorite_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.favorite.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().favorite.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_favorite_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.favorite.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().favorite.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_favorite_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().favorite.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.upload.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().upload.video_id = value.unwrap_or("").to_string(); + request_content_details_upload_init(&mut request); + request.content_details.as_mut().unwrap().upload.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_recommendation_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.reason" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.reason = value.unwrap_or("").to_string(); + request_content_details_recommendation_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().reason = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.seed-resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.seed_resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_recommendation_seed_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.seed-resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.seed_resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_seed_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.seed-resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.seed_resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_seed_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.recommendation.seed-resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().recommendation.seed_resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_recommendation_seed_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().recommendation.as_mut().unwrap().seed_resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.subscription.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().subscription.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_subscription_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.subscription.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().subscription.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_subscription_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.subscription.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().subscription.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_subscription_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.subscription.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().subscription.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_subscription_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().subscription.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.bulletin.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bulletin.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_bulletin_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.bulletin.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bulletin.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_bulletin_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.bulletin.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bulletin.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_bulletin_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.bulletin.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bulletin.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_bulletin_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().bulletin.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "content-details.channel-item.resource-id.kind" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channel_item.resource_id.kind = value.unwrap_or("").to_string(); + request_content_details_channel_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "content-details.channel-item.resource-id.channel-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channel_item.resource_id.channel_id = value.unwrap_or("").to_string(); + request_content_details_channel_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "content-details.channel-item.resource-id.playlist-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channel_item.resource_id.playlist_id = value.unwrap_or("").to_string(); + request_content_details_channel_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "content-details.channel-item.resource-id.video-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channel_item.resource_id.video_id = value.unwrap_or("").to_string(); + request_content_details_channel_item_resource_id_init(&mut request); + request.content_details.as_mut().unwrap().channel_item.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "kind" => { request_content_details_init(&mut request); @@ -493,8 +707,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -505,7 +718,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.activities().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "region-code" => { call = call.region_code(value.unwrap_or("")); @@ -561,8 +774,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -573,7 +785,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.captions().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "on-behalf-of" => { call = call.on_behalf_of(value.unwrap_or("")); @@ -610,7 +822,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -622,7 +833,7 @@ impl Engine { let mut download_mode = false; let mut call = self.hub.captions().download(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tlang" => { call = call.tlang(value.unwrap_or("")); @@ -669,7 +880,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); if !download_mode { } else { io::copy(&mut response, &mut ostream).unwrap(); @@ -682,10 +892,10 @@ impl Engine { fn _captions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Caption = Default::default(); + 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); + 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")); @@ -714,9 +924,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -729,55 +940,55 @@ impl Engine { match &field_name.to_string()[..] { "snippet.status" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "snippet.audio-track-type" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().audio_track_type = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().audio_track_type = Some(value.unwrap_or("").to_string()); }, "snippet.language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().language = Some(value.unwrap_or("").to_string()); }, "snippet.name" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "snippet.video-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().video_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.is-draft" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_draft = arg_from_str(value.unwrap_or("false"), err, "snippet.is-draft", "boolean"); + request.snippet.as_mut().unwrap().is_draft = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-draft", "boolean")); }, "snippet.is-auto-synced" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_auto_synced = arg_from_str(value.unwrap_or("false"), err, "snippet.is-auto-synced", "boolean"); + request.snippet.as_mut().unwrap().is_auto_synced = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-auto-synced", "boolean")); }, "snippet.track-kind" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().track_kind = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().track_kind = Some(value.unwrap_or("").to_string()); }, "snippet.last-updated" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().last_updated = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().last_updated = Some(value.unwrap_or("").to_string()); }, "snippet.is-cc" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_cc = arg_from_str(value.unwrap_or("false"), err, "snippet.is-cc", "boolean"); + request.snippet.as_mut().unwrap().is_cc = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-cc", "boolean")); }, "snippet.is-easy-reader" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_easy_reader = arg_from_str(value.unwrap_or("false"), err, "snippet.is-easy-reader", "boolean"); + request.snippet.as_mut().unwrap().is_easy_reader = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-easy-reader", "boolean")); }, "snippet.is-large" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_large = arg_from_str(value.unwrap_or("false"), err, "snippet.is-large", "boolean"); + request.snippet.as_mut().unwrap().is_large = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-large", "boolean")); }, "snippet.failure-reason" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().failure_reason = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().failure_reason = Some(value.unwrap_or("").to_string()); }, "kind" => { request_snippet_init(&mut request); @@ -818,8 +1029,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -830,7 +1040,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.captions().list(&self.opt.arg_part, &self.opt.arg_video_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "on-behalf-of" => { call = call.on_behalf_of(value.unwrap_or("")); @@ -871,8 +1081,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -881,10 +1090,10 @@ impl Engine { fn _captions_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Caption = Default::default(); + 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); + 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")); @@ -913,9 +1122,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -928,55 +1138,55 @@ impl Engine { match &field_name.to_string()[..] { "snippet.status" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().status = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().status = Some(value.unwrap_or("").to_string()); }, "snippet.audio-track-type" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().audio_track_type = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().audio_track_type = Some(value.unwrap_or("").to_string()); }, "snippet.language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().language = Some(value.unwrap_or("").to_string()); }, "snippet.name" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().name = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().name = Some(value.unwrap_or("").to_string()); }, "snippet.video-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().video_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.is-draft" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_draft = arg_from_str(value.unwrap_or("false"), err, "snippet.is-draft", "boolean"); + request.snippet.as_mut().unwrap().is_draft = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-draft", "boolean")); }, "snippet.is-auto-synced" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_auto_synced = arg_from_str(value.unwrap_or("false"), err, "snippet.is-auto-synced", "boolean"); + request.snippet.as_mut().unwrap().is_auto_synced = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-auto-synced", "boolean")); }, "snippet.track-kind" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().track_kind = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().track_kind = Some(value.unwrap_or("").to_string()); }, "snippet.last-updated" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().last_updated = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().last_updated = Some(value.unwrap_or("").to_string()); }, "snippet.is-cc" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_cc = arg_from_str(value.unwrap_or("false"), err, "snippet.is-cc", "boolean"); + request.snippet.as_mut().unwrap().is_cc = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-cc", "boolean")); }, "snippet.is-easy-reader" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_easy_reader = arg_from_str(value.unwrap_or("false"), err, "snippet.is-easy-reader", "boolean"); + request.snippet.as_mut().unwrap().is_easy_reader = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-easy-reader", "boolean")); }, "snippet.is-large" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().is_large = arg_from_str(value.unwrap_or("false"), err, "snippet.is-large", "boolean"); + request.snippet.as_mut().unwrap().is_large = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.is-large", "boolean")); }, "snippet.failure-reason" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().failure_reason = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().failure_reason = Some(value.unwrap_or("").to_string()); }, "kind" => { request_snippet_init(&mut request); @@ -1017,8 +1227,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1027,10 +1236,10 @@ impl Engine { fn _channel_banners_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ChannelBannerResource = Default::default(); + let mut request = api::ChannelBannerResource::default(); 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); + 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("")); @@ -1053,9 +1262,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1096,8 +1306,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1108,7 +1317,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.channel_sections().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -1142,7 +1351,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -1151,10 +1359,10 @@ impl Engine { fn _channel_sections_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ChannelSection = Default::default(); + 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); + 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("")); @@ -1180,9 +1388,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1198,53 +1407,92 @@ impl Engine { } } + fn request_snippet_localized_init(request: &mut api::ChannelSection) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_targeting_init(request: &mut api::ChannelSection) { + if request.targeting.is_none() { + request.targeting = Some(Default::default()); + } + } + match &field_name.to_string()[..] { - "snippet.style" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().style = value.unwrap_or("").to_string(); + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); }, - "snippet.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + "targeting.languages" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().languages.is_none() { + request.targeting.as_mut().unwrap().languages = Some(Default::default()); + } + request.targeting.as_mut().unwrap().languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + "targeting.regions" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().regions.is_none() { + request.targeting.as_mut().unwrap().regions = Some(Default::default()); + } + request.targeting.as_mut().unwrap().regions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "snippet.default-language" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); - }, - "snippet.position" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().position = arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer"); - }, - "snippet.type" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + "targeting.countries" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().countries.is_none() { + request.targeting.as_mut().unwrap().countries = Some(Default::default()); + } + request.targeting.as_mut().unwrap().countries.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.channels" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channels.push(value.unwrap_or("").to_string()); + if request.content_details.as_mut().unwrap().channels.is_none() { + request.content_details.as_mut().unwrap().channels = Some(Default::default()); + } + request.content_details.as_mut().unwrap().channels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.playlists" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlists.push(value.unwrap_or("").to_string()); + if request.content_details.as_mut().unwrap().playlists.is_none() { + request.content_details.as_mut().unwrap().playlists = Some(Default::default()); + } + request.content_details.as_mut().unwrap().playlists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "kind" => { - request_content_details_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); + "snippet.style" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().style = Some(value.unwrap_or("").to_string()); + }, + "snippet.title" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.default-language" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); + }, + "snippet.position" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().position = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer")); + }, + "snippet.type" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + "snippet.localized.title" => { + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "etag" => { - request_content_details_init(&mut request); + request_snippet_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "id" => { - request_content_details_init(&mut request); + request_snippet_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, _ => { @@ -1264,8 +1512,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1276,7 +1523,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.channel_sections().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -1323,8 +1570,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1333,10 +1579,10 @@ impl Engine { fn _channel_sections_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::ChannelSection = Default::default(); + 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); + 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("")); @@ -1359,9 +1605,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1377,53 +1624,92 @@ impl Engine { } } + fn request_snippet_localized_init(request: &mut api::ChannelSection) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_targeting_init(request: &mut api::ChannelSection) { + if request.targeting.is_none() { + request.targeting = Some(Default::default()); + } + } + match &field_name.to_string()[..] { - "snippet.style" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().style = value.unwrap_or("").to_string(); + "kind" => { + request.kind = Some(value.unwrap_or("").to_string()); }, - "snippet.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + "targeting.languages" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().languages.is_none() { + request.targeting.as_mut().unwrap().languages = Some(Default::default()); + } + request.targeting.as_mut().unwrap().languages.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + "targeting.regions" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().regions.is_none() { + request.targeting.as_mut().unwrap().regions = Some(Default::default()); + } + request.targeting.as_mut().unwrap().regions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "snippet.default-language" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); - }, - "snippet.position" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().position = arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer"); - }, - "snippet.type" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); - }, - "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + "targeting.countries" => { + request_targeting_init(&mut request); + if request.targeting.as_mut().unwrap().countries.is_none() { + request.targeting.as_mut().unwrap().countries = Some(Default::default()); + } + request.targeting.as_mut().unwrap().countries.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.channels" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().channels.push(value.unwrap_or("").to_string()); + if request.content_details.as_mut().unwrap().channels.is_none() { + request.content_details.as_mut().unwrap().channels = Some(Default::default()); + } + request.content_details.as_mut().unwrap().channels.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.playlists" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().playlists.push(value.unwrap_or("").to_string()); + if request.content_details.as_mut().unwrap().playlists.is_none() { + request.content_details.as_mut().unwrap().playlists = Some(Default::default()); + } + request.content_details.as_mut().unwrap().playlists.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, - "kind" => { - request_content_details_init(&mut request); - request.kind = Some(value.unwrap_or("").to_string()); + "snippet.style" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().style = Some(value.unwrap_or("").to_string()); + }, + "snippet.title" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.default-language" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); + }, + "snippet.position" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().position = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer")); + }, + "snippet.type" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); + }, + "snippet.localized.title" => { + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "etag" => { - request_content_details_init(&mut request); + request_snippet_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "id" => { - request_content_details_init(&mut request); + request_snippet_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, _ => { @@ -1443,8 +1729,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1455,7 +1740,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.channels().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -1517,8 +1802,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -1527,10 +1811,10 @@ impl Engine { fn _channels_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Channel = Default::default(); + 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); + 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("")); @@ -1553,9 +1837,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -1565,36 +1850,197 @@ impl Engine { } } + fn request_branding_settings_channel_init(request: &mut api::Channel) { + request_branding_settings_init(request); + if request.branding_settings.as_mut().unwrap().channel.is_none() { + request.branding_settings.as_mut().unwrap().channel = Some(Default::default()); + } + } + + fn request_branding_settings_image_background_image_url_default_language_init(request: &mut api::Channel) { + request_branding_settings_image_background_image_url_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url.as_mut().unwrap().default_language.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url.as_mut().unwrap().default_language = Some(Default::default()); + } + } + + fn request_branding_settings_image_background_image_url_init(request: &mut api::Channel) { + request_branding_settings_image_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url = Some(Default::default()); + } + } + + fn request_branding_settings_image_init(request: &mut api::Channel) { + request_branding_settings_init(request); + if request.branding_settings.as_mut().unwrap().image.is_none() { + request.branding_settings.as_mut().unwrap().image = Some(Default::default()); + } + } + + fn request_branding_settings_image_large_branded_banner_image_imap_script_default_language_init(request: &mut api::Channel) { + request_branding_settings_image_large_branded_banner_image_imap_script_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script.as_mut().unwrap().default_language.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script.as_mut().unwrap().default_language = Some(Default::default()); + } + } + + fn request_branding_settings_image_large_branded_banner_image_imap_script_init(request: &mut api::Channel) { + request_branding_settings_image_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script = Some(Default::default()); + } + } + + fn request_branding_settings_image_large_branded_banner_image_url_default_language_init(request: &mut api::Channel) { + request_branding_settings_image_large_branded_banner_image_url_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url.as_mut().unwrap().default_language.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url.as_mut().unwrap().default_language = Some(Default::default()); + } + } + + fn request_branding_settings_image_large_branded_banner_image_url_init(request: &mut api::Channel) { + request_branding_settings_image_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url = Some(Default::default()); + } + } + + fn request_branding_settings_image_small_branded_banner_image_imap_script_default_language_init(request: &mut api::Channel) { + request_branding_settings_image_small_branded_banner_image_imap_script_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script.as_mut().unwrap().default_language.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script.as_mut().unwrap().default_language = Some(Default::default()); + } + } + + fn request_branding_settings_image_small_branded_banner_image_imap_script_init(request: &mut api::Channel) { + request_branding_settings_image_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script = Some(Default::default()); + } + } + + fn request_branding_settings_image_small_branded_banner_image_url_default_language_init(request: &mut api::Channel) { + request_branding_settings_image_small_branded_banner_image_url_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url.as_mut().unwrap().default_language.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url.as_mut().unwrap().default_language = Some(Default::default()); + } + } + + fn request_branding_settings_image_small_branded_banner_image_url_init(request: &mut api::Channel) { + request_branding_settings_image_init(request); + if request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url.is_none() { + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url = Some(Default::default()); + } + } + fn request_branding_settings_init(request: &mut api::Channel) { if request.branding_settings.is_none() { request.branding_settings = Some(Default::default()); } } + fn request_branding_settings_watch_init(request: &mut api::Channel) { + request_branding_settings_init(request); + if request.branding_settings.as_mut().unwrap().watch.is_none() { + request.branding_settings.as_mut().unwrap().watch = Some(Default::default()); + } + } + fn request_content_details_init(request: &mut api::Channel) { if request.content_details.is_none() { request.content_details = Some(Default::default()); } } + fn request_content_details_related_playlists_init(request: &mut api::Channel) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().related_playlists.is_none() { + request.content_details.as_mut().unwrap().related_playlists = Some(Default::default()); + } + } + fn request_content_owner_details_init(request: &mut api::Channel) { if request.content_owner_details.is_none() { request.content_owner_details = Some(Default::default()); } } + fn request_invideo_promotion_default_timing_init(request: &mut api::Channel) { + request_invideo_promotion_init(request); + if request.invideo_promotion.as_mut().unwrap().default_timing.is_none() { + request.invideo_promotion.as_mut().unwrap().default_timing = Some(Default::default()); + } + } + fn request_invideo_promotion_init(request: &mut api::Channel) { if request.invideo_promotion.is_none() { request.invideo_promotion = Some(Default::default()); } } + fn request_invideo_promotion_position_init(request: &mut api::Channel) { + request_invideo_promotion_init(request); + if request.invideo_promotion.as_mut().unwrap().position.is_none() { + request.invideo_promotion.as_mut().unwrap().position = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::Channel) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_localized_init(request: &mut api::Channel) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Channel) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Channel) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Channel) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Channel) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Channel) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Channel) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_statistics_init(request: &mut api::Channel) { if request.statistics.is_none() { request.statistics = Some(Default::default()); @@ -1616,39 +2062,39 @@ impl Engine { match &field_name.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "status.is-linked" => { request_status_init(&mut request); - request.status.as_mut().unwrap().is_linked = arg_from_str(value.unwrap_or("false"), err, "status.is-linked", "boolean"); + request.status.as_mut().unwrap().is_linked = Some(arg_from_str(value.unwrap_or("false"), err, "status.is-linked", "boolean")); }, "status.long-uploads-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().long_uploads_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().long_uploads_status = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.default-timing.offset-ms" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().default_timing.offset_ms = value.unwrap_or("").to_string(); + request_invideo_promotion_default_timing_init(&mut request); + request.invideo_promotion.as_mut().unwrap().default_timing.as_mut().unwrap().offset_ms = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.default-timing.type" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().default_timing.type_ = value.unwrap_or("").to_string(); + request_invideo_promotion_default_timing_init(&mut request); + request.invideo_promotion.as_mut().unwrap().default_timing.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.default-timing.duration-ms" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().default_timing.duration_ms = value.unwrap_or("").to_string(); + request_invideo_promotion_default_timing_init(&mut request); + request.invideo_promotion.as_mut().unwrap().default_timing.as_mut().unwrap().duration_ms = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.position.corner-position" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().position.corner_position = value.unwrap_or("").to_string(); + request_invideo_promotion_position_init(&mut request); + request.invideo_promotion.as_mut().unwrap().position.as_mut().unwrap().corner_position = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.position.type" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().position.type_ = value.unwrap_or("").to_string(); + request_invideo_promotion_position_init(&mut request); + request.invideo_promotion.as_mut().unwrap().position.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "invideo-promotion.use-smart-timing" => { - request_invideo_promotion_init(&mut request); - request.invideo_promotion.as_mut().unwrap().use_smart_timing = arg_from_str(value.unwrap_or("false"), err, "invideo-promotion.use-smart-timing", "boolean"); + request_invideo_promotion_position_init(&mut request); + request.invideo_promotion.as_mut().unwrap().use_smart_timing = Some(arg_from_str(value.unwrap_or("false"), err, "invideo-promotion.use-smart-timing", "boolean")); }, "kind" => { request_invideo_promotion_init(&mut request); @@ -1656,331 +2102,345 @@ impl Engine { }, "statistics.comment-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().comment_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64"); + request.statistics.as_mut().unwrap().comment_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64")); }, "statistics.subscriber-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().subscriber_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.subscriber-count", "int64"); + request.statistics.as_mut().unwrap().subscriber_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.subscriber-count", "int64")); }, "statistics.video-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().video_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.video-count", "int64"); + request.statistics.as_mut().unwrap().video_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.video-count", "int64")); }, "statistics.hidden-subscriber-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().hidden_subscriber_count = arg_from_str(value.unwrap_or("false"), err, "statistics.hidden-subscriber-count", "boolean"); + request.statistics.as_mut().unwrap().hidden_subscriber_count = Some(arg_from_str(value.unwrap_or("false"), err, "statistics.hidden-subscriber-count", "boolean")); }, "statistics.view-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().view_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64"); + request.statistics.as_mut().unwrap().view_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64")); }, "content-owner-details.content-owner" => { request_content_owner_details_init(&mut request); - request.content_owner_details.as_mut().unwrap().content_owner = value.unwrap_or("").to_string(); + request.content_owner_details.as_mut().unwrap().content_owner = Some(value.unwrap_or("").to_string()); }, "content-owner-details.time-linked" => { request_content_owner_details_init(&mut request); - request.content_owner_details.as_mut().unwrap().time_linked = value.unwrap_or("").to_string(); + request.content_owner_details.as_mut().unwrap().time_linked = Some(value.unwrap_or("").to_string()); }, "topic-details.topic-ids" => { request_topic_details_init(&mut request); - request.topic_details.as_mut().unwrap().topic_ids.push(value.unwrap_or("").to_string()); + if request.topic_details.as_mut().unwrap().topic_ids.is_none() { + request.topic_details.as_mut().unwrap().topic_ids = Some(Default::default()); + } + request.topic_details.as_mut().unwrap().topic_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.related-playlists.watch-later" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().related_playlists.watch_later = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().related_playlists.as_mut().unwrap().watch_later = Some(value.unwrap_or("").to_string()); }, "content-details.related-playlists.watch-history" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().related_playlists.watch_history = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().related_playlists.as_mut().unwrap().watch_history = Some(value.unwrap_or("").to_string()); }, "content-details.related-playlists.uploads" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().related_playlists.uploads = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().related_playlists.as_mut().unwrap().uploads = Some(value.unwrap_or("").to_string()); }, "content-details.related-playlists.favorites" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().related_playlists.favorites = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().related_playlists.as_mut().unwrap().favorites = Some(value.unwrap_or("").to_string()); }, "content-details.related-playlists.likes" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().related_playlists.likes = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().related_playlists.as_mut().unwrap().likes = Some(value.unwrap_or("").to_string()); }, "content-details.google-plus-user-id" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().google_plus_user_id = value.unwrap_or("").to_string(); + request_content_details_related_playlists_init(&mut request); + request.content_details.as_mut().unwrap().google_plus_user_id = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.large-branded-banner-image-imap-script.default" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.large_branded_banner_image_imap_script.default = value.unwrap_or("").to_string(); + request_branding_settings_image_large_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script.as_mut().unwrap().default = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.large-branded-banner-image-imap-script.default-language.value" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.large_branded_banner_image_imap_script.default_language.value = value.unwrap_or("").to_string(); + request_branding_settings_image_large_branded_banner_image_imap_script_default_language_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_imap_script.as_mut().unwrap().default_language.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.small-branded-banner-image-url.default" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.small_branded_banner_image_url.default = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url.as_mut().unwrap().default = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.small-branded-banner-image-url.default-language.value" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.small_branded_banner_image_url.default_language.value = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_url_default_language_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_url.as_mut().unwrap().default_language.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tv-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tv_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tv_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tv-low-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tv_low_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tv_low_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.large-branded-banner-image-url.default" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.large_branded_banner_image_url.default = value.unwrap_or("").to_string(); + request_branding_settings_image_large_branded_banner_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url.as_mut().unwrap().default = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.large-branded-banner-image-url.default-language.value" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.large_branded_banner_image_url.default_language.value = value.unwrap_or("").to_string(); + request_branding_settings_image_large_branded_banner_image_url_default_language_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().large_branded_banner_image_url.as_mut().unwrap().default_language.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tv-high-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tv_high_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_large_branded_banner_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tv_high_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.background-image-url.default" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.background_image_url.default = value.unwrap_or("").to_string(); + request_branding_settings_image_background_image_url_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url.as_mut().unwrap().default = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.background-image-url.default-language.value" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.background_image_url.default_language.value = value.unwrap_or("").to_string(); + request_branding_settings_image_background_image_url_default_language_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().background_image_url.as_mut().unwrap().default_language.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.small-branded-banner-image-imap-script.default" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.small_branded_banner_image_imap_script.default = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script.as_mut().unwrap().default = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.small-branded-banner-image-imap-script.default-language.value" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.small_branded_banner_image_imap_script.default_language.value = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_default_language_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().small_branded_banner_image_imap_script.as_mut().unwrap().default_language.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-external-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_external_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_external_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.watch-icon-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.watch_icon_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().watch_icon_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tv-medium-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tv_medium_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tv_medium_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-mobile-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_mobile_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_mobile_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tablet-hd-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tablet_hd_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tablet_hd_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tablet-low-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tablet_low_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tablet_low_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.tracking-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.tracking_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().tracking_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-mobile-extra-hd-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_mobile_extra_hd_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_mobile_extra_hd_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tablet-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tablet_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tablet_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-mobile-low-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_mobile_low_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_mobile_low_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-mobile-medium-hd-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_mobile_medium_hd_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_mobile_medium_hd_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-tablet-extra-hd-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_tablet_extra_hd_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_tablet_extra_hd_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.image.banner-mobile-hd-image-url" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().image.banner_mobile_hd_image_url = value.unwrap_or("").to_string(); + request_branding_settings_image_small_branded_banner_image_imap_script_init(&mut request); + request.branding_settings.as_mut().unwrap().image.as_mut().unwrap().banner_mobile_hd_image_url = Some(value.unwrap_or("").to_string()); }, "branding-settings.watch.text-color" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().watch.text_color = value.unwrap_or("").to_string(); + request_branding_settings_watch_init(&mut request); + request.branding_settings.as_mut().unwrap().watch.as_mut().unwrap().text_color = Some(value.unwrap_or("").to_string()); }, "branding-settings.watch.featured-playlist-id" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().watch.featured_playlist_id = value.unwrap_or("").to_string(); + request_branding_settings_watch_init(&mut request); + request.branding_settings.as_mut().unwrap().watch.as_mut().unwrap().featured_playlist_id = Some(value.unwrap_or("").to_string()); }, "branding-settings.watch.background-color" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().watch.background_color = value.unwrap_or("").to_string(); + request_branding_settings_watch_init(&mut request); + request.branding_settings.as_mut().unwrap().watch.as_mut().unwrap().background_color = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.description" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.description = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.title" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.title = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, - "branding-settings.channel.moderate-comments" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.moderate_comments = arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.moderate-comments", "boolean"); + "branding-settings.channel.country" => { + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.show-browse-view" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.show_browse_view = arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.show-browse-view", "boolean"); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().show_browse_view = Some(arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.show-browse-view", "boolean")); }, "branding-settings.channel.featured-channels-title" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.featured_channels_title = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().featured_channels_title = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.default-language" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.default_language = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.unsubscribed-trailer" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.unsubscribed_trailer = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().unsubscribed_trailer = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.keywords" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.keywords = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().keywords = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.profile-color" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.profile_color = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().profile_color = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.default-tab" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.default_tab = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().default_tab = Some(value.unwrap_or("").to_string()); + }, + "branding-settings.channel.moderate-comments" => { + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().moderate_comments = Some(arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.moderate-comments", "boolean")); }, "branding-settings.channel.featured-channels-urls" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.featured_channels_urls.push(value.unwrap_or("").to_string()); + request_branding_settings_channel_init(&mut request); + if request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().featured_channels_urls.is_none() { + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().featured_channels_urls = Some(Default::default()); + } + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().featured_channels_urls.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "branding-settings.channel.tracking-analytics-account-id" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.tracking_analytics_account_id = value.unwrap_or("").to_string(); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().tracking_analytics_account_id = Some(value.unwrap_or("").to_string()); }, "branding-settings.channel.show-related-channels" => { - request_branding_settings_init(&mut request); - request.branding_settings.as_mut().unwrap().channel.show_related_channels = arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.show-related-channels", "boolean"); + request_branding_settings_channel_init(&mut request); + request.branding_settings.as_mut().unwrap().channel.as_mut().unwrap().show_related_channels = Some(arg_from_str(value.unwrap_or("false"), err, "branding-settings.channel.show-related-channels", "boolean")); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "snippet.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); + }, + "snippet.country" => { + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().country = Some(value.unwrap_or("").to_string()); }, "snippet.default-language" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request_snippet_thumbnails_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.localized.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "audit-details.community-guidelines-good-standing" => { request_audit_details_init(&mut request); - request.audit_details.as_mut().unwrap().community_guidelines_good_standing = arg_from_str(value.unwrap_or("false"), err, "audit-details.community-guidelines-good-standing", "boolean"); + request.audit_details.as_mut().unwrap().community_guidelines_good_standing = Some(arg_from_str(value.unwrap_or("false"), err, "audit-details.community-guidelines-good-standing", "boolean")); }, "audit-details.content-id-claims-good-standing" => { request_audit_details_init(&mut request); - request.audit_details.as_mut().unwrap().content_id_claims_good_standing = arg_from_str(value.unwrap_or("false"), err, "audit-details.content-id-claims-good-standing", "boolean"); + request.audit_details.as_mut().unwrap().content_id_claims_good_standing = Some(arg_from_str(value.unwrap_or("false"), err, "audit-details.content-id-claims-good-standing", "boolean")); }, "audit-details.overall-good-standing" => { request_audit_details_init(&mut request); - request.audit_details.as_mut().unwrap().overall_good_standing = arg_from_str(value.unwrap_or("false"), err, "audit-details.overall-good-standing", "boolean"); + request.audit_details.as_mut().unwrap().overall_good_standing = Some(arg_from_str(value.unwrap_or("false"), err, "audit-details.overall-good-standing", "boolean")); }, "audit-details.copyright-strikes-good-standing" => { request_audit_details_init(&mut request); - request.audit_details.as_mut().unwrap().copyright_strikes_good_standing = arg_from_str(value.unwrap_or("false"), err, "audit-details.copyright-strikes-good-standing", "boolean"); + request.audit_details.as_mut().unwrap().copyright_strikes_good_standing = Some(arg_from_str(value.unwrap_or("false"), err, "audit-details.copyright-strikes-good-standing", "boolean")); }, "etag" => { request_audit_details_init(&mut request); @@ -2007,8 +2467,940 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + 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); + 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 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_snippet_init(request: &mut api::CommentThread) { + if request.snippet.is_none() { + request.snippet = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_init(request: &mut api::CommentThread) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.is_none() { + request.snippet.as_mut().unwrap().top_level_comment = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_snippet_author_channel_id_init(request: &mut api::CommentThread) { + request_snippet_top_level_comment_snippet_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id.is_none() { + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_snippet_init(request: &mut api::CommentThread) { + request_snippet_top_level_comment_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.is_none() { + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet = Some(Default::default()); + } + } + + match &field_name.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")); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.video-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.can-reply" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().can_reply = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.can-reply", "boolean")); + }, + "snippet.total-reply-count" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().total_reply_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.total-reply-count", "integer")); + }, + "snippet.top-level-comment.snippet.author-channel-url" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.viewer-rating" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().viewer_rating = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-display-name" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_display_name = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.channel-id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.video-id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.published-at" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.like-count" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.top-level-comment.snippet.like-count", "integer")); + }, + "snippet.top-level-comment.snippet.text-original" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().text_original = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-channel-id.value" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.parent-id" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().parent_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.moderation-status" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().moderation_status = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.can-rate" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().can_rate = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.top-level-comment.snippet.can-rate", "boolean")); + }, + "snippet.top-level-comment.snippet.updated-at" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().updated_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-profile-image-url" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_profile_image_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-googleplus-profile-url" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_googleplus_profile_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.text-display" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().text_display = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.kind" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.etag" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_snippet_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_snippet_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_snippet_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); + 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_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.comment_threads().list(&self.opt.arg_part); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "video-id" => { + call = call.video_id(value.unwrap_or("")); + }, + "text-format" => { + call = call.text_format(value.unwrap_or("")); + }, + "search-terms" => { + call = call.search_terms(value.unwrap_or("")); + }, + "page-token" => { + call = call.page_token(value.unwrap_or("")); + }, + "moderation-status" => { + call = call.moderation_status(value.unwrap_or("")); + }, + "max-results" => { + call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); + }, + "id" => { + call = call.id(value.unwrap_or("")); + }, + "channel-id" => { + call = call.channel_id(value.unwrap_or("")); + }, + "all-threads-related-to-channel-id" => { + call = call.all_threads_related_to_channel_id(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); + 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_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(); + 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_snippet_init(request: &mut api::CommentThread) { + if request.snippet.is_none() { + request.snippet = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_init(request: &mut api::CommentThread) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.is_none() { + request.snippet.as_mut().unwrap().top_level_comment = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_snippet_author_channel_id_init(request: &mut api::CommentThread) { + request_snippet_top_level_comment_snippet_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id.is_none() { + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id = Some(Default::default()); + } + } + + fn request_snippet_top_level_comment_snippet_init(request: &mut api::CommentThread) { + request_snippet_top_level_comment_init(request); + if request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.is_none() { + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet = Some(Default::default()); + } + } + + match &field_name.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")); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.video-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.can-reply" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().can_reply = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.can-reply", "boolean")); + }, + "snippet.total-reply-count" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().total_reply_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.total-reply-count", "integer")); + }, + "snippet.top-level-comment.snippet.author-channel-url" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.viewer-rating" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().viewer_rating = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-display-name" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_display_name = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.channel-id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.video-id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.published-at" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.like-count" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.top-level-comment.snippet.like-count", "integer")); + }, + "snippet.top-level-comment.snippet.text-original" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().text_original = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-channel-id.value" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_channel_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.parent-id" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().parent_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.moderation-status" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().moderation_status = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.can-rate" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().can_rate = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.top-level-comment.snippet.can-rate", "boolean")); + }, + "snippet.top-level-comment.snippet.updated-at" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().updated_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-profile-image-url" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_profile_image_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.author-googleplus-profile-url" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().author_googleplus_profile_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.snippet.text-display" => { + request_snippet_top_level_comment_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().snippet.as_mut().unwrap().text_display = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.kind" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.etag" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().etag = Some(value.unwrap_or("").to_string()); + }, + "snippet.top-level-comment.id" => { + request_snippet_top_level_comment_snippet_init(&mut request); + request.snippet.as_mut().unwrap().top_level_comment.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_snippet_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_snippet_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_snippet_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); + 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 _comments_delete(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.comments().delete(&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); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + 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(); + 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_snippet_author_channel_id_init(request: &mut api::Comment) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().author_channel_id.is_none() { + request.snippet.as_mut().unwrap().author_channel_id = Some(Default::default()); + } + } + + fn request_snippet_init(request: &mut api::Comment) { + if request.snippet.is_none() { + request.snippet = Some(Default::default()); + } + } + + match &field_name.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()); + }, + "snippet.viewer-rating" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().viewer_rating = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-display-name" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().author_display_name = Some(value.unwrap_or("").to_string()); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.video-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.published-at" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.like-count" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.like-count", "integer")); + }, + "snippet.text-original" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().text_original = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-channel-id.value" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_channel_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "snippet.parent-id" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().parent_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.moderation-status" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().moderation_status = Some(value.unwrap_or("").to_string()); + }, + "snippet.can-rate" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().can_rate = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.can-rate", "boolean")); + }, + "snippet.updated-at" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().updated_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-profile-image-url" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_profile_image_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-googleplus-profile-url" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_googleplus_profile_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.text-display" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().text_display = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_snippet_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_snippet_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_snippet_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); + 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 _comments_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.comments().list(&self.opt.arg_part); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "text-format" => { + call = call.text_format(value.unwrap_or("")); + }, + "parent-id" => { + call = call.parent_id(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")); + }, + "id" => { + call = call.id(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); + 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 _comments_mark_as_spam(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.comments().mark_as_spam(&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); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + fn _comments_set_moderation_status(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.comments().set_moderation_status(&self.opt.arg_id, &self.opt.arg_moderation_status); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "ban-author" => { + call = call.ban_author(arg_from_str(value.unwrap_or("false"), err, "ban-author", "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); + match match protocol { + "standard-request" => call.doit(), + _ => unreachable!(), + } { + Err(api_err) => Some(api_err), + Ok(mut response) => { + None + } + } + } + } + + 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(); + 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_snippet_author_channel_id_init(request: &mut api::Comment) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().author_channel_id.is_none() { + request.snippet.as_mut().unwrap().author_channel_id = Some(Default::default()); + } + } + + fn request_snippet_init(request: &mut api::Comment) { + if request.snippet.is_none() { + request.snippet = Some(Default::default()); + } + } + + match &field_name.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()); + }, + "snippet.viewer-rating" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().viewer_rating = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-display-name" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().author_display_name = Some(value.unwrap_or("").to_string()); + }, + "snippet.channel-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.video-id" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.published-at" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.like-count" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.like-count", "integer")); + }, + "snippet.text-original" => { + request_snippet_init(&mut request); + request.snippet.as_mut().unwrap().text_original = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-channel-id.value" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_channel_id.as_mut().unwrap().value = Some(value.unwrap_or("").to_string()); + }, + "snippet.parent-id" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().parent_id = Some(value.unwrap_or("").to_string()); + }, + "snippet.moderation-status" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().moderation_status = Some(value.unwrap_or("").to_string()); + }, + "snippet.can-rate" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().can_rate = Some(arg_from_str(value.unwrap_or("false"), err, "snippet.can-rate", "boolean")); + }, + "snippet.updated-at" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().updated_at = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-profile-image-url" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_profile_image_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.author-googleplus-profile-url" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().author_googleplus_profile_url = Some(value.unwrap_or("").to_string()); + }, + "snippet.text-display" => { + request_snippet_author_channel_id_init(&mut request); + request.snippet.as_mut().unwrap().text_display = Some(value.unwrap_or("").to_string()); + }, + "kind" => { + request_snippet_init(&mut request); + request.kind = Some(value.unwrap_or("").to_string()); + }, + "etag" => { + request_snippet_init(&mut request); + request.etag = Some(value.unwrap_or("").to_string()); + }, + "id" => { + request_snippet_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); + 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 } } @@ -2019,7 +3411,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.guide_categories().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "region-code" => { call = call.region_code(value.unwrap_or("")); @@ -2060,8 +3452,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2072,7 +3463,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.i18n_languages().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "hl" => { call = call.hl(value.unwrap_or("")); @@ -2107,8 +3498,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2119,7 +3509,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.i18n_regions().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "hl" => { call = call.hl(value.unwrap_or("")); @@ -2154,8 +3544,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2166,7 +3555,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_broadcasts().bind(&self.opt.arg_id, &self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "stream-id" => { call = call.stream_id(value.unwrap_or("")); @@ -2207,8 +3596,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2219,7 +3607,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_broadcasts().control(&self.opt.arg_id, &self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "walltime" => { call = call.walltime(value.unwrap_or("")); @@ -2266,8 +3654,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2278,7 +3665,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_broadcasts().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -2315,7 +3702,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2324,10 +3710,10 @@ impl Engine { fn _live_broadcasts_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LiveBroadcast = Default::default(); + 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); + 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("")); @@ -2353,9 +3739,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2365,12 +3752,61 @@ impl Engine { } } + fn request_content_details_monitor_stream_init(request: &mut api::LiveBroadcast) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().monitor_stream.is_none() { + request.content_details.as_mut().unwrap().monitor_stream = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::LiveBroadcast) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_thumbnails_default_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::LiveBroadcast) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::LiveBroadcast) { if request.status.is_none() { request.status = Some(Default::default()); @@ -2380,19 +3816,23 @@ impl Engine { match &field_name.to_string()[..] { "status.recording-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().recording_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().recording_status = Some(value.unwrap_or("").to_string()); }, "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "status.life-cycle-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().life_cycle_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().life_cycle_status = Some(value.unwrap_or("").to_string()); + }, + "status.is-default-broadcast" => { + request_status_init(&mut request); + request.status.as_mut().unwrap().is_default_broadcast = Some(arg_from_str(value.unwrap_or("false"), err, "status.is-default-broadcast", "boolean")); }, "status.live-broadcast-priority" => { request_status_init(&mut request); - request.status.as_mut().unwrap().live_broadcast_priority = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().live_broadcast_priority = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -2400,135 +3840,135 @@ impl Engine { }, "content-details.start-with-slate" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().start_with_slate = arg_from_str(value.unwrap_or("false"), err, "content-details.start-with-slate", "boolean"); + request.content_details.as_mut().unwrap().start_with_slate = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.start-with-slate", "boolean")); }, "content-details.bound-stream-id" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bound_stream_id = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().bound_stream_id = Some(value.unwrap_or("").to_string()); }, "content-details.enable-embed" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_embed = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-embed", "boolean"); + request.content_details.as_mut().unwrap().enable_embed = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-embed", "boolean")); }, "content-details.enable-closed-captions" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_closed_captions = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-closed-captions", "boolean"); + request.content_details.as_mut().unwrap().enable_closed_captions = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-closed-captions", "boolean")); }, "content-details.enable-content-encryption" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_content_encryption = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-content-encryption", "boolean"); + request.content_details.as_mut().unwrap().enable_content_encryption = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-content-encryption", "boolean")); }, "content-details.record-from-start" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().record_from_start = arg_from_str(value.unwrap_or("false"), err, "content-details.record-from-start", "boolean"); + request.content_details.as_mut().unwrap().record_from_start = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.record-from-start", "boolean")); }, "content-details.enable-dvr" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_dvr = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-dvr", "boolean"); + request.content_details.as_mut().unwrap().enable_dvr = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-dvr", "boolean")); }, "content-details.monitor-stream.broadcast-stream-delay-ms" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.broadcast_stream_delay_ms = arg_from_str(value.unwrap_or("-0"), err, "content-details.monitor-stream.broadcast-stream-delay-ms", "integer"); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().broadcast_stream_delay_ms = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.monitor-stream.broadcast-stream-delay-ms", "integer")); }, "content-details.monitor-stream.embed-html" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.embed_html = value.unwrap_or("").to_string(); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "content-details.monitor-stream.enable-monitor-stream" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.enable_monitor_stream = arg_from_str(value.unwrap_or("false"), err, "content-details.monitor-stream.enable-monitor-stream", "boolean"); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().enable_monitor_stream = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.monitor-stream.enable-monitor-stream", "boolean")); }, "snippet.actual-end-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().actual_end_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().actual_end_time = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.scheduled-start-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().scheduled_start_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().scheduled_start_time = Some(value.unwrap_or("").to_string()); }, "snippet.actual-start-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().actual_start_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().actual_start_time = Some(value.unwrap_or("").to_string()); }, "snippet.scheduled-end-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().scheduled_end_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().scheduled_end_time = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "etag" => { request_snippet_init(&mut request); @@ -2555,8 +3995,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2567,7 +4006,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_broadcasts().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -2620,8 +4059,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2632,7 +4070,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_broadcasts().transition(&self.opt.arg_broadcast_status, &self.opt.arg_id, &self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -2670,8 +4108,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2680,10 +4117,10 @@ impl Engine { fn _live_broadcasts_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LiveBroadcast = Default::default(); + 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); + 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("")); @@ -2709,9 +4146,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -2721,12 +4159,61 @@ impl Engine { } } + fn request_content_details_monitor_stream_init(request: &mut api::LiveBroadcast) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().monitor_stream.is_none() { + request.content_details.as_mut().unwrap().monitor_stream = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::LiveBroadcast) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_thumbnails_default_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::LiveBroadcast) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::LiveBroadcast) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::LiveBroadcast) { if request.status.is_none() { request.status = Some(Default::default()); @@ -2736,19 +4223,23 @@ impl Engine { match &field_name.to_string()[..] { "status.recording-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().recording_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().recording_status = Some(value.unwrap_or("").to_string()); }, "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "status.life-cycle-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().life_cycle_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().life_cycle_status = Some(value.unwrap_or("").to_string()); + }, + "status.is-default-broadcast" => { + request_status_init(&mut request); + request.status.as_mut().unwrap().is_default_broadcast = Some(arg_from_str(value.unwrap_or("false"), err, "status.is-default-broadcast", "boolean")); }, "status.live-broadcast-priority" => { request_status_init(&mut request); - request.status.as_mut().unwrap().live_broadcast_priority = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().live_broadcast_priority = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -2756,135 +4247,135 @@ impl Engine { }, "content-details.start-with-slate" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().start_with_slate = arg_from_str(value.unwrap_or("false"), err, "content-details.start-with-slate", "boolean"); + request.content_details.as_mut().unwrap().start_with_slate = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.start-with-slate", "boolean")); }, "content-details.bound-stream-id" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().bound_stream_id = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().bound_stream_id = Some(value.unwrap_or("").to_string()); }, "content-details.enable-embed" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_embed = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-embed", "boolean"); + request.content_details.as_mut().unwrap().enable_embed = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-embed", "boolean")); }, "content-details.enable-closed-captions" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_closed_captions = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-closed-captions", "boolean"); + request.content_details.as_mut().unwrap().enable_closed_captions = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-closed-captions", "boolean")); }, "content-details.enable-content-encryption" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_content_encryption = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-content-encryption", "boolean"); + request.content_details.as_mut().unwrap().enable_content_encryption = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-content-encryption", "boolean")); }, "content-details.record-from-start" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().record_from_start = arg_from_str(value.unwrap_or("false"), err, "content-details.record-from-start", "boolean"); + request.content_details.as_mut().unwrap().record_from_start = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.record-from-start", "boolean")); }, "content-details.enable-dvr" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().enable_dvr = arg_from_str(value.unwrap_or("false"), err, "content-details.enable-dvr", "boolean"); + request.content_details.as_mut().unwrap().enable_dvr = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.enable-dvr", "boolean")); }, "content-details.monitor-stream.broadcast-stream-delay-ms" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.broadcast_stream_delay_ms = arg_from_str(value.unwrap_or("-0"), err, "content-details.monitor-stream.broadcast-stream-delay-ms", "integer"); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().broadcast_stream_delay_ms = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.monitor-stream.broadcast-stream-delay-ms", "integer")); }, "content-details.monitor-stream.embed-html" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.embed_html = value.unwrap_or("").to_string(); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "content-details.monitor-stream.enable-monitor-stream" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().monitor_stream.enable_monitor_stream = arg_from_str(value.unwrap_or("false"), err, "content-details.monitor-stream.enable-monitor-stream", "boolean"); + request_content_details_monitor_stream_init(&mut request); + request.content_details.as_mut().unwrap().monitor_stream.as_mut().unwrap().enable_monitor_stream = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.monitor-stream.enable-monitor-stream", "boolean")); }, "snippet.actual-end-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().actual_end_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().actual_end_time = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.scheduled-start-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().scheduled_start_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().scheduled_start_time = Some(value.unwrap_or("").to_string()); }, "snippet.actual-start-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().actual_start_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().actual_start_time = Some(value.unwrap_or("").to_string()); }, "snippet.scheduled-end-time" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().scheduled_end_time = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().scheduled_end_time = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "etag" => { request_snippet_init(&mut request); @@ -2911,8 +4402,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -2923,7 +4413,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_streams().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -2960,7 +4450,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -2969,10 +4458,10 @@ impl Engine { fn _live_streams_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LiveStream = Default::default(); + 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); + 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("")); @@ -2998,12 +4487,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_cdn_ingestion_info_init(request: &mut api::LiveStream) { + request_cdn_init(request); + if request.cdn.as_mut().unwrap().ingestion_info.is_none() { + request.cdn.as_mut().unwrap().ingestion_info = Some(Default::default()); + } + } + fn request_cdn_init(request: &mut api::LiveStream) { if request.cdn.is_none() { request.cdn = Some(Default::default()); @@ -3029,9 +4526,13 @@ impl Engine { } match &field_name.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")); + }, "status.stream-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().stream_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().stream_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -3039,47 +4540,47 @@ impl Engine { }, "content-details.is-reusable" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().is_reusable = arg_from_str(value.unwrap_or("false"), err, "content-details.is-reusable", "boolean"); + request.content_details.as_mut().unwrap().is_reusable = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.is-reusable", "boolean")); }, "content-details.closed-captions-ingestion-url" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().closed_captions_ingestion_url = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().closed_captions_ingestion_url = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-type" => { request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_type = value.unwrap_or("").to_string(); + request.cdn.as_mut().unwrap().ingestion_type = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.backup-ingestion-address" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.backup_ingestion_address = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().backup_ingestion_address = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.stream-name" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.stream_name = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().stream_name = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.ingestion-address" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.ingestion_address = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().ingestion_address = Some(value.unwrap_or("").to_string()); }, "cdn.format" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().format = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().format = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "etag" => { request_snippet_init(&mut request); @@ -3106,8 +4607,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3118,7 +4618,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.live_streams().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -3168,8 +4668,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3178,10 +4677,10 @@ impl Engine { fn _live_streams_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::LiveStream = Default::default(); + 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); + 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("")); @@ -3207,12 +4706,20 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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_cdn_ingestion_info_init(request: &mut api::LiveStream) { + request_cdn_init(request); + if request.cdn.as_mut().unwrap().ingestion_info.is_none() { + request.cdn.as_mut().unwrap().ingestion_info = Some(Default::default()); + } + } + fn request_cdn_init(request: &mut api::LiveStream) { if request.cdn.is_none() { request.cdn = Some(Default::default()); @@ -3238,9 +4745,13 @@ impl Engine { } match &field_name.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")); + }, "status.stream-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().stream_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().stream_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -3248,47 +4759,47 @@ impl Engine { }, "content-details.is-reusable" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().is_reusable = arg_from_str(value.unwrap_or("false"), err, "content-details.is-reusable", "boolean"); + request.content_details.as_mut().unwrap().is_reusable = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.is-reusable", "boolean")); }, "content-details.closed-captions-ingestion-url" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().closed_captions_ingestion_url = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().closed_captions_ingestion_url = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-type" => { request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_type = value.unwrap_or("").to_string(); + request.cdn.as_mut().unwrap().ingestion_type = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.backup-ingestion-address" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.backup_ingestion_address = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().backup_ingestion_address = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.stream-name" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.stream_name = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().stream_name = Some(value.unwrap_or("").to_string()); }, "cdn.ingestion-info.ingestion-address" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().ingestion_info.ingestion_address = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().ingestion_info.as_mut().unwrap().ingestion_address = Some(value.unwrap_or("").to_string()); }, "cdn.format" => { - request_cdn_init(&mut request); - request.cdn.as_mut().unwrap().format = value.unwrap_or("").to_string(); + request_cdn_ingestion_info_init(&mut request); + request.cdn.as_mut().unwrap().format = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "etag" => { request_snippet_init(&mut request); @@ -3315,8 +4826,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3327,7 +4837,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.playlist_items().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3358,7 +4868,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3367,10 +4876,10 @@ impl Engine { fn _playlist_items_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlaylistItem = Default::default(); + 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); + 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("")); @@ -3393,9 +4902,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3411,6 +4921,55 @@ impl Engine { } } + fn request_snippet_resource_id_init(request: &mut api::PlaylistItem) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().resource_id.is_none() { + request.snippet.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::PlaylistItem) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::PlaylistItem) { if request.status.is_none() { request.status = Some(Default::default()); @@ -3420,7 +4979,7 @@ impl Engine { match &field_name.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -3428,123 +4987,123 @@ impl Engine { }, "content-details.note" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().note = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().note = Some(value.unwrap_or("").to_string()); }, "content-details.start-at" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().start_at = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().start_at = Some(value.unwrap_or("").to_string()); }, "content-details.end-at" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().end_at = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().end_at = Some(value.unwrap_or("").to_string()); }, "content-details.video-id" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().video_id = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.playlist-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().playlist_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.kind" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.kind = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.playlist-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.playlist_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.video-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.video_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.position" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().position = arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer"); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().position = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer")); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "etag" => { request_snippet_init(&mut request); @@ -3571,8 +5130,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3583,7 +5141,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.playlist_items().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "video-id" => { call = call.video_id(value.unwrap_or("")); @@ -3633,8 +5191,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3643,10 +5200,10 @@ impl Engine { fn _playlist_items_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::PlaylistItem = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -3666,9 +5223,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3684,6 +5242,55 @@ impl Engine { } } + fn request_snippet_resource_id_init(request: &mut api::PlaylistItem) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().resource_id.is_none() { + request.snippet.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::PlaylistItem) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::PlaylistItem) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::PlaylistItem) { if request.status.is_none() { request.status = Some(Default::default()); @@ -3693,7 +5300,7 @@ impl Engine { match &field_name.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -3701,123 +5308,123 @@ impl Engine { }, "content-details.note" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().note = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().note = Some(value.unwrap_or("").to_string()); }, "content-details.start-at" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().start_at = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().start_at = Some(value.unwrap_or("").to_string()); }, "content-details.end-at" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().end_at = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().end_at = Some(value.unwrap_or("").to_string()); }, "content-details.video-id" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().video_id = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.playlist-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().playlist_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.kind" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.kind = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.playlist-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.playlist_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.video-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.video_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.position" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().position = arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer"); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().position = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.position", "integer")); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "etag" => { request_snippet_init(&mut request); @@ -3844,8 +5451,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -3856,7 +5462,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.playlists().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -3890,7 +5496,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -3899,10 +5504,10 @@ impl Engine { fn _playlists_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Playlist = Default::default(); + 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); + 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("")); @@ -3928,9 +5533,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -3952,6 +5558,55 @@ impl Engine { } } + fn request_snippet_localized_init(request: &mut api::Playlist) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Playlist) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::Playlist) { if request.status.is_none() { request.status = Some(Default::default()); @@ -3961,7 +5616,7 @@ impl Engine { match &field_name.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -3969,107 +5624,110 @@ impl Engine { }, "content-details.item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "integer"); + request.content_details.as_mut().unwrap().item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "integer")); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.tags" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.snippet.as_mut().unwrap().tags.is_none() { + request.snippet.as_mut().unwrap().tags = Some(Default::default()); + } + request.snippet.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.default-language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "snippet.localized.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "player.embed-html" => { request_player_init(&mut request); - request.player.as_mut().unwrap().embed_html = value.unwrap_or("").to_string(); + request.player.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "etag" => { request_player_init(&mut request); @@ -4096,8 +5754,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4108,7 +5765,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.playlists().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4164,8 +5821,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4174,10 +5830,10 @@ impl Engine { fn _playlists_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Playlist = Default::default(); + 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); + 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("")); @@ -4200,9 +5856,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4224,6 +5881,55 @@ impl Engine { } } + fn request_snippet_localized_init(request: &mut api::Playlist) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Playlist) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Playlist) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_status_init(request: &mut api::Playlist) { if request.status.is_none() { request.status = Some(Default::default()); @@ -4233,7 +5939,7 @@ impl Engine { match &field_name.to_string()[..] { "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "kind" => { request_status_init(&mut request); @@ -4241,107 +5947,110 @@ impl Engine { }, "content-details.item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "integer"); + request.content_details.as_mut().unwrap().item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "integer")); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.tags" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.snippet.as_mut().unwrap().tags.is_none() { + request.snippet.as_mut().unwrap().tags = Some(Default::default()); + } + request.snippet.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.default-language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "snippet.localized.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "player.embed-html" => { request_player_init(&mut request); - request.player.as_mut().unwrap().embed_html = value.unwrap_or("").to_string(); + request.player.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "etag" => { request_player_init(&mut request); @@ -4368,8 +6077,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4380,7 +6088,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.search().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "video-type" => { call = call.video_type(value.unwrap_or("")); @@ -4502,8 +6210,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4514,7 +6221,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subscriptions().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4545,7 +6252,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -4554,10 +6260,10 @@ impl Engine { fn _subscriptions_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Subscription = Default::default(); + 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); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -4577,9 +6283,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -4595,123 +6302,214 @@ impl Engine { } } + fn request_snippet_resource_id_init(request: &mut api::Subscription) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().resource_id.is_none() { + request.snippet.as_mut().unwrap().resource_id = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Subscription) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Subscription) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Subscription) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Subscription) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Subscription) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Subscription) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_subscriber_snippet_init(request: &mut api::Subscription) { if request.subscriber_snippet.is_none() { request.subscriber_snippet = Some(Default::default()); } } + fn request_subscriber_snippet_thumbnails_default_init(request: &mut api::Subscription) { + request_subscriber_snippet_thumbnails_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_subscriber_snippet_thumbnails_high_init(request: &mut api::Subscription) { + request_subscriber_snippet_thumbnails_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_subscriber_snippet_thumbnails_init(request: &mut api::Subscription) { + request_subscriber_snippet_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_subscriber_snippet_thumbnails_maxres_init(request: &mut api::Subscription) { + request_subscriber_snippet_thumbnails_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_subscriber_snippet_thumbnails_medium_init(request: &mut api::Subscription) { + request_subscriber_snippet_thumbnails_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_subscriber_snippet_thumbnails_standard_init(request: &mut api::Subscription) { + request_subscriber_snippet_thumbnails_init(request); + if request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + match &field_name.to_string()[..] { "kind" => { request.kind = Some(value.unwrap_or("").to_string()); }, "content-details.new-item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().new_item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.new-item-count", "integer"); + request.content_details.as_mut().unwrap().new_item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.new-item-count", "integer")); }, "content-details.activity-type" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().activity_type = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().activity_type = Some(value.unwrap_or("").to_string()); }, "content-details.total-item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().total_item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.total-item-count", "integer"); + request.content_details.as_mut().unwrap().total_item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.total-item-count", "integer")); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.kind" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.kind = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().kind = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.playlist-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.playlist_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().playlist_id = Some(value.unwrap_or("").to_string()); }, "snippet.resource-id.video-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().resource_id.video_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().resource_id.as_mut().unwrap().video_id = Some(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request_snippet_resource_id_init(&mut request); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "etag" => { request_snippet_init(&mut request); @@ -4719,75 +6517,75 @@ impl Engine { }, "subscriber-snippet.title" => { request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.subscriber_snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.channel-id" => { request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.subscriber_snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.description" => { request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.subscriber_snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.default.url" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + request_subscriber_snippet_thumbnails_default_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.default.width" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.default.width", "integer")); + request_subscriber_snippet_thumbnails_default_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.default.width", "integer")); }, "subscriber-snippet.thumbnails.default.height" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.default.height", "integer")); + request_subscriber_snippet_thumbnails_default_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.default.height", "integer")); }, "subscriber-snippet.thumbnails.high.url" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_subscriber_snippet_thumbnails_high_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.high.width" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.high.width", "integer")); + request_subscriber_snippet_thumbnails_high_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.high.width", "integer")); }, "subscriber-snippet.thumbnails.high.height" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.high.height", "integer")); + request_subscriber_snippet_thumbnails_high_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.high.height", "integer")); }, "subscriber-snippet.thumbnails.medium.url" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_subscriber_snippet_thumbnails_medium_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.medium.width" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.medium.width", "integer")); + request_subscriber_snippet_thumbnails_medium_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.medium.width", "integer")); }, "subscriber-snippet.thumbnails.medium.height" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.medium.height", "integer")); + request_subscriber_snippet_thumbnails_medium_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.medium.height", "integer")); }, "subscriber-snippet.thumbnails.maxres.url" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_subscriber_snippet_thumbnails_maxres_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.maxres.width" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.maxres.width", "integer")); + request_subscriber_snippet_thumbnails_maxres_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.maxres.width", "integer")); }, "subscriber-snippet.thumbnails.maxres.height" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.maxres.height", "integer")); + request_subscriber_snippet_thumbnails_maxres_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.maxres.height", "integer")); }, "subscriber-snippet.thumbnails.standard.url" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_subscriber_snippet_thumbnails_standard_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "subscriber-snippet.thumbnails.standard.width" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.standard.width", "integer")); + request_subscriber_snippet_thumbnails_standard_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.standard.width", "integer")); }, "subscriber-snippet.thumbnails.standard.height" => { - request_subscriber_snippet_init(&mut request); - request.subscriber_snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.standard.height", "integer")); + request_subscriber_snippet_thumbnails_standard_init(&mut request); + request.subscriber_snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "subscriber-snippet.thumbnails.standard.height", "integer")); }, "id" => { request_subscriber_snippet_init(&mut request); @@ -4810,8 +6608,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4822,7 +6619,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.subscriptions().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); @@ -4884,8 +6681,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -4896,7 +6692,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.thumbnails().set(&self.opt.arg_video_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -4941,8 +6737,53 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); + None + } + } + } + } + + fn _video_abuse_report_reasons_list(&self, dry_run: bool, err: &mut InvalidOptionsError) + -> Option<api::Error> { + let mut call = self.hub.video_abuse_report_reasons().list(&self.opt.arg_part); + for parg in self.opt.arg_v.iter() { + let (key, value) = parse_kv_arg(&*parg, err, false); + match key { + "hl" => { + call = call.hl(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); + 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 } } @@ -4953,7 +6794,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.video_categories().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "region-code" => { call = call.region_code(value.unwrap_or("")); @@ -4994,8 +6835,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5006,7 +6846,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.videos().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -5040,7 +6880,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -5051,7 +6890,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.videos().get_rating(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -5086,8 +6925,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5096,10 +6934,10 @@ impl Engine { fn _videos_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Video = Default::default(); + 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); + 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")); @@ -5134,9 +6972,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -5146,24 +6985,59 @@ impl Engine { } } + fn request_content_details_content_rating_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().content_rating.is_none() { + request.content_details.as_mut().unwrap().content_rating = Some(Default::default()); + } + } + + fn request_content_details_country_restriction_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().country_restriction.is_none() { + request.content_details.as_mut().unwrap().country_restriction = Some(Default::default()); + } + } + fn request_content_details_init(request: &mut api::Video) { if request.content_details.is_none() { request.content_details = Some(Default::default()); } } + fn request_content_details_region_restriction_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().region_restriction.is_none() { + request.content_details.as_mut().unwrap().region_restriction = Some(Default::default()); + } + } + fn request_file_details_init(request: &mut api::Video) { if request.file_details.is_none() { request.file_details = Some(Default::default()); } } + fn request_file_details_recording_location_init(request: &mut api::Video) { + request_file_details_init(request); + if request.file_details.as_mut().unwrap().recording_location.is_none() { + request.file_details.as_mut().unwrap().recording_location = Some(Default::default()); + } + } + fn request_live_streaming_details_init(request: &mut api::Video) { if request.live_streaming_details.is_none() { request.live_streaming_details = Some(Default::default()); } } + fn request_monetization_details_access_init(request: &mut api::Video) { + request_monetization_details_init(request); + if request.monetization_details.as_mut().unwrap().access.is_none() { + request.monetization_details.as_mut().unwrap().access = Some(Default::default()); + } + } + fn request_monetization_details_init(request: &mut api::Video) { if request.monetization_details.is_none() { request.monetization_details = Some(Default::default()); @@ -5182,6 +7056,13 @@ impl Engine { } } + fn request_processing_details_processing_progress_init(request: &mut api::Video) { + request_processing_details_init(request); + if request.processing_details.as_mut().unwrap().processing_progress.is_none() { + request.processing_details.as_mut().unwrap().processing_progress = Some(Default::default()); + } + } + fn request_project_details_init(request: &mut api::Video) { if request.project_details.is_none() { request.project_details = Some(Default::default()); @@ -5194,12 +7075,68 @@ impl Engine { } } + fn request_recording_details_location_init(request: &mut api::Video) { + request_recording_details_init(request); + if request.recording_details.as_mut().unwrap().location.is_none() { + request.recording_details.as_mut().unwrap().location = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::Video) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_localized_init(request: &mut api::Video) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Video) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_statistics_init(request: &mut api::Video) { if request.statistics.is_none() { request.statistics = Some(Default::default()); @@ -5227,43 +7164,49 @@ impl Engine { match &field_name.to_string()[..] { "status.license" => { request_status_init(&mut request); - request.status.as_mut().unwrap().license = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().license = Some(value.unwrap_or("").to_string()); }, "status.embeddable" => { request_status_init(&mut request); - request.status.as_mut().unwrap().embeddable = arg_from_str(value.unwrap_or("false"), err, "status.embeddable", "boolean"); + request.status.as_mut().unwrap().embeddable = Some(arg_from_str(value.unwrap_or("false"), err, "status.embeddable", "boolean")); }, "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "status.publish-at" => { request_status_init(&mut request); - request.status.as_mut().unwrap().publish_at = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().publish_at = Some(value.unwrap_or("").to_string()); }, "status.public-stats-viewable" => { request_status_init(&mut request); - request.status.as_mut().unwrap().public_stats_viewable = arg_from_str(value.unwrap_or("false"), err, "status.public-stats-viewable", "boolean"); + request.status.as_mut().unwrap().public_stats_viewable = Some(arg_from_str(value.unwrap_or("false"), err, "status.public-stats-viewable", "boolean")); }, "status.upload-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().upload_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().upload_status = Some(value.unwrap_or("").to_string()); }, "status.rejection-reason" => { request_status_init(&mut request); - request.status.as_mut().unwrap().rejection_reason = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().rejection_reason = Some(value.unwrap_or("").to_string()); }, "status.failure-reason" => { request_status_init(&mut request); - request.status.as_mut().unwrap().failure_reason = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().failure_reason = Some(value.unwrap_or("").to_string()); }, "topic-details.topic-ids" => { request_topic_details_init(&mut request); - request.topic_details.as_mut().unwrap().topic_ids.push(value.unwrap_or("").to_string()); + if request.topic_details.as_mut().unwrap().topic_ids.is_none() { + request.topic_details.as_mut().unwrap().topic_ids = Some(Default::default()); + } + request.topic_details.as_mut().unwrap().topic_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "topic-details.relevant-topic-ids" => { request_topic_details_init(&mut request); - request.topic_details.as_mut().unwrap().relevant_topic_ids.push(value.unwrap_or("").to_string()); + if request.topic_details.as_mut().unwrap().relevant_topic_ids.is_none() { + request.topic_details.as_mut().unwrap().relevant_topic_ids = Some(Default::default()); + } + request.topic_details.as_mut().unwrap().relevant_topic_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_topic_details_init(&mut request); @@ -5271,559 +7214,589 @@ impl Engine { }, "statistics.comment-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().comment_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64"); + request.statistics.as_mut().unwrap().comment_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64")); }, "statistics.view-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().view_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64"); + request.statistics.as_mut().unwrap().view_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64")); }, "statistics.favorite-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().favorite_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.favorite-count", "int64"); + request.statistics.as_mut().unwrap().favorite_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.favorite-count", "int64")); }, "statistics.dislike-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().dislike_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.dislike-count", "int64"); + request.statistics.as_mut().unwrap().dislike_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.dislike-count", "int64")); }, "statistics.like-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().like_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.like-count", "int64"); + request.statistics.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.like-count", "int64")); }, "content-details.definition" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().definition = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().definition = Some(value.unwrap_or("").to_string()); }, "content-details.country-restriction.exception" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().country_restriction.exception.push(value.unwrap_or("").to_string()); + request_content_details_country_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception.is_none() { + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception = Some(Default::default()); + } + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.country-restriction.allowed" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().country_restriction.allowed = arg_from_str(value.unwrap_or("false"), err, "content-details.country-restriction.allowed", "boolean"); + request_content_details_country_restriction_init(&mut request); + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().allowed = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.country-restriction.allowed", "boolean")); }, "content-details.content-rating.yt-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.yt_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().yt_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.catvfr-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.catvfr_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().catvfr_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cbfc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cbfc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cbfc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bfvc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bfvc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bfvc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mda-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mda_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mda_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.acb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.acb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().acb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nfvcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nfvcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nfvcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bmukk-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bmukk_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bmukk_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.chfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.chfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().chfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.resorteviolencia-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.resorteviolencia_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().resorteviolencia_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.csa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.csa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().csa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.moctw-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.moctw_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().moctw_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.anatel-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.anatel_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().anatel_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.catv-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.catv_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().catv_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.pefilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.pefilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().pefilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.djctq-rating-reasons" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.djctq_rating_reasons.push(value.unwrap_or("").to_string()); + request_content_details_content_rating_init(&mut request); + if request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons.is_none() { + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons = Some(Default::default()); + } + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.content-rating.incaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.incaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().incaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.oflc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.oflc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().oflc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fpb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fpb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fpb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mccaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mccaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mccaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.tvpg-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.tvpg_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().tvpg_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rtc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rtc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rtc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cscf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cscf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cscf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fsk-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fsk_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fsk_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bbfc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bbfc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bbfc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kmrb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kmrb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kmrb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.smsa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.smsa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().smsa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.egfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.egfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().egfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cicf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cicf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cicf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nbcpl-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nbcpl_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nbcpl_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nbc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nbc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nbc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.djctq-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.djctq_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ifco-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ifco_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ifco_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fco-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fco_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fco_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.eefilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.eefilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().eefilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.medietilsynet-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.medietilsynet_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().medietilsynet_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.grfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.grfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().grfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ccc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ccc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ccc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rte-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rte_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rte_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.czfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.czfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().czfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.lsf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.lsf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().lsf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fmoc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fmoc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fmoc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.eirin-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.eirin_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().eirin_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cce-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cce_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cce_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nkclv-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nkclv_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nkclv_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mtrcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mtrcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mtrcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mibac-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mibac_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mibac_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ilfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ilfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ilfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.smais-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.smais_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().smais_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.russia-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.russia_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().russia_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mpaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mpaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mpaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kfcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kfcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kfcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.agcom-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.agcom_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().agcom_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.chvrs-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.chvrs_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().chvrs_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cna-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cna_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cna_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.icaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.icaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().icaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mccyp-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mccyp_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mccyp_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nfrc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nfrc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nfrc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.skfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.skfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().skfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.moc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.moc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().moc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rcnof-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rcnof_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rcnof_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.meku-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.meku_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().meku_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fcbm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fcbm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fcbm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kijkwijzer-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kijkwijzer_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kijkwijzer_rating = Some(value.unwrap_or("").to_string()); }, "content-details.caption" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().caption = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().caption = Some(value.unwrap_or("").to_string()); }, "content-details.region-restriction.blocked" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().region_restriction.blocked.push(value.unwrap_or("").to_string()); + request_content_details_region_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked.is_none() { + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked = Some(Default::default()); + } + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.region-restriction.allowed" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().region_restriction.allowed.push(value.unwrap_or("").to_string()); + request_content_details_region_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed.is_none() { + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed = Some(Default::default()); + } + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.duration" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().duration = value.unwrap_or("").to_string(); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "content-details.licensed-content" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().licensed_content = arg_from_str(value.unwrap_or("false"), err, "content-details.licensed-content", "boolean"); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().licensed_content = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.licensed-content", "boolean")); }, "content-details.dimension" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "monetization-details.access.exception" => { - request_monetization_details_init(&mut request); - request.monetization_details.as_mut().unwrap().access.exception.push(value.unwrap_or("").to_string()); + request_monetization_details_access_init(&mut request); + if request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception.is_none() { + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception = Some(Default::default()); + } + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "monetization-details.access.allowed" => { - request_monetization_details_init(&mut request); - request.monetization_details.as_mut().unwrap().access.allowed = arg_from_str(value.unwrap_or("false"), err, "monetization-details.access.allowed", "boolean"); + request_monetization_details_access_init(&mut request); + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().allowed = Some(arg_from_str(value.unwrap_or("false"), err, "monetization-details.access.allowed", "boolean")); }, "age-gating.restricted" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "age-gating.restricted", "boolean"); + request.age_gating.as_mut().unwrap().restricted = Some(arg_from_str(value.unwrap_or("false"), err, "age-gating.restricted", "boolean")); }, "age-gating.alcohol-content" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().alcohol_content = arg_from_str(value.unwrap_or("false"), err, "age-gating.alcohol-content", "boolean"); + request.age_gating.as_mut().unwrap().alcohol_content = Some(arg_from_str(value.unwrap_or("false"), err, "age-gating.alcohol-content", "boolean")); }, "age-gating.video-game-rating" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().video_game_rating = value.unwrap_or("").to_string(); + request.age_gating.as_mut().unwrap().video_game_rating = Some(value.unwrap_or("").to_string()); }, "suggestions.processing-errors" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_errors.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_errors.is_none() { + request.suggestions.as_mut().unwrap().processing_errors = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_errors.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.editor-suggestions" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().editor_suggestions.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().editor_suggestions.is_none() { + request.suggestions.as_mut().unwrap().editor_suggestions = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().editor_suggestions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.processing-warnings" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_warnings.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_warnings.is_none() { + request.suggestions.as_mut().unwrap().processing_warnings = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_warnings.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.processing-hints" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_hints.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_hints.is_none() { + request.suggestions.as_mut().unwrap().processing_hints = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_hints.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "live-streaming-details.concurrent-viewers" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().concurrent_viewers = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().concurrent_viewers = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.scheduled-start-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().scheduled_start_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().scheduled_start_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.scheduled-end-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().scheduled_end_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().scheduled_end_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.actual-start-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().actual_start_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().actual_start_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.actual-end-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().actual_end_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().actual_end_time = Some(value.unwrap_or("").to_string()); }, "file-details.bitrate-bps" => { request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().bitrate_bps = value.unwrap_or("").to_string(); + request.file_details.as_mut().unwrap().bitrate_bps = Some(value.unwrap_or("").to_string()); }, "file-details.container" => { request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().container = value.unwrap_or("").to_string(); + request.file_details.as_mut().unwrap().container = Some(value.unwrap_or("").to_string()); }, "file-details.recording-location.latitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.latitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.latitude", "number")); }, "file-details.recording-location.altitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.altitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().altitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.altitude", "number")); }, "file-details.recording-location.longitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.longitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.longitude", "number")); }, "file-details.file-type" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_type = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_type = Some(value.unwrap_or("").to_string()); }, "file-details.creation-time" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().creation_time = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().creation_time = Some(value.unwrap_or("").to_string()); }, "file-details.duration-ms" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().duration_ms = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().duration_ms = Some(value.unwrap_or("").to_string()); }, "file-details.file-name" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_name = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_name = Some(value.unwrap_or("").to_string()); }, "file-details.file-size" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_size = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_size = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.tags" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.snippet.as_mut().unwrap().tags.is_none() { + request.snippet.as_mut().unwrap().tags = Some(Default::default()); + } + request.snippet.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.live-broadcast-content" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().live_broadcast_content = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().live_broadcast_content = Some(value.unwrap_or("").to_string()); }, "snippet.default-language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.category-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().category_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().category_id = Some(value.unwrap_or("").to_string()); }, "snippet.localized.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "player.embed-html" => { request_player_init(&mut request); - request.player.as_mut().unwrap().embed_html = value.unwrap_or("").to_string(); + request.player.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "processing-details.file-details-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().file_details_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().file_details_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.editor-suggestions-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().editor_suggestions_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().editor_suggestions_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-status" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_status = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_status = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-issues-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_issues_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_issues_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-failure-reason" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_failure_reason = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_failure_reason = Some(value.unwrap_or("").to_string()); }, "processing-details.thumbnails-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().thumbnails_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().thumbnails_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.time-left-ms" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.time_left_ms = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().time_left_ms = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.parts-processed" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.parts_processed = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().parts_processed = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.parts-total" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.parts_total = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().parts_total = Some(value.unwrap_or("").to_string()); }, "processing-details.tag-suggestions-availability" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().tag_suggestions_availability = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().tag_suggestions_availability = Some(value.unwrap_or("").to_string()); }, "etag" => { request_processing_details_init(&mut request); @@ -5831,27 +7804,30 @@ impl Engine { }, "project-details.tags" => { request_project_details_init(&mut request); - request.project_details.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.project_details.as_mut().unwrap().tags.is_none() { + request.project_details.as_mut().unwrap().tags = Some(Default::default()); + } + request.project_details.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "recording-details.recording-date" => { request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().recording_date = value.unwrap_or("").to_string(); + request.recording_details.as_mut().unwrap().recording_date = Some(value.unwrap_or("").to_string()); }, "recording-details.location-description" => { request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location_description = value.unwrap_or("").to_string(); + request.recording_details.as_mut().unwrap().location_description = Some(value.unwrap_or("").to_string()); }, "recording-details.location.latitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.latitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.latitude", "number")); }, "recording-details.location.altitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.altitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().altitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.altitude", "number")); }, "recording-details.location.longitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.longitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.longitude", "number")); }, "id" => { request_recording_details_init(&mut request); @@ -5884,8 +7860,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5896,7 +7871,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.videos().list(&self.opt.arg_part); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "video-category-id" => { call = call.video_category_id(value.unwrap_or("")); @@ -5958,8 +7933,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -5970,7 +7944,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.videos().rate(&self.opt.arg_id, &self.opt.arg_rating); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -6004,19 +7978,18 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } } } - fn _videos_update(&self, dry_run: bool, err: &mut InvalidOptionsError) + fn _videos_report_abuse(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Video = Default::default(); - let mut call = self.hub.videos().update(&request); + 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); + 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("")); @@ -6039,9 +8012,83 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + 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()[..] { + "secondary-reason-id" => { + request.secondary_reason_id = Some(value.unwrap_or("").to_string()); + }, + "reason-id" => { + request.reason_id = Some(value.unwrap_or("").to_string()); + }, + "language" => { + request.language = Some(value.unwrap_or("").to_string()); + }, + "comments" => { + request.comments = Some(value.unwrap_or("").to_string()); + }, + "video-id" => { + request.video_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); + 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); + 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(); + 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); } @@ -6051,24 +8098,59 @@ impl Engine { } } + fn request_content_details_content_rating_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().content_rating.is_none() { + request.content_details.as_mut().unwrap().content_rating = Some(Default::default()); + } + } + + fn request_content_details_country_restriction_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().country_restriction.is_none() { + request.content_details.as_mut().unwrap().country_restriction = Some(Default::default()); + } + } + fn request_content_details_init(request: &mut api::Video) { if request.content_details.is_none() { request.content_details = Some(Default::default()); } } + fn request_content_details_region_restriction_init(request: &mut api::Video) { + request_content_details_init(request); + if request.content_details.as_mut().unwrap().region_restriction.is_none() { + request.content_details.as_mut().unwrap().region_restriction = Some(Default::default()); + } + } + fn request_file_details_init(request: &mut api::Video) { if request.file_details.is_none() { request.file_details = Some(Default::default()); } } + fn request_file_details_recording_location_init(request: &mut api::Video) { + request_file_details_init(request); + if request.file_details.as_mut().unwrap().recording_location.is_none() { + request.file_details.as_mut().unwrap().recording_location = Some(Default::default()); + } + } + fn request_live_streaming_details_init(request: &mut api::Video) { if request.live_streaming_details.is_none() { request.live_streaming_details = Some(Default::default()); } } + fn request_monetization_details_access_init(request: &mut api::Video) { + request_monetization_details_init(request); + if request.monetization_details.as_mut().unwrap().access.is_none() { + request.monetization_details.as_mut().unwrap().access = Some(Default::default()); + } + } + fn request_monetization_details_init(request: &mut api::Video) { if request.monetization_details.is_none() { request.monetization_details = Some(Default::default()); @@ -6087,6 +8169,13 @@ impl Engine { } } + fn request_processing_details_processing_progress_init(request: &mut api::Video) { + request_processing_details_init(request); + if request.processing_details.as_mut().unwrap().processing_progress.is_none() { + request.processing_details.as_mut().unwrap().processing_progress = Some(Default::default()); + } + } + fn request_project_details_init(request: &mut api::Video) { if request.project_details.is_none() { request.project_details = Some(Default::default()); @@ -6099,12 +8188,68 @@ impl Engine { } } + fn request_recording_details_location_init(request: &mut api::Video) { + request_recording_details_init(request); + if request.recording_details.as_mut().unwrap().location.is_none() { + request.recording_details.as_mut().unwrap().location = Some(Default::default()); + } + } + fn request_snippet_init(request: &mut api::Video) { if request.snippet.is_none() { request.snippet = Some(Default::default()); } } + fn request_snippet_localized_init(request: &mut api::Video) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().localized.is_none() { + request.snippet.as_mut().unwrap().localized = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_default_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_high_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_init(request: &mut api::Video) { + request_snippet_init(request); + if request.snippet.as_mut().unwrap().thumbnails.is_none() { + request.snippet.as_mut().unwrap().thumbnails = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_maxres_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_medium_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium = Some(Default::default()); + } + } + + fn request_snippet_thumbnails_standard_init(request: &mut api::Video) { + request_snippet_thumbnails_init(request); + if request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.is_none() { + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard = Some(Default::default()); + } + } + fn request_statistics_init(request: &mut api::Video) { if request.statistics.is_none() { request.statistics = Some(Default::default()); @@ -6132,43 +8277,49 @@ impl Engine { match &field_name.to_string()[..] { "status.license" => { request_status_init(&mut request); - request.status.as_mut().unwrap().license = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().license = Some(value.unwrap_or("").to_string()); }, "status.embeddable" => { request_status_init(&mut request); - request.status.as_mut().unwrap().embeddable = arg_from_str(value.unwrap_or("false"), err, "status.embeddable", "boolean"); + request.status.as_mut().unwrap().embeddable = Some(arg_from_str(value.unwrap_or("false"), err, "status.embeddable", "boolean")); }, "status.privacy-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().privacy_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().privacy_status = Some(value.unwrap_or("").to_string()); }, "status.publish-at" => { request_status_init(&mut request); - request.status.as_mut().unwrap().publish_at = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().publish_at = Some(value.unwrap_or("").to_string()); }, "status.public-stats-viewable" => { request_status_init(&mut request); - request.status.as_mut().unwrap().public_stats_viewable = arg_from_str(value.unwrap_or("false"), err, "status.public-stats-viewable", "boolean"); + request.status.as_mut().unwrap().public_stats_viewable = Some(arg_from_str(value.unwrap_or("false"), err, "status.public-stats-viewable", "boolean")); }, "status.upload-status" => { request_status_init(&mut request); - request.status.as_mut().unwrap().upload_status = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().upload_status = Some(value.unwrap_or("").to_string()); }, "status.rejection-reason" => { request_status_init(&mut request); - request.status.as_mut().unwrap().rejection_reason = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().rejection_reason = Some(value.unwrap_or("").to_string()); }, "status.failure-reason" => { request_status_init(&mut request); - request.status.as_mut().unwrap().failure_reason = value.unwrap_or("").to_string(); + request.status.as_mut().unwrap().failure_reason = Some(value.unwrap_or("").to_string()); }, "topic-details.topic-ids" => { request_topic_details_init(&mut request); - request.topic_details.as_mut().unwrap().topic_ids.push(value.unwrap_or("").to_string()); + if request.topic_details.as_mut().unwrap().topic_ids.is_none() { + request.topic_details.as_mut().unwrap().topic_ids = Some(Default::default()); + } + request.topic_details.as_mut().unwrap().topic_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "topic-details.relevant-topic-ids" => { request_topic_details_init(&mut request); - request.topic_details.as_mut().unwrap().relevant_topic_ids.push(value.unwrap_or("").to_string()); + if request.topic_details.as_mut().unwrap().relevant_topic_ids.is_none() { + request.topic_details.as_mut().unwrap().relevant_topic_ids = Some(Default::default()); + } + request.topic_details.as_mut().unwrap().relevant_topic_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "kind" => { request_topic_details_init(&mut request); @@ -6176,559 +8327,589 @@ impl Engine { }, "statistics.comment-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().comment_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64"); + request.statistics.as_mut().unwrap().comment_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.comment-count", "int64")); }, "statistics.view-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().view_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64"); + request.statistics.as_mut().unwrap().view_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.view-count", "int64")); }, "statistics.favorite-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().favorite_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.favorite-count", "int64"); + request.statistics.as_mut().unwrap().favorite_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.favorite-count", "int64")); }, "statistics.dislike-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().dislike_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.dislike-count", "int64"); + request.statistics.as_mut().unwrap().dislike_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.dislike-count", "int64")); }, "statistics.like-count" => { request_statistics_init(&mut request); - request.statistics.as_mut().unwrap().like_count = arg_from_str(value.unwrap_or("-0"), err, "statistics.like-count", "int64"); + request.statistics.as_mut().unwrap().like_count = Some(arg_from_str(value.unwrap_or("-0"), err, "statistics.like-count", "int64")); }, "content-details.definition" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().definition = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().definition = Some(value.unwrap_or("").to_string()); }, "content-details.country-restriction.exception" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().country_restriction.exception.push(value.unwrap_or("").to_string()); + request_content_details_country_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception.is_none() { + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception = Some(Default::default()); + } + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().exception.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.country-restriction.allowed" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().country_restriction.allowed = arg_from_str(value.unwrap_or("false"), err, "content-details.country-restriction.allowed", "boolean"); + request_content_details_country_restriction_init(&mut request); + request.content_details.as_mut().unwrap().country_restriction.as_mut().unwrap().allowed = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.country-restriction.allowed", "boolean")); }, "content-details.content-rating.yt-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.yt_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().yt_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.catvfr-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.catvfr_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().catvfr_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cbfc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cbfc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cbfc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bfvc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bfvc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bfvc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mda-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mda_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mda_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.acb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.acb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().acb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nfvcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nfvcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nfvcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bmukk-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bmukk_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bmukk_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.chfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.chfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().chfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.resorteviolencia-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.resorteviolencia_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().resorteviolencia_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.csa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.csa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().csa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.moctw-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.moctw_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().moctw_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.anatel-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.anatel_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().anatel_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.catv-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.catv_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().catv_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.pefilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.pefilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().pefilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.djctq-rating-reasons" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.djctq_rating_reasons.push(value.unwrap_or("").to_string()); + request_content_details_content_rating_init(&mut request); + if request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons.is_none() { + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons = Some(Default::default()); + } + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating_reasons.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.content-rating.incaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.incaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().incaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.oflc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.oflc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().oflc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fpb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fpb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fpb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mccaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mccaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mccaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.tvpg-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.tvpg_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().tvpg_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rtc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rtc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rtc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cscf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cscf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cscf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fsk-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fsk_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fsk_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.bbfc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.bbfc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().bbfc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kmrb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kmrb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kmrb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.smsa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.smsa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().smsa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.egfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.egfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().egfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cicf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cicf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cicf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nbcpl-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nbcpl_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nbcpl_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nbc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nbc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nbc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.djctq-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.djctq_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().djctq_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ifco-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ifco_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ifco_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fco-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fco_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fco_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.eefilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.eefilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().eefilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.medietilsynet-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.medietilsynet_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().medietilsynet_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.grfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.grfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().grfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ccc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ccc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ccc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rte-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rte_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rte_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.czfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.czfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().czfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.lsf-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.lsf_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().lsf_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fmoc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fmoc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fmoc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.eirin-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.eirin_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().eirin_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cce-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cce_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cce_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nkclv-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nkclv_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nkclv_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mtrcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mtrcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mtrcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mibac-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mibac_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mibac_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.ilfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.ilfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().ilfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.smais-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.smais_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().smais_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.russia-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.russia_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().russia_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mpaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mpaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mpaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kfcb-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kfcb_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kfcb_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.agcom-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.agcom_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().agcom_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.chvrs-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.chvrs_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().chvrs_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.cna-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.cna_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().cna_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.icaa-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.icaa_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().icaa_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.mccyp-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.mccyp_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().mccyp_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.nfrc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.nfrc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().nfrc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.skfilm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.skfilm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().skfilm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.moc-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.moc_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().moc_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.rcnof-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.rcnof_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().rcnof_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.meku-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.meku_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().meku_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.fcbm-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.fcbm_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().fcbm_rating = Some(value.unwrap_or("").to_string()); }, "content-details.content-rating.kijkwijzer-rating" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().content_rating.kijkwijzer_rating = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().content_rating.as_mut().unwrap().kijkwijzer_rating = Some(value.unwrap_or("").to_string()); }, "content-details.caption" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().caption = value.unwrap_or("").to_string(); + request_content_details_content_rating_init(&mut request); + request.content_details.as_mut().unwrap().caption = Some(value.unwrap_or("").to_string()); }, "content-details.region-restriction.blocked" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().region_restriction.blocked.push(value.unwrap_or("").to_string()); + request_content_details_region_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked.is_none() { + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked = Some(Default::default()); + } + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().blocked.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.region-restriction.allowed" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().region_restriction.allowed.push(value.unwrap_or("").to_string()); + request_content_details_region_restriction_init(&mut request); + if request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed.is_none() { + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed = Some(Default::default()); + } + request.content_details.as_mut().unwrap().region_restriction.as_mut().unwrap().allowed.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "content-details.duration" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().duration = value.unwrap_or("").to_string(); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().duration = Some(value.unwrap_or("").to_string()); }, "content-details.licensed-content" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().licensed_content = arg_from_str(value.unwrap_or("false"), err, "content-details.licensed-content", "boolean"); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().licensed_content = Some(arg_from_str(value.unwrap_or("false"), err, "content-details.licensed-content", "boolean")); }, "content-details.dimension" => { - request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().dimension = value.unwrap_or("").to_string(); + request_content_details_region_restriction_init(&mut request); + request.content_details.as_mut().unwrap().dimension = Some(value.unwrap_or("").to_string()); }, "monetization-details.access.exception" => { - request_monetization_details_init(&mut request); - request.monetization_details.as_mut().unwrap().access.exception.push(value.unwrap_or("").to_string()); + request_monetization_details_access_init(&mut request); + if request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception.is_none() { + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception = Some(Default::default()); + } + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().exception.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "monetization-details.access.allowed" => { - request_monetization_details_init(&mut request); - request.monetization_details.as_mut().unwrap().access.allowed = arg_from_str(value.unwrap_or("false"), err, "monetization-details.access.allowed", "boolean"); + request_monetization_details_access_init(&mut request); + request.monetization_details.as_mut().unwrap().access.as_mut().unwrap().allowed = Some(arg_from_str(value.unwrap_or("false"), err, "monetization-details.access.allowed", "boolean")); }, "age-gating.restricted" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().restricted = arg_from_str(value.unwrap_or("false"), err, "age-gating.restricted", "boolean"); + request.age_gating.as_mut().unwrap().restricted = Some(arg_from_str(value.unwrap_or("false"), err, "age-gating.restricted", "boolean")); }, "age-gating.alcohol-content" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().alcohol_content = arg_from_str(value.unwrap_or("false"), err, "age-gating.alcohol-content", "boolean"); + request.age_gating.as_mut().unwrap().alcohol_content = Some(arg_from_str(value.unwrap_or("false"), err, "age-gating.alcohol-content", "boolean")); }, "age-gating.video-game-rating" => { request_age_gating_init(&mut request); - request.age_gating.as_mut().unwrap().video_game_rating = value.unwrap_or("").to_string(); + request.age_gating.as_mut().unwrap().video_game_rating = Some(value.unwrap_or("").to_string()); }, "suggestions.processing-errors" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_errors.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_errors.is_none() { + request.suggestions.as_mut().unwrap().processing_errors = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_errors.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.editor-suggestions" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().editor_suggestions.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().editor_suggestions.is_none() { + request.suggestions.as_mut().unwrap().editor_suggestions = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().editor_suggestions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.processing-warnings" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_warnings.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_warnings.is_none() { + request.suggestions.as_mut().unwrap().processing_warnings = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_warnings.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "suggestions.processing-hints" => { request_suggestions_init(&mut request); - request.suggestions.as_mut().unwrap().processing_hints.push(value.unwrap_or("").to_string()); + if request.suggestions.as_mut().unwrap().processing_hints.is_none() { + request.suggestions.as_mut().unwrap().processing_hints = Some(Default::default()); + } + request.suggestions.as_mut().unwrap().processing_hints.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "live-streaming-details.concurrent-viewers" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().concurrent_viewers = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().concurrent_viewers = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.scheduled-start-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().scheduled_start_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().scheduled_start_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.scheduled-end-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().scheduled_end_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().scheduled_end_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.actual-start-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().actual_start_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().actual_start_time = Some(value.unwrap_or("").to_string()); }, "live-streaming-details.actual-end-time" => { request_live_streaming_details_init(&mut request); - request.live_streaming_details.as_mut().unwrap().actual_end_time = value.unwrap_or("").to_string(); + request.live_streaming_details.as_mut().unwrap().actual_end_time = Some(value.unwrap_or("").to_string()); }, "file-details.bitrate-bps" => { request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().bitrate_bps = value.unwrap_or("").to_string(); + request.file_details.as_mut().unwrap().bitrate_bps = Some(value.unwrap_or("").to_string()); }, "file-details.container" => { request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().container = value.unwrap_or("").to_string(); + request.file_details.as_mut().unwrap().container = Some(value.unwrap_or("").to_string()); }, "file-details.recording-location.latitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.latitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.latitude", "number")); }, "file-details.recording-location.altitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.altitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().altitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.altitude", "number")); }, "file-details.recording-location.longitude" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().recording_location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.longitude", "number"); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().recording_location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "file-details.recording-location.longitude", "number")); }, "file-details.file-type" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_type = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_type = Some(value.unwrap_or("").to_string()); }, "file-details.creation-time" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().creation_time = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().creation_time = Some(value.unwrap_or("").to_string()); }, "file-details.duration-ms" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().duration_ms = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().duration_ms = Some(value.unwrap_or("").to_string()); }, "file-details.file-name" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_name = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_name = Some(value.unwrap_or("").to_string()); }, "file-details.file-size" => { - request_file_details_init(&mut request); - request.file_details.as_mut().unwrap().file_size = value.unwrap_or("").to_string(); + request_file_details_recording_location_init(&mut request); + request.file_details.as_mut().unwrap().file_size = Some(value.unwrap_or("").to_string()); }, "snippet.description" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().description = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.tags" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.snippet.as_mut().unwrap().tags.is_none() { + request.snippet.as_mut().unwrap().tags = Some(Default::default()); + } + request.snippet.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "snippet.channel-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_id = Some(value.unwrap_or("").to_string()); }, "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.live-broadcast-content" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().live_broadcast_content = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().live_broadcast_content = Some(value.unwrap_or("").to_string()); }, "snippet.default-language" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().default_language = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().default_language = Some(value.unwrap_or("").to_string()); }, "snippet.channel-title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().channel_title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().channel_title = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.category-id" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().category_id = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().category_id = Some(value.unwrap_or("").to_string()); }, "snippet.localized.description" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.description = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().description = Some(value.unwrap_or("").to_string()); }, "snippet.localized.title" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().localized.title = value.unwrap_or("").to_string(); + request_snippet_localized_init(&mut request); + request.snippet.as_mut().unwrap().localized.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.default.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.url = Some(value.unwrap_or("").to_string()); + 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()); }, "snippet.thumbnails.default.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.width", "integer")); }, "snippet.thumbnails.default.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.default.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); + request_snippet_thumbnails_default_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().default.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.default.height", "integer")); }, "snippet.thumbnails.high.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.high.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.width", "integer")); }, "snippet.thumbnails.high.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.high.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); + request_snippet_thumbnails_high_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().high.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.high.height", "integer")); }, "snippet.thumbnails.medium.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.medium.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.width", "integer")); }, "snippet.thumbnails.medium.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.medium.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); + request_snippet_thumbnails_medium_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().medium.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.medium.height", "integer")); }, "snippet.thumbnails.maxres.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.maxres.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.width", "integer")); }, "snippet.thumbnails.maxres.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.maxres.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); + request_snippet_thumbnails_maxres_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().maxres.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.maxres.height", "integer")); }, "snippet.thumbnails.standard.url" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.url = Some(value.unwrap_or("").to_string()); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().url = Some(value.unwrap_or("").to_string()); }, "snippet.thumbnails.standard.width" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().width = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.width", "integer")); }, "snippet.thumbnails.standard.height" => { - request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().thumbnails.standard.height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); + request_snippet_thumbnails_standard_init(&mut request); + request.snippet.as_mut().unwrap().thumbnails.as_mut().unwrap().standard.as_mut().unwrap().height = Some(arg_from_str(value.unwrap_or("-0"), err, "snippet.thumbnails.standard.height", "integer")); }, "player.embed-html" => { request_player_init(&mut request); - request.player.as_mut().unwrap().embed_html = value.unwrap_or("").to_string(); + request.player.as_mut().unwrap().embed_html = Some(value.unwrap_or("").to_string()); }, "processing-details.file-details-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().file_details_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().file_details_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.editor-suggestions-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().editor_suggestions_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().editor_suggestions_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-status" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_status = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_status = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-issues-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_issues_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_issues_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-failure-reason" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_failure_reason = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().processing_failure_reason = Some(value.unwrap_or("").to_string()); }, "processing-details.thumbnails-availability" => { request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().thumbnails_availability = value.unwrap_or("").to_string(); + request.processing_details.as_mut().unwrap().thumbnails_availability = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.time-left-ms" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.time_left_ms = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().time_left_ms = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.parts-processed" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.parts_processed = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().parts_processed = Some(value.unwrap_or("").to_string()); }, "processing-details.processing-progress.parts-total" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().processing_progress.parts_total = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().processing_progress.as_mut().unwrap().parts_total = Some(value.unwrap_or("").to_string()); }, "processing-details.tag-suggestions-availability" => { - request_processing_details_init(&mut request); - request.processing_details.as_mut().unwrap().tag_suggestions_availability = value.unwrap_or("").to_string(); + request_processing_details_processing_progress_init(&mut request); + request.processing_details.as_mut().unwrap().tag_suggestions_availability = Some(value.unwrap_or("").to_string()); }, "etag" => { request_processing_details_init(&mut request); @@ -6736,27 +8917,30 @@ impl Engine { }, "project-details.tags" => { request_project_details_init(&mut request); - request.project_details.as_mut().unwrap().tags.push(value.unwrap_or("").to_string()); + if request.project_details.as_mut().unwrap().tags.is_none() { + request.project_details.as_mut().unwrap().tags = Some(Default::default()); + } + request.project_details.as_mut().unwrap().tags.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "recording-details.recording-date" => { request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().recording_date = value.unwrap_or("").to_string(); + request.recording_details.as_mut().unwrap().recording_date = Some(value.unwrap_or("").to_string()); }, "recording-details.location-description" => { request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location_description = value.unwrap_or("").to_string(); + request.recording_details.as_mut().unwrap().location_description = Some(value.unwrap_or("").to_string()); }, "recording-details.location.latitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.latitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.latitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().latitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.latitude", "number")); }, "recording-details.location.altitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.altitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.altitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().altitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.altitude", "number")); }, "recording-details.location.longitude" => { - request_recording_details_init(&mut request); - request.recording_details.as_mut().unwrap().location.longitude = arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.longitude", "number"); + request_recording_details_location_init(&mut request); + request.recording_details.as_mut().unwrap().location.as_mut().unwrap().longitude = Some(arg_from_str(value.unwrap_or("0.0"), err, "recording-details.location.longitude", "number")); }, "id" => { request_recording_details_init(&mut request); @@ -6779,8 +8963,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -6789,10 +8972,10 @@ impl Engine { fn _watermarks_set(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::InvideoBranding = Default::default(); + let mut request = api::InvideoBranding::default(); 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); + 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("")); @@ -6815,9 +8998,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -6839,11 +9023,11 @@ impl Engine { }, "position.corner-position" => { request_position_init(&mut request); - request.position.as_mut().unwrap().corner_position = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().corner_position = Some(value.unwrap_or("").to_string()); }, "position.type" => { request_position_init(&mut request); - request.position.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.position.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "image-url" => { request_position_init(&mut request); @@ -6851,15 +9035,15 @@ impl Engine { }, "timing.offset-ms" => { request_timing_init(&mut request); - request.timing.as_mut().unwrap().offset_ms = value.unwrap_or("").to_string(); + request.timing.as_mut().unwrap().offset_ms = Some(value.unwrap_or("").to_string()); }, "timing.type" => { request_timing_init(&mut request); - request.timing.as_mut().unwrap().type_ = value.unwrap_or("").to_string(); + request.timing.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "timing.duration-ms" => { request_timing_init(&mut request); - request.timing.as_mut().unwrap().duration_ms = value.unwrap_or("").to_string(); + request.timing.as_mut().unwrap().duration_ms = Some(value.unwrap_or("").to_string()); }, "image-bytes" => { request_timing_init(&mut request); @@ -6891,7 +9075,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -6902,7 +9085,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.watermarks().unset(&self.opt.arg_channel_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -6936,7 +9119,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -6956,7 +9138,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_captions { + } + else if self.opt.cmd_captions { if self.opt.cmd_delete { call_result = self._captions_delete(dry_run, &mut err); } else if self.opt.cmd_download { @@ -6970,13 +9153,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_channel_banners { + } + else if self.opt.cmd_channel_banners { if self.opt.cmd_insert { call_result = self._channel_banners_insert(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_channel_sections { + } + else if self.opt.cmd_channel_sections { if self.opt.cmd_delete { call_result = self._channel_sections_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -6988,7 +9173,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_channels { + } + else if self.opt.cmd_channels { if self.opt.cmd_list { call_result = self._channels_list(dry_run, &mut err); } else if self.opt.cmd_update { @@ -6996,25 +9182,57 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_guide_categories { + } + else if self.opt.cmd_comment_threads { + if self.opt.cmd_insert { + call_result = self._comment_threads_insert(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._comment_threads_list(dry_run, &mut err); + } else if self.opt.cmd_update { + call_result = self._comment_threads_update(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_comments { + if self.opt.cmd_delete { + call_result = self._comments_delete(dry_run, &mut err); + } else if self.opt.cmd_insert { + call_result = self._comments_insert(dry_run, &mut err); + } else if self.opt.cmd_list { + call_result = self._comments_list(dry_run, &mut err); + } else if self.opt.cmd_mark_as_spam { + call_result = self._comments_mark_as_spam(dry_run, &mut err); + } else if self.opt.cmd_set_moderation_status { + call_result = self._comments_set_moderation_status(dry_run, &mut err); + } else if self.opt.cmd_update { + call_result = self._comments_update(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_guide_categories { if self.opt.cmd_list { call_result = self._guide_categories_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_i18n_languages { + } + else if self.opt.cmd_i18n_languages { if self.opt.cmd_list { call_result = self._i18n_languages_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_i18n_regions { + } + else if self.opt.cmd_i18n_regions { if self.opt.cmd_list { call_result = self._i18n_regions_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_live_broadcasts { + } + else if self.opt.cmd_live_broadcasts { if self.opt.cmd_bind { call_result = self._live_broadcasts_bind(dry_run, &mut err); } else if self.opt.cmd_control { @@ -7032,7 +9250,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_live_streams { + } + else if self.opt.cmd_live_streams { if self.opt.cmd_delete { call_result = self._live_streams_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -7044,7 +9263,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_playlist_items { + } + else if self.opt.cmd_playlist_items { if self.opt.cmd_delete { call_result = self._playlist_items_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -7056,7 +9276,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_playlists { + } + else if self.opt.cmd_playlists { if self.opt.cmd_delete { call_result = self._playlists_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -7068,13 +9289,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_search { + } + else if self.opt.cmd_search { if self.opt.cmd_list { call_result = self._search_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_subscriptions { + } + else if self.opt.cmd_subscriptions { if self.opt.cmd_delete { call_result = self._subscriptions_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -7084,19 +9307,29 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_thumbnails { + } + else if self.opt.cmd_thumbnails { if self.opt.cmd_set { call_result = self._thumbnails_set(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_video_categories { + } + else if self.opt.cmd_video_abuse_report_reasons { + if self.opt.cmd_list { + call_result = self._video_abuse_report_reasons_list(dry_run, &mut err); + } else { + unreachable!(); + } + } + else if self.opt.cmd_video_categories { if self.opt.cmd_list { call_result = self._video_categories_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_videos { + } + else if self.opt.cmd_videos { if self.opt.cmd_delete { call_result = self._videos_delete(dry_run, &mut err); } else if self.opt.cmd_get_rating { @@ -7107,12 +9340,15 @@ impl Engine { call_result = self._videos_list(dry_run, &mut err); } else if self.opt.cmd_rate { call_result = self._videos_rate(dry_run, &mut err); + } else if self.opt.cmd_report_abuse { + call_result = self._videos_report_abuse(dry_run, &mut err); } else if self.opt.cmd_update { call_result = self._videos_update(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_watermarks { + } + else if self.opt.cmd_watermarks { if self.opt.cmd_set { call_result = self._watermarks_set(dry_run, &mut err); } else if self.opt.cmd_unset { @@ -7140,21 +9376,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "youtube3-secret.json") { + 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\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "youtube3", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "youtube3", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::YouTube::new(hyper::Client::new(), auth), + hub: api::YouTube::new(client, auth), }; match engine._doit(true) { @@ -7174,12 +9426,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/youtube3/README.md b/gen/youtube3/README.md index 40f9f1d92b..24df832a77 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+20150327*, where *20150327* 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.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*. Everything else about the *YouTube* *v3* API can be found at the [official documentation site](https://developers.google.com/youtube/v3). @@ -23,6 +23,10 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*delete*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelSectionDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelSectionInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelSectionListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelSectionUpdateCall.html) * [channels](http://byron.github.io/google-apis-rs/google_youtube3/struct.Channel.html) * [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ChannelUpdateCall.html) +* [comment threads](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentThread.html) + * [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentThreadInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentThreadListCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentThreadUpdateCall.html) +* [comments](http://byron.github.io/google-apis-rs/google_youtube3/struct.Comment.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentListCall.html), [*mark as spam*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentMarkAsSpamCall.html), [*set moderation status*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentSetModerationStatuCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.CommentUpdateCall.html) * [guide categories](http://byron.github.io/google-apis-rs/google_youtube3/struct.GuideCategory.html) * [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.GuideCategoryListCall.html) * [i18n languages](http://byron.github.io/google-apis-rs/google_youtube3/struct.I18nLanguage.html) @@ -43,10 +47,12 @@ Handle the following *Resources* with ease from the central [hub](http://byron.g * [*delete*](http://byron.github.io/google-apis-rs/google_youtube3/struct.SubscriptionDeleteCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.SubscriptionInsertCall.html) and [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.SubscriptionListCall.html) * [thumbnails](http://byron.github.io/google-apis-rs/google_youtube3/struct.Thumbnail.html) * [*set*](http://byron.github.io/google-apis-rs/google_youtube3/struct.ThumbnailSetCall.html) +* [video abuse report reasons](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoAbuseReportReason.html) + * [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoAbuseReportReasonListCall.html) * [video categories](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoCategory.html) * [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoCategoryListCall.html) * [videos](http://byron.github.io/google-apis-rs/google_youtube3/struct.Video.html) - * [*delete*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoDeleteCall.html), [*get rating*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoGetRatingCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoListCall.html), [*rate*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoRateCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoUpdateCall.html) + * [*delete*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoDeleteCall.html), [*get rating*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoGetRatingCall.html), [*insert*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoInsertCall.html), [*list*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoListCall.html), [*rate*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoRateCall.html), [*report abuse*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoReportAbuseCall.html) and [*update*](http://byron.github.io/google-apis-rs/google_youtube3/struct.VideoUpdateCall.html) * watermarks * [*set*](http://byron.github.io/google-apis-rs/google_youtube3/struct.WatermarkSetCall.html) and [*unset*](http://byron.github.io/google-apis-rs/google_youtube3/struct.WatermarkUnsetCall.html) @@ -98,13 +104,13 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.live_broadcasts().control(...).doit() -let r = hub.live_broadcasts().insert(...).doit() -let r = hub.live_broadcasts().list(...).doit() -let r = hub.live_broadcasts().transition(...).doit() -let r = hub.live_broadcasts().update(...).doit() -let r = hub.live_broadcasts().delete(...).doit() -let r = hub.live_broadcasts().bind(...).doit() +let r = hub.videos().rate(...).doit() +let r = hub.videos().report_abuse(...).doit() +let r = hub.videos().get_rating(...).doit() +let r = hub.videos().list(...).doit() +let r = hub.videos().insert(...).doit() +let r = hub.videos().update(...).doit() +let r = hub.videos().delete(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -149,14 +155,17 @@ let mut hub = YouTube::new(hyper::Client::new(), auth); // You can configure optional parameters by calling 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().list("part") - .page_token("sit") - .on_behalf_of_content_owner_channel("Stet") - .on_behalf_of_content_owner("sed") - .mine(false) - .max_results(83) - .id("kasd") - .broadcast_status("accusam") +let result = hub.videos().list("part") + .video_category_id("sit") + .region_code("Stet") + .page_token("sed") + .on_behalf_of_content_owner("et") + .my_rating("dolores") + .max_results(38) + .locale("accusam") + .id("takimata") + .hl("justo") + .chart("amet.") .doit(); match result { diff --git a/gen/youtube3/cargo.toml b/gen/youtube3/cargo.toml index 36e9c740ac..8ada608335 100644 --- a/gen/youtube3/cargo.toml +++ b/gen/youtube3/cargo.toml @@ -4,8 +4,8 @@ [package] name = "google-youtube3" -version = "0.1.5+20150327" -authors = ["Sebastian Thiel <byronimo@gmail>"] +version = "0.1.5+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" homepage = "https://developers.google.com/youtube/v3" diff --git a/gen/youtube3/src/cmn.rs b/gen/youtube3/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/youtube3/src/cmn.rs +++ b/gen/youtube3/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index 034c4b7ad0..ecf81a4bd7 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+20150327*, where *20150327* 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.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*. //! //! Everything else about the *YouTube* *v3* API can be found at the //! [official documentation site](https://developers.google.com/youtube/v3). @@ -21,6 +21,10 @@ //! * [*delete*](struct.ChannelSectionDeleteCall.html), [*insert*](struct.ChannelSectionInsertCall.html), [*list*](struct.ChannelSectionListCall.html) and [*update*](struct.ChannelSectionUpdateCall.html) //! * [channels](struct.Channel.html) //! * [*list*](struct.ChannelListCall.html) and [*update*](struct.ChannelUpdateCall.html) +//! * [comment threads](struct.CommentThread.html) +//! * [*insert*](struct.CommentThreadInsertCall.html), [*list*](struct.CommentThreadListCall.html) and [*update*](struct.CommentThreadUpdateCall.html) +//! * [comments](struct.Comment.html) +//! * [*delete*](struct.CommentDeleteCall.html), [*insert*](struct.CommentInsertCall.html), [*list*](struct.CommentListCall.html), [*mark as spam*](struct.CommentMarkAsSpamCall.html), [*set moderation status*](struct.CommentSetModerationStatuCall.html) and [*update*](struct.CommentUpdateCall.html) //! * [guide categories](struct.GuideCategory.html) //! * [*list*](struct.GuideCategoryListCall.html) //! * [i18n languages](struct.I18nLanguage.html) @@ -41,10 +45,12 @@ //! * [*delete*](struct.SubscriptionDeleteCall.html), [*insert*](struct.SubscriptionInsertCall.html) and [*list*](struct.SubscriptionListCall.html) //! * [thumbnails](struct.Thumbnail.html) //! * [*set*](struct.ThumbnailSetCall.html) +//! * [video abuse report reasons](struct.VideoAbuseReportReason.html) +//! * [*list*](struct.VideoAbuseReportReasonListCall.html) //! * [video categories](struct.VideoCategory.html) //! * [*list*](struct.VideoCategoryListCall.html) //! * [videos](struct.Video.html) -//! * [*delete*](struct.VideoDeleteCall.html), [*get rating*](struct.VideoGetRatingCall.html), [*insert*](struct.VideoInsertCall.html), [*list*](struct.VideoListCall.html), [*rate*](struct.VideoRateCall.html) and [*update*](struct.VideoUpdateCall.html) +//! * [*delete*](struct.VideoDeleteCall.html), [*get rating*](struct.VideoGetRatingCall.html), [*insert*](struct.VideoInsertCall.html), [*list*](struct.VideoListCall.html), [*rate*](struct.VideoRateCall.html), [*report abuse*](struct.VideoReportAbuseCall.html) and [*update*](struct.VideoUpdateCall.html) //! * watermarks //! * [*set*](struct.WatermarkSetCall.html) and [*unset*](struct.WatermarkUnsetCall.html) //! @@ -98,13 +104,13 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.live_broadcasts().control(...).doit() -//! let r = hub.live_broadcasts().insert(...).doit() -//! let r = hub.live_broadcasts().list(...).doit() -//! let r = hub.live_broadcasts().transition(...).doit() -//! let r = hub.live_broadcasts().update(...).doit() -//! let r = hub.live_broadcasts().delete(...).doit() -//! let r = hub.live_broadcasts().bind(...).doit() +//! let r = hub.videos().rate(...).doit() +//! let r = hub.videos().report_abuse(...).doit() +//! let r = hub.videos().get_rating(...).doit() +//! let r = hub.videos().list(...).doit() +//! let r = hub.videos().insert(...).doit() +//! let r = hub.videos().update(...).doit() +//! let r = hub.videos().delete(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -150,14 +156,17 @@ //! // You can configure optional parameters by calling 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().list("part") -//! .page_token("justo") -//! .on_behalf_of_content_owner_channel("amet.") -//! .on_behalf_of_content_owner("erat") -//! .mine(true) -//! .max_results(92) -//! .id("nonumy") -//! .broadcast_status("dolores") +//! let result = hub.videos().list("part") +//! .video_category_id("labore") +//! .region_code("sea") +//! .page_token("nonumy") +//! .on_behalf_of_content_owner("dolores") +//! .my_rating("gubergren") +//! .max_results(6) +//! .locale("aliquyam") +//! .id("ea") +//! .hl("no") +//! .chart("justo") //! .doit(); //! //! match result { @@ -346,14 +355,17 @@ 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.live_broadcasts().list("part") -/// .page_token("sadipscing") -/// .on_behalf_of_content_owner_channel("aliquyam") -/// .on_behalf_of_content_owner("ea") -/// .mine(false) +/// let result = hub.videos().list("part") +/// .video_category_id("et") +/// .region_code("et") +/// .page_token("diam") +/// .on_behalf_of_content_owner("ipsum") +/// .my_rating("Lorem") /// .max_results(80) -/// .id("justo") -/// .broadcast_status("et") +/// .locale("duo") +/// .id("aliquyam") +/// .hl("sea") +/// .chart("Lorem") /// .doit(); /// /// match result { @@ -407,6 +419,12 @@ impl<'a, C, A> YouTube<C, A> pub fn channels(&'a self) -> ChannelMethods<'a, C, A> { ChannelMethods { hub: &self } } + pub fn comment_threads(&'a self) -> CommentThreadMethods<'a, C, A> { + CommentThreadMethods { hub: &self } + } + pub fn comments(&'a self) -> CommentMethods<'a, C, A> { + CommentMethods { hub: &self } + } pub fn guide_categories(&'a self) -> GuideCategoryMethods<'a, C, A> { GuideCategoryMethods { hub: &self } } @@ -437,6 +455,9 @@ impl<'a, C, A> YouTube<C, A> pub fn thumbnails(&'a self) -> ThumbnailMethods<'a, C, A> { ThumbnailMethods { hub: &self } } + pub fn video_abuse_report_reasons(&'a self) -> VideoAbuseReportReasonMethods<'a, C, A> { + VideoAbuseReportReasonMethods { hub: &self } + } pub fn video_categories(&'a self) -> VideoCategoryMethods<'a, C, A> { VideoCategoryMethods { hub: &self } } @@ -475,32 +496,51 @@ impl<'a, C, A> YouTube<C, A> pub struct SubscriptionListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#subscriptionListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of subscriptions that match the request criteria. - pub items: Vec<Subscription>, + pub items: Option<Vec<Subscription>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for SubscriptionListResponse {} +impl ToParts for SubscriptionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// Basic details about a playlist, including title, description and thumbnails. /// @@ -509,27 +549,27 @@ impl ResponseResult for SubscriptionListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlaylistSnippet { /// The playlist's description. - pub description: String, + pub description: Option<String>, /// The playlist's title. - pub title: String, + pub title: Option<String>, /// The ID that YouTube uses to uniquely identify the channel that published the playlist. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The date and time that the playlist was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// Keyword tags associated with the playlist. - pub tags: Vec<String>, + pub tags: Option<Vec<String>>, /// The channel title of the channel that the video belongs to. #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, /// The language of the playlist's default title and description. #[serde(rename="defaultLanguage")] - pub default_language: String, + pub default_language: Option<String>, /// Localized title and description, read-only. - pub localized: PlaylistLocalization, + pub localized: Option<PlaylistLocalization>, /// A map of thumbnail images associated with the playlist. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, } impl Part for PlaylistSnippet {} @@ -543,16 +583,16 @@ impl Part for PlaylistSnippet {} pub struct ChannelAuditDetails { /// Whether or not the channel has any copyright strikes. #[serde(rename="copyrightStrikesGoodStanding")] - pub copyright_strikes_good_standing: bool, + pub copyright_strikes_good_standing: Option<bool>, /// Whether or not the channel respects the community guidelines. #[serde(rename="communityGuidelinesGoodStanding")] - pub community_guidelines_good_standing: bool, + pub community_guidelines_good_standing: Option<bool>, /// Whether or not the channel has any unresolved claims. #[serde(rename="contentIdClaimsGoodStanding")] - pub content_id_claims_good_standing: bool, + pub content_id_claims_good_standing: Option<bool>, /// Describes the general state of the channel. This field will always show if there are any issues whatsoever with the channel. Currently this field represents the result of the logical and operation over the community guidelines good standing, the copyright strikes good standing and the content ID claims good standing, but this may change in the future. #[serde(rename="overallGoodStanding")] - pub overall_good_standing: bool, + pub overall_good_standing: Option<bool>, } impl Part for ChannelAuditDetails {} @@ -571,16 +611,16 @@ impl Part for ChannelAuditDetails {} pub struct ThumbnailSetResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of thumbnails. - pub items: Vec<ThumbnailDetails>, + pub items: Option<Vec<ThumbnailDetails>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#thumbnailSetResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for ThumbnailSetResponse {} @@ -593,41 +633,43 @@ impl ResponseResult for ThumbnailSetResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelSettings { /// Specifies the channel description. - pub description: String, + pub description: Option<String>, /// Specifies the channel title. - pub title: String, - /// Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible. - #[serde(rename="moderateComments")] - pub moderate_comments: bool, + pub title: Option<String>, + /// The country of the channel. + pub country: Option<String>, /// Whether the tab to browse the videos should be displayed. #[serde(rename="showBrowseView")] - pub show_browse_view: bool, + pub show_browse_view: Option<bool>, /// Title for the featured channels tab. #[serde(rename="featuredChannelsTitle")] - pub featured_channels_title: String, + pub featured_channels_title: Option<String>, /// no description provided #[serde(rename="defaultLanguage")] - pub default_language: String, + pub default_language: Option<String>, /// The trailer of the channel, for users that are not subscribers. #[serde(rename="unsubscribedTrailer")] - pub unsubscribed_trailer: String, + pub unsubscribed_trailer: Option<String>, /// The list of featured channels. #[serde(rename="featuredChannelsUrls")] - pub featured_channels_urls: Vec<String>, + pub featured_channels_urls: Option<Vec<String>>, /// A prominent color that can be rendered on this channel page. #[serde(rename="profileColor")] - pub profile_color: String, + pub profile_color: Option<String>, /// Which content tab users should see when viewing the channel. #[serde(rename="defaultTab")] - pub default_tab: String, + pub default_tab: Option<String>, + /// Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible. + #[serde(rename="moderateComments")] + pub moderate_comments: Option<bool>, /// Lists keywords associated with the channel, comma-separated. - pub keywords: String, + pub keywords: Option<String>, /// Whether related channels should be proposed. #[serde(rename="showRelatedChannels")] - pub show_related_channels: bool, + pub show_related_channels: Option<bool>, /// The ID for a Google Analytics account to track and measure traffic to the channels. #[serde(rename="trackingAnalyticsAccountId")] - pub tracking_analytics_account_id: String, + pub tracking_analytics_account_id: Option<String>, } impl Part for ChannelSettings {} @@ -640,13 +682,13 @@ impl Part for ChannelSettings {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CdnSettings { /// The format of the video stream that you are sending to Youtube. - pub format: String, + pub format: Option<String>, /// The ingestionInfo object contains information that YouTube provides that you need to transmit your RTMP or HTTP stream to YouTube. #[serde(rename="ingestionInfo")] - pub ingestion_info: IngestionInfo, + pub ingestion_info: Option<IngestionInfo>, /// The method or protocol used to transmit the video stream. #[serde(rename="ingestionType")] - pub ingestion_type: String, + pub ingestion_type: Option<String>, } impl Part for CdnSettings {} @@ -665,21 +707,64 @@ impl Part for CdnSettings {} pub struct VideoGetRatingResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of ratings that match the request criteria. - pub items: Vec<VideoRating>, + pub items: Option<Vec<VideoRating>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoGetRatingResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for VideoGetRatingResponse {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list video abuse report reasons](struct.VideoAbuseReportReasonListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VideoAbuseReportReasonListResponse { + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + pub event_id: Option<String>, + /// A list of valid abuse reasons that are used with video.ReportAbuse. + pub items: Option<Vec<VideoAbuseReportReason>>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoAbuseReportReasonListResponse". + pub kind: Option<String>, + /// Etag of this resource. + pub etag: Option<String>, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + pub visitor_id: Option<String>, +} + +impl ResponseResult for VideoAbuseReportReasonListResponse {} + +impl ToParts for VideoAbuseReportReasonListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + /// Details about a resource which was added to a channel. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -688,7 +773,7 @@ impl ResponseResult for VideoGetRatingResponse {} pub struct ActivityContentDetailsChannelItem { /// The resourceId object contains information that identifies the resource that was added to the channel. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsChannelItem {} @@ -701,9 +786,9 @@ impl Part for ActivityContentDetailsChannelItem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct I18nLanguageSnippet { /// The human-readable name of the language in the language itself. - pub name: String, + pub name: Option<String>, /// A short BCP-47 code that uniquely identifies a language. - pub hl: String, + pub hl: Option<String>, } impl Part for I18nLanguageSnippet {} @@ -716,10 +801,10 @@ impl Part for I18nLanguageSnippet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoRating { /// no description provided - pub rating: String, + pub rating: Option<String>, /// no description provided #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, } impl Part for VideoRating {} @@ -738,20 +823,35 @@ impl Part for VideoRating {} pub struct I18nRegionListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of regions where YouTube is available. In this map, the i18n region ID is the map key, and its value is the corresponding i18nRegion resource. - pub items: Vec<I18nRegion>, + pub items: Option<Vec<I18nRegion>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegionListResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for I18nRegionListResponse {} +impl ToParts for I18nRegionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -766,32 +866,51 @@ impl ResponseResult for I18nRegionListResponse {} pub struct LiveStreamListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStreamListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of live streams that match the request criteria. - pub items: Vec<LiveStream>, + pub items: Option<Vec<LiveStream>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for LiveStreamListResponse {} +impl ToParts for LiveStreamListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -806,32 +925,51 @@ impl ResponseResult for LiveStreamListResponse {} pub struct PlaylistListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of playlists that match the request criteria. - pub items: Vec<Playlist>, + pub items: Option<Vec<Playlist>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for PlaylistListResponse {} +impl ToParts for PlaylistListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. /// @@ -840,10 +978,10 @@ impl ResponseResult for PlaylistListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelConversionPing { /// Defines the context of the ping. - pub context: String, + pub context: Option<String>, /// The url (without the schema) that the player shall send the ping to. It's at caller's descretion to decide which schema to use (http vs https) Example of a returned url: //googleads.g.doubleclick.net/pagead/ viewthroughconversion/962985656/?data=path%3DtHe_path%3Btype%3D cview%3Butuid%3DGISQtTNGYqaYl4sKxoVvKA&labe=default The caller must append biscotti authentication (ms param in case of mobile, for example) to this ping. #[serde(rename="conversionUrl")] - pub conversion_url: String, + pub conversion_url: Option<String>, } impl Part for ChannelConversionPing {} @@ -857,14 +995,14 @@ impl Part for ChannelConversionPing {} pub struct InvideoPromotion { /// The default temporal position within the video where the promoted item will be displayed. Can be overriden by more specific timing in the item. #[serde(rename="defaultTiming")] - pub default_timing: InvideoTiming, + pub default_timing: Option<InvideoTiming>, /// List of promoted items in decreasing priority. - pub items: Vec<PromotedItem>, + pub items: Option<Vec<PromotedItem>>, /// Indicates whether the channel's promotional campaign uses "smart timing." This feature attempts to show promotions at a point in the video when they are more likely to be clicked and less likely to disrupt the viewing experience. This feature also picks up a single promotion to show on each video. #[serde(rename="useSmartTiming")] - pub use_smart_timing: bool, + pub use_smart_timing: Option<bool>, /// The spatial position within the video where the promoted item will be displayed. - pub position: InvideoPosition, + pub position: Option<InvideoPosition>, } impl Part for InvideoPromotion {} @@ -936,16 +1074,16 @@ impl ToParts for PlaylistItem { #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlaylistItemContentDetails { /// A user-generated note for this item. - pub note: String, + pub note: Option<String>, /// The time, measured in seconds from the start of the video, when the video should start playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) The default value is 0. #[serde(rename="startAt")] - pub start_at: String, + pub start_at: Option<String>, /// The time, measured in seconds from the start of the video, when the video should stop playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) By default, assume that the video.endTime is the end of the video. #[serde(rename="endAt")] - pub end_at: String, + pub end_at: Option<String>, /// The ID that YouTube uses to uniquely identify a video. To retrieve the video resource, set the id query parameter to this value in your API request. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, } impl Part for PlaylistItemContentDetails {} @@ -958,15 +1096,15 @@ impl Part for PlaylistItemContentDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ThumbnailDetails { /// The default image for this resource. - pub default: Thumbnail, + pub default: Option<Thumbnail>, /// The high quality image for this resource. - pub high: Thumbnail, + pub high: Option<Thumbnail>, /// The medium quality image for this resource. - pub medium: Thumbnail, + pub medium: Option<Thumbnail>, /// The maximum resolution quality image for this resource. - pub maxres: Thumbnail, + pub maxres: Option<Thumbnail>, /// The standard quality image for this resource. - pub standard: Thumbnail, + pub standard: Option<Thumbnail>, } impl Part for ThumbnailDetails {} @@ -979,7 +1117,7 @@ impl Part for ThumbnailDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoMonetizationDetails { /// The value of access indicates whether the video can be monetized or not. - pub access: AccessPolicy, + pub access: Option<AccessPolicy>, } impl Part for VideoMonetizationDetails {} @@ -992,34 +1130,37 @@ impl Part for VideoMonetizationDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelContentDetailsRelatedPlaylists { /// The ID of the playlist that contains the channel"s uploaded videos. Use the videos.insert method to upload new videos and the videos.delete method to delete previously uploaded videos. - pub uploads: String, + pub uploads: Option<String>, /// The ID of the playlist that contains the channel"s watch history. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list. #[serde(rename="watchHistory")] - pub watch_history: String, + pub watch_history: Option<String>, /// The ID of the playlist that contains the channel"s liked videos. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list. - pub likes: String, + pub likes: Option<String>, /// The ID of the playlist that contains the channel"s favorite videos. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list. - pub favorites: String, + pub favorites: Option<String>, /// The ID of the playlist that contains the channel"s watch later playlist. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list. #[serde(rename="watchLater")] - pub watch_later: String, + pub watch_later: Option<String>, } impl NestedType for ChannelContentDetailsRelatedPlaylists {} impl Part for ChannelContentDetailsRelatedPlaylists {} -/// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel. +/// Basic details about a video category, such as its localized title. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct ChannelConversionPings { - /// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. - pub pings: Vec<ChannelConversionPing>, +pub struct VideoAbuseReportReasonSnippet { + /// The secondary reasons associated with this reason, if any are available. (There might be 0 or more.) + #[serde(rename="secondaryReasons")] + pub secondary_reasons: Option<Vec<VideoAbuseReportSecondaryReason>>, + /// The localized label belonging to this abuse report reason. + pub label: Option<String>, } -impl Part for ChannelConversionPings {} +impl Part for VideoAbuseReportReasonSnippet {} /// Describes processing status and progress and availability of some other Video resource parts. @@ -1030,33 +1171,61 @@ impl Part for ChannelConversionPings {} pub struct VideoProcessingDetails { /// This value indicates whether file details are available for the uploaded video. You can retrieve a video's file details by requesting the fileDetails part in your videos.list() request. #[serde(rename="fileDetailsAvailability")] - pub file_details_availability: String, + pub file_details_availability: Option<String>, /// This value indicates whether video editing suggestions, which might improve video quality or the playback experience, are available for the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. #[serde(rename="editorSuggestionsAvailability")] - pub editor_suggestions_availability: String, + pub editor_suggestions_availability: Option<String>, /// The video's processing status. This value indicates whether YouTube was able to process the video or if the video is still being processed. #[serde(rename="processingStatus")] - pub processing_status: String, + pub processing_status: Option<String>, /// This value indicates whether the video processing engine has generated suggestions that might improve YouTube's ability to process the the video, warnings that explain video processing problems, or errors that cause video processing problems. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. #[serde(rename="processingIssuesAvailability")] - pub processing_issues_availability: String, + pub processing_issues_availability: Option<String>, /// The reason that YouTube failed to process the video. This property will only have a value if the processingStatus property's value is failed. #[serde(rename="processingFailureReason")] - pub processing_failure_reason: String, + pub processing_failure_reason: Option<String>, /// This value indicates whether thumbnail images have been generated for the video. #[serde(rename="thumbnailsAvailability")] - pub thumbnails_availability: String, + pub thumbnails_availability: Option<String>, /// The processingProgress object contains information about the progress YouTube has made in processing the video. The values are really only relevant if the video's processing status is processing. #[serde(rename="processingProgress")] - pub processing_progress: VideoProcessingDetailsProcessingProgress, + pub processing_progress: Option<VideoProcessingDetailsProcessingProgress>, /// This value indicates whether keyword (tag) suggestions are available for the video. Tags can be added to a video's metadata to make it easier for other users to find the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. #[serde(rename="tagSuggestionsAvailability")] - pub tag_suggestions_availability: String, + pub tag_suggestions_availability: Option<String>, } impl Part for VideoProcessingDetails {} +/// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelConversionPings { + /// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. + pub pings: Option<Vec<ChannelConversionPing>>, +} + +impl Part for ChannelConversionPings {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VideoAbuseReportSecondaryReason { + /// The ID of this abuse report secondary reason. + pub id: Option<VideoAbuseReportReasonId>, + /// The localized label for this abuse report secondary reason. + pub label: Option<String>, +} + +impl Part for VideoAbuseReportSecondaryReason {} + + /// Details about the content to witch a subscription refers. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -1065,13 +1234,13 @@ impl Part for VideoProcessingDetails {} pub struct SubscriptionContentDetails { /// The number of new items in the subscription since its content was last read. #[serde(rename="newItemCount")] - pub new_item_count: u32, + pub new_item_count: Option<u32>, /// The type of activity this subscription is for (only uploads, everything). #[serde(rename="activityType")] - pub activity_type: String, + pub activity_type: Option<String>, /// The approximate number of items that the subscription points to. #[serde(rename="totalItemCount")] - pub total_item_count: u32, + pub total_item_count: Option<u32>, } impl Part for SubscriptionContentDetails {} @@ -1090,20 +1259,48 @@ impl Part for SubscriptionContentDetails {} pub struct ChannelSectionListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of ChannelSections that match the request criteria. - pub items: Vec<ChannelSection>, + pub items: Option<Vec<ChannelSection>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelSectionListResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for ChannelSectionListResponse {} +impl ToParts for ChannelSectionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Comments written in (direct or indirect) reply to the top level comment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadReplies { + /// A limited number of replies. Unless the number of replies returned equals total_reply_count in the snippet the returned replies are only a subset of the total number of replies. + pub comments: Option<Vec<Comment>>, +} + +impl Part for CommentThreadReplies {} + /// DEPRECATED Region restriction of the video. /// @@ -1112,9 +1309,9 @@ impl ResponseResult for ChannelSectionListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoContentDetailsRegionRestriction { /// A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries. - pub allowed: Vec<String>, + pub allowed: Option<Vec<String>>, /// A list of region codes that identify countries where the video is blocked. If this property is present and a country is not listed in its value, then the video is viewable in that country. If this property is present and contains an empty list, the video is viewable in all countries. - pub blocked: Vec<String>, + pub blocked: Option<Vec<String>>, } impl Part for VideoContentDetailsRegionRestriction {} @@ -1127,23 +1324,23 @@ impl Part for VideoContentDetailsRegionRestriction {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SubscriptionSnippet { /// The subscription's details. - pub description: String, + pub description: Option<String>, /// The subscription's title. - pub title: String, + pub title: Option<String>, /// The id object contains information about the channel that the user subscribed to. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, /// A map of thumbnail images associated with the video. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, /// The ID that YouTube uses to uniquely identify the subscriber's channel. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The date and time that the subscription was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// Channel title for the channel that the subscription belongs to. #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, } impl Part for SubscriptionSnippet {} @@ -1156,41 +1353,41 @@ impl Part for SubscriptionSnippet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CaptionSnippet { /// The caption track's status. - pub status: String, + pub status: Option<String>, /// Indicates whether the track contains closed captions for the deaf and hard of hearing. The default value is false. #[serde(rename="isCC")] - pub is_cc: bool, + pub is_cc: Option<bool>, /// The type of audio track associated with the caption track. #[serde(rename="audioTrackType")] - pub audio_track_type: String, + pub audio_track_type: Option<String>, /// The language of the caption track. The property value is a BCP-47 language tag. - pub language: String, + pub language: Option<String>, /// The ID that YouTube uses to uniquely identify the video associated with the caption track. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, /// Indicates whether the caption track is a draft. If the value is true, then the track is not publicly visible. The default value is false. #[serde(rename="isDraft")] - pub is_draft: bool, + pub is_draft: Option<bool>, /// Indicates whether YouTube synchronized the caption track to the audio track in the video. The value will be true if a sync was explicitly requested when the caption track was uploaded. For example, when calling the captions.insert or captions.update methods, you can set the sync parameter to true to instruct YouTube to sync the uploaded track to the video. If the value is false, YouTube uses the time codes in the uploaded caption track to determine when to display captions. #[serde(rename="isAutoSynced")] - pub is_auto_synced: bool, + pub is_auto_synced: Option<bool>, /// The date and time when the caption track was last updated. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="lastUpdated")] - pub last_updated: String, + pub last_updated: Option<String>, /// The caption track's type. #[serde(rename="trackKind")] - pub track_kind: String, + pub track_kind: Option<String>, /// Indicates whether caption track is formatted for "easy reader," meaning it is at a third-grade level for language learners. The default value is false. #[serde(rename="isEasyReader")] - pub is_easy_reader: bool, + pub is_easy_reader: Option<bool>, /// Indicates whether the caption track uses large text for the vision-impaired. The default value is false. #[serde(rename="isLarge")] - pub is_large: bool, + pub is_large: Option<bool>, /// The reason that YouTube failed to process the caption track. This property is only present if the state property's value is failed. #[serde(rename="failureReason")] - pub failure_reason: String, + pub failure_reason: Option<String>, /// The name of the caption track. The name is intended to be visible to the user as an option during playback. - pub name: String, + pub name: Option<String>, } impl Part for CaptionSnippet {} @@ -1203,9 +1400,9 @@ impl Part for CaptionSnippet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct I18nRegionSnippet { /// The region code as a 2-letter ISO country code. - pub gl: String, + pub gl: Option<String>, /// The human-readable name of the region. - pub name: String, + pub name: Option<String>, } impl Part for I18nRegionSnippet {} @@ -1219,13 +1416,13 @@ impl Part for I18nRegionSnippet {} pub struct ActivityContentDetailsPlaylistItem { /// The resourceId object contains information about the resource that was added to the playlist. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, /// The value that YouTube uses to uniquely identify the playlist. #[serde(rename="playlistId")] - pub playlist_id: String, + pub playlist_id: Option<String>, /// ID of the item within the playlist. #[serde(rename="playlistItemId")] - pub playlist_item_id: String, + pub playlist_item_id: Option<String>, } impl Part for ActivityContentDetailsPlaylistItem {} @@ -1239,7 +1436,7 @@ impl Part for ActivityContentDetailsPlaylistItem {} pub struct ActivityContentDetailsComment { /// The resourceId object contains information that identifies the resource associated with the comment. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsComment {} @@ -1253,9 +1450,9 @@ impl Part for ActivityContentDetailsComment {} pub struct GuideCategorySnippet { /// no description provided #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// Description of the guide category. - pub title: String, + pub title: Option<String>, } impl Part for GuideCategorySnippet {} @@ -1268,33 +1465,33 @@ impl Part for GuideCategorySnippet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoSnippet { /// The video's description. - pub description: String, + pub description: Option<String>, /// A list of keyword tags associated with the video. Tags may contain spaces. This field is only visible to the video's uploader. - pub tags: Vec<String>, + pub tags: Option<Vec<String>>, /// The ID that YouTube uses to uniquely identify the channel that the video was uploaded to. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The language of the videos's default snippet. #[serde(rename="defaultLanguage")] - pub default_language: String, + pub default_language: Option<String>, /// Indicates if the video is an upcoming/active live broadcast. Or it's "none" if the video is not an upcoming/active live broadcast. #[serde(rename="liveBroadcastContent")] - pub live_broadcast_content: String, + pub live_broadcast_content: Option<String>, /// The date and time that the video was uploaded. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// A map of thumbnail images associated with the video. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, /// The video's title. - pub title: String, + pub title: Option<String>, /// The YouTube video category associated with the video. #[serde(rename="categoryId")] - pub category_id: String, + pub category_id: Option<String>, /// Localized snippet selected with the hl parameter. If no such localization exists, this field is populated with the default snippet. (Read-only) - pub localized: VideoLocalization, + pub localized: Option<VideoLocalization>, /// Channel title for the channel that the video belongs to. #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, } impl Part for VideoSnippet {} @@ -1313,10 +1510,10 @@ pub struct LiveStreamContentDetails { /// - A non-reusable stream might be deleted by an automated process after the broadcast ends. /// - The liveStreams.list method does not list non-reusable streams if you call the method and set the mine parameter to true. The only way to use that method to retrieve the resource for a non-reusable stream is to use the id parameter to identify the stream. #[serde(rename="isReusable")] - pub is_reusable: bool, + pub is_reusable: Option<bool>, /// The ingestion URL where the closed captions of this stream are sent. #[serde(rename="closedCaptionsIngestionUrl")] - pub closed_captions_ingestion_url: String, + pub closed_captions_ingestion_url: Option<String>, } impl Part for LiveStreamContentDetails {} @@ -1329,13 +1526,13 @@ impl Part for LiveStreamContentDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GuideCategory { /// The snippet object contains basic details about the category, such as its title. - pub snippet: GuideCategorySnippet, + pub snippet: Option<GuideCategorySnippet>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#guideCategory". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The ID that YouTube uses to uniquely identify the guide category. - pub id: String, + pub id: Option<String>, } impl Part for GuideCategory {} @@ -1354,20 +1551,35 @@ impl Part for GuideCategory {} pub struct I18nLanguageListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of supported i18n languages. In this map, the i18n language ID is the map key, and its value is the corresponding i18nLanguage resource. - pub items: Vec<I18nLanguage>, + pub items: Option<Vec<I18nLanguage>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nLanguageListResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for I18nLanguageListResponse {} +impl ToParts for I18nLanguageListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -1376,12 +1588,12 @@ impl ResponseResult for I18nLanguageListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocalizedProperty { /// no description provided - pub default: String, + pub default: Option<String>, /// The language of the default property. #[serde(rename="defaultLanguage")] - pub default_language: LanguageTag, + pub default_language: Option<LanguageTag>, /// no description provided - pub localized: Vec<LocalizedString>, + pub localized: Option<Vec<LocalizedString>>, } impl Part for LocalizedProperty {} @@ -1395,25 +1607,25 @@ impl Part for LocalizedProperty {} pub struct VideoFileDetailsVideoStream { /// The video stream's bitrate, in bits per second. #[serde(rename="bitrateBps")] - pub bitrate_bps: String, + pub bitrate_bps: Option<String>, /// A value that uniquely identifies a video vendor. Typically, the value is a four-letter vendor code. - pub vendor: String, + pub vendor: Option<String>, /// The video codec that the stream uses. - pub codec: String, + pub codec: Option<String>, /// The encoded video content's width in pixels. You can calculate the video's encoding aspect ratio as width_pixels / height_pixels. #[serde(rename="widthPixels")] - pub width_pixels: u32, + pub width_pixels: Option<u32>, /// The encoded video content's height in pixels. #[serde(rename="heightPixels")] - pub height_pixels: u32, + pub height_pixels: Option<u32>, /// The video content's display aspect ratio, which specifies the aspect ratio in which the video should be displayed. #[serde(rename="aspectRatio")] - pub aspect_ratio: f64, + pub aspect_ratio: Option<f64>, /// The amount that YouTube needs to rotate the original source content to properly display the video. - pub rotation: String, + pub rotation: Option<String>, /// The video stream's frame rate, in frames per second. #[serde(rename="frameRateFps")] - pub frame_rate_fps: f64, + pub frame_rate_fps: Option<f64>, } impl Part for VideoFileDetailsVideoStream {} @@ -1526,9 +1738,9 @@ impl ToParts for Channel { #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelLocalization { /// The localized strings for channel's description. - pub description: String, - /// The localized strings for channel's title, read-only. - pub title: String, + pub description: Option<String>, + /// The localized strings for channel's title. + pub title: Option<String>, } impl Part for ChannelLocalization {} @@ -1541,13 +1753,13 @@ impl Part for ChannelLocalization {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SearchResult { /// The snippet object contains basic details about a search result, such as its title or description. For example, if the search result is a video, then the title will be the video's title and the description will be the video's description. - pub snippet: SearchResultSnippet, + pub snippet: Option<SearchResultSnippet>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#searchResult". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The id object contains information that can be used to uniquely identify the resource that matches the search request. - pub id: ResourceId, + pub id: Option<ResourceId>, } impl Part for SearchResult {} @@ -1566,32 +1778,51 @@ impl Part for SearchResult {} pub struct VideoCategoryListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoCategoryListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of video categories that can be associated with YouTube videos. In this map, the video category ID is the map key, and its value is the corresponding videoCategory resource. - pub items: Vec<VideoCategory>, + pub items: Option<Vec<VideoCategory>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for VideoCategoryListResponse {} +impl ToParts for VideoCategoryListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// Video processing progress and completion time estimate. /// @@ -1601,16 +1832,16 @@ impl ResponseResult for VideoCategoryListResponse {} pub struct VideoProcessingDetailsProcessingProgress { /// An estimate of the amount of time, in millseconds, that YouTube needs to finish processing the video. #[serde(rename="timeLeftMs")] - pub time_left_ms: String, + pub time_left_ms: Option<String>, /// The number of parts of the video that YouTube has already processed. You can estimate the percentage of the video that YouTube has already processed by calculating: /// 100 * parts_processed / parts_total /// /// Note that since the estimated number of parts could increase without a corresponding increase in the number of parts that have already been processed, it is possible that the calculated progress could periodically decrease while YouTube processes a video. #[serde(rename="partsProcessed")] - pub parts_processed: String, + pub parts_processed: Option<String>, /// An estimate of the total number of parts that need to be processed for the video. The number may be updated with more precise estimates while YouTube processes the video. #[serde(rename="partsTotal")] - pub parts_total: String, + pub parts_total: Option<String>, } impl Part for VideoProcessingDetailsProcessingProgress {} @@ -1629,32 +1860,51 @@ impl Part for VideoProcessingDetailsProcessingProgress {} pub struct VideoListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of videos that match the request criteria. - pub items: Vec<Video>, + pub items: Option<Vec<Video>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for VideoListResponse {} +impl ToParts for VideoListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -1663,7 +1913,7 @@ impl ResponseResult for VideoListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LanguageTag { /// no description provided - pub value: String, + pub value: Option<String>, } impl Part for LanguageTag {} @@ -1727,14 +1977,14 @@ impl ToParts for Subscription { pub struct LiveStreamSnippet { /// The ID that YouTube uses to uniquely identify the channel that is transmitting the stream. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The stream's description. The value cannot be longer than 10000 characters. - pub description: String, + pub description: Option<String>, /// The date and time that the stream was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// The stream's title. The value must be between 1 and 128 characters long. - pub title: String, + pub title: Option<String>, } impl Part for LiveStreamSnippet {} @@ -1748,13 +1998,13 @@ impl Part for LiveStreamSnippet {} pub struct ChannelStatus { /// Privacy status of the channel. #[serde(rename="privacyStatus")] - pub privacy_status: String, + pub privacy_status: Option<String>, /// If true, then the user is linked to either a YouTube username or G+ account. Otherwise, the user doesn't have a public YouTube identity. #[serde(rename="isLinked")] - pub is_linked: bool, + pub is_linked: Option<bool>, /// The long uploads status of this channel. See #[serde(rename="longUploadsStatus")] - pub long_uploads_status: String, + pub long_uploads_status: Option<String>, } impl Part for ChannelStatus {} @@ -1773,32 +2023,51 @@ impl Part for ChannelStatus {} pub struct ChannelListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of channels that match the request criteria. - pub items: Vec<Channel>, + pub items: Option<Vec<Channel>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for ChannelListResponse {} +impl ToParts for ChannelListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -1820,6 +2089,8 @@ pub struct ChannelSection { pub kind: Option<String>, /// Etag of this resource. pub etag: Option<String>, + /// The targeting object contains basic targeting settings about the channel section. + pub targeting: Option<ChannelSectionTargeting>, /// The contentDetails object contains details about the channel section content, such as a list of playlists or channels featured in the section. #[serde(rename="contentDetails")] pub content_details: Option<ChannelSectionContentDetails>, @@ -1842,6 +2113,7 @@ impl ToParts for ChannelSection { if self.snippet.is_some() { r = r + "snippet,"; } if self.kind.is_some() { r = r + "kind,"; } if self.etag.is_some() { r = r + "etag,"; } + if self.targeting.is_some() { r = r + "targeting,"; } if self.content_details.is_some() { r = r + "contentDetails,"; } if self.id.is_some() { r = r + "id,"; } if self.localizations.is_some() { r = r + "localizations,"; } @@ -1863,32 +2135,51 @@ impl ToParts for ChannelSection { pub struct LiveBroadcastListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveBroadcastListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of broadcasts that match the request criteria. - pub items: Vec<LiveBroadcast>, + pub items: Option<Vec<LiveBroadcast>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for LiveBroadcastListResponse {} +impl ToParts for LiveBroadcastListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -1903,20 +2194,35 @@ impl ResponseResult for LiveBroadcastListResponse {} pub struct CaptionListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// A list of captions that match the request criteria. - pub items: Vec<Caption>, + pub items: Option<Vec<Caption>>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#captionListResponse". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, } impl ResponseResult for CaptionListResponse {} +impl ToParts for CaptionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} /// Brief description of the live stream status. /// @@ -1924,9 +2230,12 @@ impl ResponseResult for CaptionListResponse {} /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LiveStreamStatus { + /// no description provided + #[serde(rename="isDefaultStream")] + pub is_default_stream: Option<bool>, /// no description provided #[serde(rename="streamStatus")] - pub stream_status: String, + pub stream_status: Option<String>, } impl Part for LiveStreamStatus {} @@ -1940,201 +2249,260 @@ impl Part for LiveStreamStatus {} pub struct ContentRating { /// Internal YouTube rating. #[serde(rename="ytRating")] - pub yt_rating: String, + pub yt_rating: Option<String>, /// Rating system for French Canadian TV - Regie du cinema #[serde(rename="catvfrRating")] - pub catvfr_rating: String, + pub catvfr_rating: Option<String>, /// Rating system in India - Central Board of Film Certification #[serde(rename="cbfcRating")] - pub cbfc_rating: String, + pub cbfc_rating: Option<String>, /// Rating system for Thailand - Board of Filmand Video Censors #[serde(rename="bfvcRating")] - pub bfvc_rating: String, + pub bfvc_rating: Option<String>, /// Rating system for Austria - Bundesministeriums f�r Unterricht, Kunst und Kultur! #[serde(rename="bmukkRating")] - pub bmukk_rating: String, + pub bmukk_rating: Option<String>, /// Rating system for Switzerland - Switzerland Rating System #[serde(rename="chfilmRating")] - pub chfilm_rating: String, + pub chfilm_rating: Option<String>, /// Rating system for Taiwan - Ministry of Culture - Tawan #[serde(rename="moctwRating")] - pub moctw_rating: String, + pub moctw_rating: Option<String>, /// Rating system for Canadian TV - Canadian TV Classification System #[serde(rename="catvRating")] - pub catv_rating: String, + pub catv_rating: Option<String>, /// Rating system for Peru - Peru Rating System #[serde(rename="pefilmRating")] - pub pefilm_rating: String, + pub pefilm_rating: Option<String>, /// no description provided #[serde(rename="djctqRatingReasons")] - pub djctq_rating_reasons: Vec<String>, + pub djctq_rating_reasons: Option<Vec<String>>, /// Rating system for Argentina - Instituto Nacional de Cine y Artes Audiovisuales #[serde(rename="incaaRating")] - pub incaa_rating: String, + pub incaa_rating: Option<String>, /// Rating system for Israel - Israel Rating System #[serde(rename="ilfilmRating")] - pub ilfilm_rating: String, + pub ilfilm_rating: Option<String>, /// Rating system for Luxembourg - Commission de surveillance de la classification des films #[serde(rename="cscfRating")] - pub cscf_rating: String, + pub cscf_rating: Option<String>, /// Rating system in Germany - Voluntary Self Regulation of the Movie Industry #[serde(rename="fskRating")] - pub fsk_rating: String, + pub fsk_rating: Option<String>, /// Rating system in South Korea - Korea Media Rating Board #[serde(rename="kmrbRating")] - pub kmrb_rating: String, + pub kmrb_rating: Option<String>, /// Rating system in Brazil - Department of Justice, Rating, Titles and Qualification #[serde(rename="djctqRating")] - pub djctq_rating: String, + pub djctq_rating: Option<String>, /// Rating system for Hong kong - Office for Film, Newspaper and Article Administration #[serde(rename="fcoRating")] - pub fco_rating: String, + pub fco_rating: Option<String>, /// Rating system for Norway - Medietilsynet #[serde(rename="medietilsynetRating")] - pub medietilsynet_rating: String, + pub medietilsynet_rating: Option<String>, /// Rating system for Greece - Greece Rating System #[serde(rename="grfilmRating")] - pub grfilm_rating: String, + pub grfilm_rating: Option<String>, /// Rating system for Chile - Consejo de Calificaci�n Cinematogr�fica #[serde(rename="cccRating")] - pub ccc_rating: String, + pub ccc_rating: Option<String>, /// Rating system for Ireland - Raidi� Teilif�s �ireann #[serde(rename="rteRating")] - pub rte_rating: String, + pub rte_rating: Option<String>, /// Rating system in France - French Minister of Culture #[serde(rename="fmocRating")] - pub fmoc_rating: String, + pub fmoc_rating: Option<String>, /// Rating system in Japan - Eiga Rinri Kanri Iinkai #[serde(rename="eirinRating")] - pub eirin_rating: String, + pub eirin_rating: Option<String>, /// Rating system for Portugal - Comiss�o de Classifica��o de Espect�culos #[serde(rename="cceRating")] - pub cce_rating: String, + pub cce_rating: Option<String>, /// Rating system for Latvia - National Film Center of Latvia #[serde(rename="nkclvRating")] - pub nkclv_rating: String, + pub nkclv_rating: Option<String>, /// Rating system for South africa - Film & Publication Board #[serde(rename="fpbRating")] - pub fpb_rating: String, + pub fpb_rating: Option<String>, /// Rating system for Iceland - SMAIS #[serde(rename="smaisRating")] - pub smais_rating: String, + pub smais_rating: Option<String>, /// Canadian Home Video Rating System #[serde(rename="chvrsRating")] - pub chvrs_rating: String, + pub chvrs_rating: Option<String>, /// Rating system for Italy - Autorit� per le Garanzie nelle Comunicazioni #[serde(rename="agcomRating")] - pub agcom_rating: String, + pub agcom_rating: Option<String>, /// Rating system for Colombia - MoC #[serde(rename="mocRating")] - pub moc_rating: String, + pub moc_rating: Option<String>, /// Rating system for Hungary - Rating Committee of the National Office of Film #[serde(rename="rcnofRating")] - pub rcnof_rating: String, + pub rcnof_rating: Option<String>, /// Rating system for Malaysia - Film Censorship Board of Malaysia #[serde(rename="fcbmRating")] - pub fcbm_rating: String, + pub fcbm_rating: Option<String>, /// Rating system for Netherlands - Nederlands Instituut voor de Classificatie van Audiovisuele Media #[serde(rename="kijkwijzerRating")] - pub kijkwijzer_rating: String, + pub kijkwijzer_rating: Option<String>, /// Rating system for Singapore - Media Development Authority #[serde(rename="mdaRating")] - pub mda_rating: String, + pub mda_rating: Option<String>, /// Rating system for Nigeria - National Film and Video Censors Board #[serde(rename="nfvcbRating")] - pub nfvcb_rating: String, + pub nfvcb_rating: Option<String>, /// Rating system for Venezuela - SiBCI #[serde(rename="resorteviolenciaRating")] - pub resorteviolencia_rating: String, + pub resorteviolencia_rating: Option<String>, /// Rating system for France - Conseil sup�rieur de l?audiovisuel #[serde(rename="csaRating")] - pub csa_rating: String, + pub csa_rating: Option<String>, /// Rating system in New Zealand - Office of Film and Literature Classification #[serde(rename="oflcRating")] - pub oflc_rating: String, + pub oflc_rating: Option<String>, /// TV Parental Guidelines rating of the content. #[serde(rename="tvpgRating")] - pub tvpg_rating: String, + pub tvpg_rating: Option<String>, /// Rating system for Bulgaria - National Film Centre #[serde(rename="nfrcRating")] - pub nfrc_rating: String, + pub nfrc_rating: Option<String>, /// Rating system for Malta - Film Age-Classification Board #[serde(rename="mccaaRating")] - pub mccaa_rating: String, + pub mccaa_rating: Option<String>, /// Rating system in Mexico - General Directorate of Radio, Television and Cinematography #[serde(rename="rtcRating")] - pub rtc_rating: String, + pub rtc_rating: Option<String>, /// Rating system in Italy - Ministero dei Beni e delle Attivita Culturali e del Turismo #[serde(rename="mibacRating")] - pub mibac_rating: String, + pub mibac_rating: Option<String>, /// British Board of Film Classification #[serde(rename="bbfcRating")] - pub bbfc_rating: String, + pub bbfc_rating: Option<String>, /// Rating system for Egypt - Egypt Rating System #[serde(rename="egfilmRating")] - pub egfilm_rating: String, + pub egfilm_rating: Option<String>, /// Rating system for Belgium - Belgium Rating System #[serde(rename="cicfRating")] - pub cicf_rating: String, + pub cicf_rating: Option<String>, /// Rating system for Poland - National Broadcasting Council #[serde(rename="nbcplRating")] - pub nbcpl_rating: String, + pub nbcpl_rating: Option<String>, /// Rating system for Maldives - National Bureau of Classification #[serde(rename="nbcRating")] - pub nbc_rating: String, + pub nbc_rating: Option<String>, /// Motion Picture Association of America rating for the content. #[serde(rename="mpaaRating")] - pub mpaa_rating: String, + pub mpaa_rating: Option<String>, /// Rating system in Ireland - Irish Film Classification Office #[serde(rename="ifcoRating")] - pub ifco_rating: String, + pub ifco_rating: Option<String>, /// Rating system in Australia - Australian Classification Board #[serde(rename="acbRating")] - pub acb_rating: String, + pub acb_rating: Option<String>, /// Rating system for Estonia - Estonia Rating System #[serde(rename="eefilmRating")] - pub eefilm_rating: String, + pub eefilm_rating: Option<String>, /// Rating system for Czech republic - Czech republic Rating System #[serde(rename="czfilmRating")] - pub czfilm_rating: String, + pub czfilm_rating: Option<String>, /// Rating system for Indonesia - Lembaga Sensor Film #[serde(rename="lsfRating")] - pub lsf_rating: String, + pub lsf_rating: Option<String>, /// Rating system in Russia #[serde(rename="russiaRating")] - pub russia_rating: String, + pub russia_rating: Option<String>, /// Rating system for Kenya - Kenya Film Classification Board #[serde(rename="kfcbRating")] - pub kfcb_rating: String, + pub kfcb_rating: Option<String>, /// Rating system for Philippines - MOVIE AND TELEVISION REVIEW AND CLASSIFICATION BOARD #[serde(rename="mtrcbRating")] - pub mtrcb_rating: String, + pub mtrcb_rating: Option<String>, /// Rating system for Chile - Asociaci�n Nacional de Televisi�n #[serde(rename="anatelRating")] - pub anatel_rating: String, + pub anatel_rating: Option<String>, /// Rating system for Sweden - Statens medier�d (National Media Council) #[serde(rename="smsaRating")] - pub smsa_rating: String, + pub smsa_rating: Option<String>, /// Rating system for Romania - CONSILIUL NATIONAL AL AUDIOVIZUALULUI - CNA #[serde(rename="cnaRating")] - pub cna_rating: String, + pub cna_rating: Option<String>, /// Rating system in Spain - Instituto de Cinematografia y de las Artes Audiovisuales #[serde(rename="icaaRating")] - pub icaa_rating: String, + pub icaa_rating: Option<String>, /// Rating system for Denmark - The Media Council for Children and Young People #[serde(rename="mccypRating")] - pub mccyp_rating: String, + pub mccyp_rating: Option<String>, /// Rating system for Slovakia - Slovakia Rating System #[serde(rename="skfilmRating")] - pub skfilm_rating: String, + pub skfilm_rating: Option<String>, /// Rating system for Finland - Finnish Centre for Media Education and Audiovisual Media #[serde(rename="mekuRating")] - pub meku_rating: String, + pub meku_rating: Option<String>, } impl Part for ContentRating {} +/// Basic details about a comment, such as its author and text. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentSnippet { + /// Link to the author's YouTube channel, if any. + #[serde(rename="authorChannelUrl")] + pub author_channel_url: Option<String>, + /// The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel. + #[serde(rename="channelId")] + pub channel_id: Option<String>, + /// The ID of the video the comment refers to, if any. + #[serde(rename="videoId")] + pub video_id: Option<String>, + /// The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + #[serde(rename="publishedAt")] + pub published_at: Option<String>, + /// The total number of likes this comment has received. + #[serde(rename="likeCount")] + pub like_count: Option<u32>, + /// Whether the current viewer can rate this comment. + #[serde(rename="canRate")] + pub can_rate: Option<bool>, + /// The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + #[serde(rename="updatedAt")] + pub updated_at: Option<String>, + /// The URL for the avatar of the user who posted the comment. + #[serde(rename="authorProfileImageUrl")] + pub author_profile_image_url: Option<String>, + /// Link to the author's Google+ profile, if any. + #[serde(rename="authorGoogleplusProfileUrl")] + pub author_googleplus_profile_url: Option<String>, + /// The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc. + #[serde(rename="textDisplay")] + pub text_display: Option<String>, + /// The name of the user who posted the comment. + #[serde(rename="authorDisplayName")] + pub author_display_name: Option<String>, + /// The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future. + #[serde(rename="viewerRating")] + pub viewer_rating: Option<String>, + /// The comment's moderation status. Will not be set if the comments were requested through the id filter. + #[serde(rename="moderationStatus")] + pub moderation_status: Option<String>, + /// The id of the author's YouTube channel, if any. + #[serde(rename="authorChannelId")] + pub author_channel_id: Option<ChannelId>, + /// The unique id of the parent comment, only set for replies. + #[serde(rename="parentId")] + pub parent_id: Option<String>, + /// The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author. + #[serde(rename="textOriginal")] + pub text_original: Option<String>, +} + +impl Part for CommentSnippet {} + + /// Branding properties for images associated with the channel. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2143,70 +2511,70 @@ impl Part for ContentRating {} pub struct ImageSettings { /// Banner image. TV size medium resolution (1280x720). #[serde(rename="bannerTvMediumImageUrl")] - pub banner_tv_medium_image_url: String, + pub banner_tv_medium_image_url: Option<String>, /// The image map script for the large banner image. #[serde(rename="largeBrandedBannerImageImapScript")] - pub large_branded_banner_image_imap_script: LocalizedProperty, + pub large_branded_banner_image_imap_script: Option<LocalizedProperty>, /// Banner image. Mobile size (640x175). #[serde(rename="bannerMobileImageUrl")] - pub banner_mobile_image_url: String, + pub banner_mobile_image_url: Option<String>, /// The URL for the 640px by 70px banner image that appears below the video player in the default view of the video watch page. #[serde(rename="smallBrandedBannerImageUrl")] - pub small_branded_banner_image_url: LocalizedProperty, + pub small_branded_banner_image_url: Option<LocalizedProperty>, /// Banner image. Tablet size high resolution (2276x377). #[serde(rename="bannerTabletHdImageUrl")] - pub banner_tablet_hd_image_url: String, + pub banner_tablet_hd_image_url: Option<String>, /// Banner image. Tablet size low resolution (1138x188). #[serde(rename="bannerTabletLowImageUrl")] - pub banner_tablet_low_image_url: String, + pub banner_tablet_low_image_url: Option<String>, /// Banner image. Mobile size medium/high resolution (960x263). #[serde(rename="bannerMobileMediumHdImageUrl")] - pub banner_mobile_medium_hd_image_url: String, + pub banner_mobile_medium_hd_image_url: Option<String>, /// The URL for a 1px by 1px tracking pixel that can be used to collect statistics for views of the channel or video pages. #[serde(rename="trackingImageUrl")] - pub tracking_image_url: String, + pub tracking_image_url: Option<String>, /// Banner image. Mobile size high resolution (1440x395). #[serde(rename="bannerMobileExtraHdImageUrl")] - pub banner_mobile_extra_hd_image_url: String, + pub banner_mobile_extra_hd_image_url: Option<String>, /// Banner image. Tablet size (1707x283). #[serde(rename="bannerTabletImageUrl")] - pub banner_tablet_image_url: String, + pub banner_tablet_image_url: Option<String>, /// Banner image. Mobile size low resolution (320x88). #[serde(rename="bannerMobileLowImageUrl")] - pub banner_mobile_low_image_url: String, + pub banner_mobile_low_image_url: Option<String>, /// Banner image. TV size extra high resolution (2120x1192). #[serde(rename="bannerTvImageUrl")] - pub banner_tv_image_url: String, + pub banner_tv_image_url: Option<String>, /// Banner image. TV size low resolution (854x480). #[serde(rename="bannerTvLowImageUrl")] - pub banner_tv_low_image_url: String, + pub banner_tv_low_image_url: Option<String>, /// Banner image. Tablet size extra high resolution (2560x424). #[serde(rename="bannerTabletExtraHdImageUrl")] - pub banner_tablet_extra_hd_image_url: String, + pub banner_tablet_extra_hd_image_url: Option<String>, /// The URL for the 854px by 70px image that appears below the video player in the expanded video view of the video watch page. #[serde(rename="largeBrandedBannerImageUrl")] - pub large_branded_banner_image_url: LocalizedProperty, + pub large_branded_banner_image_url: Option<LocalizedProperty>, /// Banner image. TV size high resolution (1920x1080). #[serde(rename="bannerTvHighImageUrl")] - pub banner_tv_high_image_url: String, + pub banner_tv_high_image_url: Option<String>, /// The URL for the background image shown on the video watch page. The image should be 1200px by 615px, with a maximum file size of 128k. #[serde(rename="backgroundImageUrl")] - pub background_image_url: LocalizedProperty, + pub background_image_url: Option<LocalizedProperty>, /// The image map script for the small banner image. #[serde(rename="smallBrandedBannerImageImapScript")] - pub small_branded_banner_image_imap_script: LocalizedProperty, + pub small_branded_banner_image_imap_script: Option<LocalizedProperty>, /// Banner image. Desktop size (1060x175). #[serde(rename="bannerImageUrl")] - pub banner_image_url: String, + pub banner_image_url: Option<String>, /// Banner image. Mobile size high resolution (1280x360). #[serde(rename="bannerMobileHdImageUrl")] - pub banner_mobile_hd_image_url: String, + pub banner_mobile_hd_image_url: Option<String>, /// This is used only in update requests; if it's set, we use this URL to generate all of the above banner URLs. #[serde(rename="bannerExternalUrl")] - pub banner_external_url: String, + pub banner_external_url: Option<String>, /// The URL for the image that appears above the top-left corner of the video player. This is a 25-pixel-high image with a flexible width that cannot exceed 170 pixels. #[serde(rename="watchIconImageUrl")] - pub watch_icon_image_url: String, + pub watch_icon_image_url: Option<String>, } impl Part for ImageSettings {} @@ -2220,39 +2588,128 @@ impl Part for ImageSettings {} pub struct ActivityContentDetailsPromotedItem { /// The type of call-to-action, a message to the user indicating action that can be taken. #[serde(rename="ctaType")] - pub cta_type: String, + pub cta_type: Option<String>, /// The URL the client should fetch to request a promoted item. #[serde(rename="adTag")] - pub ad_tag: String, + pub ad_tag: Option<String>, /// The URL the client should direct the user to, if the user chooses to visit the advertiser's website. #[serde(rename="destinationUrl")] - pub destination_url: String, + pub destination_url: Option<String>, /// The list of forecasting URLs. The client should ping all of these URLs when a promoted item is not available, to indicate that a promoted item could have been shown. #[serde(rename="forecastingUrl")] - pub forecasting_url: Vec<String>, + pub forecasting_url: Option<Vec<String>>, /// The list of impression URLs. The client should ping all of these URLs to indicate that the user was shown this promoted item. #[serde(rename="impressionUrl")] - pub impression_url: Vec<String>, + pub impression_url: Option<Vec<String>>, /// The URL the client should ping to indicate that the user was shown this promoted item. #[serde(rename="creativeViewUrl")] - pub creative_view_url: String, + pub creative_view_url: Option<String>, /// The ID that YouTube uses to uniquely identify the promoted video. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, /// The text description to accompany the promoted item. #[serde(rename="descriptionText")] - pub description_text: String, + pub description_text: Option<String>, /// The custom call-to-action button text. If specified, it will override the default button text for the cta_type. #[serde(rename="customCtaButtonText")] - pub custom_cta_button_text: String, + pub custom_cta_button_text: Option<String>, /// The URL the client should ping to indicate that the user clicked through on this promoted item. #[serde(rename="clickTrackingUrl")] - pub click_tracking_url: String, + pub click_tracking_url: Option<String>, } impl Part for ActivityContentDetailsPromotedItem {} +/// A comment represents a single YouTube comment. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [insert comments](struct.CommentInsertCall.html) (request|response) +/// * [set moderation status comments](struct.CommentSetModerationStatuCall.html) (none) +/// * [update comments](struct.CommentUpdateCall.html) (request|response) +/// * [delete comments](struct.CommentDeleteCall.html) (none) +/// * [mark as spam comments](struct.CommentMarkAsSpamCall.html) (none) +/// * [list comments](struct.CommentListCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Comment { + /// The snippet object contains basic details about the comment. + pub snippet: Option<CommentSnippet>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#comment". + pub kind: Option<String>, + /// Etag of this resource. + pub etag: Option<String>, + /// The ID that YouTube uses to uniquely identify the comment. + pub id: Option<String>, +} + +impl RequestValue for Comment {} +impl Resource for Comment {} +impl ResponseResult for Comment {} + +impl ToParts for Comment { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} + +/// A caption resource represents a YouTube caption track. A caption track is associated with exactly one YouTube video. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [update captions](struct.CaptionUpdateCall.html) (request|response) +/// * [list captions](struct.CaptionListCall.html) (none) +/// * [delete captions](struct.CaptionDeleteCall.html) (none) +/// * [insert captions](struct.CaptionInsertCall.html) (request|response) +/// * [download captions](struct.CaptionDownloadCall.html) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Caption { + /// The snippet object contains basic details about the caption. + pub snippet: Option<CaptionSnippet>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#caption". + pub kind: Option<String>, + /// Etag of this resource. + pub etag: Option<String>, + /// The ID that YouTube uses to uniquely identify the caption track. + pub id: Option<String>, +} + +impl RequestValue for Caption {} +impl Resource for Caption {} +impl ResponseResult for Caption {} + +impl ToParts for Caption { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} + /// Details about a channel bulletin post. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2261,7 +2718,7 @@ impl Part for ActivityContentDetailsPromotedItem {} pub struct ActivityContentDetailsBulletin { /// The resourceId object contains information that identifies the resource associated with a bulletin post. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsBulletin {} @@ -2274,9 +2731,9 @@ impl Part for ActivityContentDetailsBulletin {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocalizedString { /// no description provided - pub language: String, + pub language: Option<String>, /// no description provided - pub value: String, + pub value: Option<String>, } impl Part for LocalizedString {} @@ -2290,14 +2747,14 @@ impl Part for LocalizedString {} pub struct VideoFileDetailsAudioStream { /// The audio stream's bitrate, in bits per second. #[serde(rename="bitrateBps")] - pub bitrate_bps: String, + pub bitrate_bps: Option<String>, /// The audio codec that the stream uses. - pub codec: String, + pub codec: Option<String>, /// A value that uniquely identifies a video vendor. Typically, the value is a four-letter vendor code. - pub vendor: String, + pub vendor: Option<String>, /// The number of audio channels that the stream contains. #[serde(rename="channelCount")] - pub channel_count: u32, + pub channel_count: Option<u32>, } impl Part for VideoFileDetailsAudioStream {} @@ -2311,17 +2768,17 @@ impl Part for VideoFileDetailsAudioStream {} pub struct IngestionInfo { /// The backup ingestion URL that you should use to stream video to YouTube. You have the option of simultaneously streaming the content that you are sending to the ingestionAddress to this URL. #[serde(rename="backupIngestionAddress")] - pub backup_ingestion_address: String, + pub backup_ingestion_address: Option<String>, /// The HTTP or RTMP stream name that YouTube assigns to the video stream. #[serde(rename="streamName")] - pub stream_name: String, + pub stream_name: Option<String>, /// The primary ingestion URL that you should use to stream video to YouTube. You must stream video to this URL. /// /// Depending on which application or tool you use to encode your video stream, you may need to enter the stream URL and stream name separately or you may need to concatenate them in the following format: /// /// STREAM_URL/STREAM_NAME #[serde(rename="ingestionAddress")] - pub ingestion_address: String, + pub ingestion_address: Option<String>, } impl Part for IngestionInfo {} @@ -2334,13 +2791,13 @@ impl Part for IngestionInfo {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoCategory { /// The snippet object contains basic details about the video category, including its title. - pub snippet: VideoCategorySnippet, + pub snippet: Option<VideoCategorySnippet>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoCategory". - pub kind: String, + pub kind: Option<String>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The ID that YouTube uses to uniquely identify the video category. - pub id: String, + pub id: Option<String>, } impl Part for VideoCategory {} @@ -2354,27 +2811,27 @@ impl Part for VideoCategory {} pub struct PlaylistItemSnippet { /// The ID that YouTube uses to uniquely identify the user that added the item to the playlist. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The item's description. - pub description: String, + pub description: Option<String>, /// The item's title. - pub title: String, + pub title: Option<String>, /// The id object contains information that can be used to uniquely identify the resource that is included in the playlist as the playlist item. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, /// The ID that YouTube uses to uniquely identify the playlist that the playlist item is in. #[serde(rename="playlistId")] - pub playlist_id: String, + pub playlist_id: Option<String>, /// The date and time that the item was added to the playlist. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// Channel title for the channel that the playlist item belongs to. #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, /// The order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth. - pub position: u32, + pub position: Option<u32>, /// A map of thumbnail images associated with the playlist item. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, } impl Part for PlaylistItemSnippet {} @@ -2388,7 +2845,7 @@ impl Part for PlaylistItemSnippet {} pub struct ActivityContentDetailsFavorite { /// The resourceId object contains information that identifies the resource that was marked as a favorite. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsFavorite {} @@ -2402,9 +2859,9 @@ impl Part for ActivityContentDetailsFavorite {} pub struct VideoSuggestionsTagSuggestion { /// A set of video categories for which the tag is relevant. You can use this information to display appropriate tag suggestions based on the video category that the video uploader associates with the video. By default, tag suggestions are relevant for all categories if there are no restricts defined for the keyword. #[serde(rename="categoryRestricts")] - pub category_restricts: Vec<String>, + pub category_restricts: Option<Vec<String>>, /// The keyword tag suggested for the video. - pub tag: String, + pub tag: Option<String>, } impl Part for VideoSuggestionsTagSuggestion {} @@ -2441,7 +2898,7 @@ impl ResponseResult for ChannelBannerResource {} pub struct PlaylistContentDetails { /// The number of videos in the playlist. #[serde(rename="itemCount")] - pub item_count: u32, + pub item_count: Option<u32>, } impl Part for PlaylistContentDetails {} @@ -2455,10 +2912,10 @@ impl Part for PlaylistContentDetails {} pub struct PageInfo { /// The number of results included in the API response. #[serde(rename="resultsPerPage")] - pub results_per_page: i32, + pub results_per_page: Option<i32>, /// The total number of results in the result set. #[serde(rename="totalResults")] - pub total_results: i32, + pub total_results: Option<i32>, } impl Part for PageInfo {} @@ -2472,7 +2929,7 @@ impl Part for PageInfo {} pub struct ActivityContentDetailsLike { /// The resourceId object contains information that identifies the rated resource. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsLike {} @@ -2556,32 +3013,51 @@ impl ToParts for Playlist { pub struct PlaylistItemListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItemListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of playlist items that match the request criteria. - pub items: Vec<PlaylistItem>, + pub items: Option<Vec<PlaylistItem>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for PlaylistItemListResponse {} +impl ToParts for PlaylistItemListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// A pair Property / Value. /// @@ -2590,9 +3066,9 @@ impl ResponseResult for PlaylistItemListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PropertyValue { /// A property. - pub property: String, + pub property: Option<String>, /// The property's value. - pub value: String, + pub value: Option<String>, } impl Part for PropertyValue {} @@ -2606,13 +3082,13 @@ impl Part for PropertyValue {} pub struct InvideoTiming { /// Defines the time at which the promotion will appear. Depending on the value of type the value of the offsetMs field will represent a time offset from the start or from the end of the video, expressed in milliseconds. #[serde(rename="offsetMs")] - pub offset_ms: String, + pub offset_ms: Option<String>, /// Describes a timing type. If the value is offsetFromStart, then the offsetMs field represents an offset from the start of the video. If the value is offsetFromEnd, then the offsetMs field represents an offset from the end of the video. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Defines the duration in milliseconds for which the promotion should be displayed. If missing, the client should use the default. #[serde(rename="durationMs")] - pub duration_ms: String, + pub duration_ms: Option<String>, } impl Part for InvideoTiming {} @@ -2625,7 +3101,7 @@ impl Part for InvideoTiming {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelSectionLocalization { /// The localized strings for channel section's title. - pub title: String, + pub title: Option<String>, } impl Part for ChannelSectionLocalization {} @@ -2692,18 +3168,18 @@ impl ToParts for LiveStream { pub struct ActivityContentDetailsSocial { /// The resourceId object encapsulates information that identifies the resource associated with a social network post. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, /// An image of the post's author. #[serde(rename="imageUrl")] - pub image_url: String, + pub image_url: Option<String>, /// The name of the social network. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The URL of the social network post. #[serde(rename="referenceUrl")] - pub reference_url: String, + pub reference_url: Option<String>, /// The author of the social network post. - pub author: String, + pub author: Option<String>, } impl Part for ActivityContentDetailsSocial {} @@ -2716,31 +3192,48 @@ impl Part for ActivityContentDetailsSocial {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivitySnippet { /// A map of thumbnail images associated with the resource that is primarily associated with the activity. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, /// The title of the resource primarily associated with the activity. - pub title: String, + pub title: Option<String>, /// The ID that YouTube uses to uniquely identify the channel associated with the activity. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The date and time that the video was uploaded. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// Channel title for the channel responsible for this activity #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, /// The type of activity that the resource describes. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The group ID associated with the activity. A group ID identifies user events that are associated with the same user and resource. For example, if a user rates a video and marks the same video as a favorite, the entries for those events would have the same group ID in the user's activity feed. In your user interface, you can avoid repetition by grouping events with the same groupId value. #[serde(rename="groupId")] - pub group_id: String, + pub group_id: Option<String>, /// The description of the resource primarily associated with the activity. - pub description: String, + pub description: Option<String>, } impl Part for ActivitySnippet {} +/// ChannelSection targeting setting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionTargeting { + /// The language the channel section is targeting. + pub languages: Option<Vec<String>>, + /// The region the channel section is targeting. + pub regions: Option<Vec<String>>, + /// The country the channel section is targeting. + pub countries: Option<Vec<String>>, +} + +impl Part for ChannelSectionTargeting {} + + /// Statistics about the video, such as the number of times the video was viewed or liked. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2749,24 +3242,37 @@ impl Part for ActivitySnippet {} pub struct VideoStatistics { /// The number of comments for the video. #[serde(rename="commentCount")] - pub comment_count: i64, + pub comment_count: Option<i64>, /// The number of times the video has been viewed. #[serde(rename="viewCount")] - pub view_count: i64, + pub view_count: Option<i64>, /// The number of users who currently have the video marked as a favorite video. #[serde(rename="favoriteCount")] - pub favorite_count: i64, + pub favorite_count: Option<i64>, /// The number of users who have indicated that they disliked the video by giving it a negative rating. #[serde(rename="dislikeCount")] - pub dislike_count: i64, + pub dislike_count: Option<i64>, /// The number of users who have indicated that they liked the video by giving it a positive rating. #[serde(rename="likeCount")] - pub like_count: i64, + pub like_count: Option<i64>, } impl Part for VideoStatistics {} +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelId { + /// no description provided + pub value: Option<String>, +} + +impl Part for ChannelId {} + + /// Details about a channelsection, including playlists and channels. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2774,9 +3280,9 @@ impl Part for VideoStatistics {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelSectionContentDetails { /// The channel ids for type multiple_channels. - pub channels: Vec<String>, + pub channels: Option<Vec<String>>, /// The playlist ids for type single_playlist and multiple_playlists. For singlePlaylist, only one playlistId is allowed. - pub playlists: Vec<String>, + pub playlists: Option<Vec<String>>, } impl Part for ChannelSectionContentDetails {} @@ -2789,15 +3295,15 @@ impl Part for ChannelSectionContentDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PromotedItem { /// The temporal position within the video where the promoted item will be displayed. If present, it overrides the default timing. - pub timing: InvideoTiming, + pub timing: Option<InvideoTiming>, /// If true, the content owner's name will be used when displaying the promotion. This field can only be set when the update is made on behalf of the content owner. #[serde(rename="promotedByContentOwner")] - pub promoted_by_content_owner: bool, + pub promoted_by_content_owner: Option<bool>, /// A custom message to display for this promotion. This field is currently ignored unless the promoted item is a website. #[serde(rename="customMessage")] - pub custom_message: String, + pub custom_message: Option<String>, /// Identifies the promoted item. - pub id: PromotedItemId, + pub id: Option<PromotedItemId>, } impl Part for PromotedItem {} @@ -2810,13 +3316,13 @@ impl Part for PromotedItem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelBrandingSettings { /// Branding properties for branding images. - pub image: ImageSettings, + pub image: Option<ImageSettings>, /// Branding properties for the watch page. - pub watch: WatchSettings, + pub watch: Option<WatchSettings>, /// Branding properties for the channel view. - pub channel: ChannelSettings, + pub channel: Option<ChannelSettings>, /// Additional experimental branding properties. - pub hints: Vec<PropertyValue>, + pub hints: Option<Vec<PropertyValue>>, } impl Part for ChannelBrandingSettings {} @@ -2851,6 +3357,61 @@ pub struct InvideoBranding { impl RequestValue for InvideoBranding {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list comments](struct.CommentListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentListResponse { + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + pub event_id: Option<String>, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentListResponse". + pub kind: Option<String>, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + pub visitor_id: Option<String>, + /// A list of comments that match the request criteria. + pub items: Option<Vec<Comment>>, + /// no description provided + #[serde(rename="tokenPagination")] + pub token_pagination: Option<TokenPagination>, + /// Etag of this resource. + pub etag: Option<String>, + /// no description provided + #[serde(rename="pageInfo")] + pub page_info: Option<PageInfo>, +} + +impl ResponseResult for CommentListResponse {} + +impl ToParts for CommentListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} + /// Information about the playlist item's privacy status. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2859,7 +3420,7 @@ impl RequestValue for InvideoBranding {} pub struct PlaylistItemStatus { /// This resource's privacy status. #[serde(rename="privacyStatus")] - pub privacy_status: String, + pub privacy_status: Option<String>, } impl Part for PlaylistItemStatus {} @@ -2878,32 +3439,51 @@ impl Part for PlaylistItemStatus {} pub struct GuideCategoryListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#guideCategoryListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of categories that can be associated with YouTube channels. In this map, the category ID is the map key, and its value is the corresponding guideCategory resource. - pub items: Vec<GuideCategory>, + pub items: Option<Vec<GuideCategory>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for GuideCategoryListResponse {} +impl ToParts for GuideCategoryListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// Basic details about a channel section, including title, style and position. /// @@ -2912,22 +3492,22 @@ impl ResponseResult for GuideCategoryListResponse {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChannelSectionSnippet { /// The style of the channel section. - pub style: String, + pub style: Option<String>, /// Localized title, read-only. - pub localized: ChannelSectionLocalization, + pub localized: Option<ChannelSectionLocalization>, /// The channel section's title for multiple_playlists and multiple_channels. - pub title: String, + pub title: Option<String>, /// The position of the channel section in the channel. - pub position: u32, + pub position: Option<u32>, /// The ID that YouTube uses to uniquely identify the channel that published the channel section. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The type of the channel section. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// The language of the channel section's default title and description. #[serde(rename="defaultLanguage")] - pub default_language: String, + pub default_language: Option<String>, } impl Part for ChannelSectionSnippet {} @@ -2941,10 +3521,10 @@ impl Part for ChannelSectionSnippet {} pub struct ChannelContentDetails { /// no description provided #[serde(rename="relatedPlaylists")] - pub related_playlists: ChannelContentDetailsRelatedPlaylists, + pub related_playlists: Option<ChannelContentDetailsRelatedPlaylists>, /// The googlePlusUserId object identifies the Google+ profile ID associated with this channel. #[serde(rename="googlePlusUserId")] - pub google_plus_user_id: String, + pub google_plus_user_id: Option<String>, } impl Part for ChannelContentDetails {} @@ -2967,14 +3547,43 @@ impl Part for TokenPagination {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccessPolicy { /// A list of region codes that identify countries where the default policy do not apply. - pub exception: Vec<String>, + pub exception: Option<Vec<String>>, /// The value of allowed indicates whether the access to the policy is allowed or denied by default. - pub allowed: bool, + pub allowed: Option<bool>, } impl Part for AccessPolicy {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [report abuse videos](struct.VideoReportAbuseCall.html) (request) +/// +#[derive(Default, Clone, Debug, Serialize)] +pub struct VideoAbuseReport { + /// The specific, or secondary, reason that this content is abusive (if available). The value is an abuse report reason ID that is a valid secondary reason for the primary reason. + #[serde(rename="secondaryReasonId")] + pub secondary_reason_id: Option<String>, + /// The high-level, or primary, reason that the content is abusive. The value is an abuse report reason ID. + #[serde(rename="reasonId")] + pub reason_id: Option<String>, + /// Additional comments regarding the abuse report. + pub comments: Option<String>, + /// The language that the content was viewed in. + pub language: Option<String>, + /// The ID that YouTube uses to uniquely identify the video. + #[serde(rename="videoId")] + pub video_id: Option<String>, +} + +impl RequestValue for VideoAbuseReport {} + + /// Information that identifies the recommended resource. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -2983,12 +3592,12 @@ impl Part for AccessPolicy {} pub struct ActivityContentDetailsRecommendation { /// The resourceId object contains information that identifies the recommended resource. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, /// The reason that the resource is recommended to the user. - pub reason: String, + pub reason: Option<String>, /// The seedResourceId object contains information about the resource that caused the recommendation. #[serde(rename="seedResourceId")] - pub seed_resource_id: ResourceId, + pub seed_resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsRecommendation {} @@ -3001,30 +3610,30 @@ impl Part for ActivityContentDetailsRecommendation {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ActivityContentDetails { /// The comment object contains information about a resource that received a comment. This property is only present if the snippet.type is comment. - pub comment: ActivityContentDetailsComment, + pub comment: Option<ActivityContentDetailsComment>, /// The playlistItem object contains information about a new playlist item. This property is only present if the snippet.type is playlistItem. #[serde(rename="playlistItem")] - pub playlist_item: ActivityContentDetailsPlaylistItem, + pub playlist_item: Option<ActivityContentDetailsPlaylistItem>, /// The like object contains information about a resource that received a positive (like) rating. This property is only present if the snippet.type is like. - pub like: ActivityContentDetailsLike, + pub like: Option<ActivityContentDetailsLike>, /// The promotedItem object contains details about a resource which is being promoted. This property is only present if the snippet.type is promotedItem. #[serde(rename="promotedItem")] - pub promoted_item: ActivityContentDetailsPromotedItem, + pub promoted_item: Option<ActivityContentDetailsPromotedItem>, /// The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation. - pub recommendation: ActivityContentDetailsRecommendation, + pub recommendation: Option<ActivityContentDetailsRecommendation>, /// The favorite object contains information about a video that was marked as a favorite video. This property is only present if the snippet.type is favorite. - pub favorite: ActivityContentDetailsFavorite, + pub favorite: Option<ActivityContentDetailsFavorite>, /// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload. - pub upload: ActivityContentDetailsUpload, + pub upload: Option<ActivityContentDetailsUpload>, /// The social object contains details about a social network post. This property is only present if the snippet.type is social. - pub social: ActivityContentDetailsSocial, + pub social: Option<ActivityContentDetailsSocial>, /// The channelItem object contains details about a resource which was added to a channel. This property is only present if the snippet.type is channelItem. #[serde(rename="channelItem")] - pub channel_item: ActivityContentDetailsChannelItem, + pub channel_item: Option<ActivityContentDetailsChannelItem>, /// The bulletin object contains details about a channel bulletin post. This object is only present if the snippet.type is bulletin. - pub bulletin: ActivityContentDetailsBulletin, + pub bulletin: Option<ActivityContentDetailsBulletin>, /// The subscription object contains information about a channel that a user subscribed to. This property is only present if the snippet.type is subscription. - pub subscription: ActivityContentDetailsSubscription, + pub subscription: Option<ActivityContentDetailsSubscription>, } impl Part for ActivityContentDetails {} @@ -3076,10 +3685,10 @@ impl ToParts for I18nRegion { pub struct ChannelContentOwnerDetails { /// The ID of the content owner linked to the channel. #[serde(rename="contentOwner")] - pub content_owner: String, + pub content_owner: Option<String>, /// The date and time of when the channel was linked to the content owner. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="timeLinked")] - pub time_linked: String, + pub time_linked: Option<String>, } impl Part for ChannelContentOwnerDetails {} @@ -3093,21 +3702,37 @@ impl Part for ChannelContentOwnerDetails {} pub struct LiveBroadcastStatus { /// The broadcast's recording status. #[serde(rename="recordingStatus")] - pub recording_status: String, + pub recording_status: Option<String>, /// The broadcast's privacy status. Note that the broadcast represents exactly one YouTube video, so the privacy settings are identical to those supported for videos. In addition, you can set this field by modifying the broadcast resource or by setting the privacyStatus field of the corresponding video resource. #[serde(rename="privacyStatus")] - pub privacy_status: String, + pub privacy_status: Option<String>, /// The broadcast's status. The status can be updated using the API's liveBroadcasts.transition method. #[serde(rename="lifeCycleStatus")] - pub life_cycle_status: String, + pub life_cycle_status: Option<String>, + /// Whether or not this broadcast is the default broadcast + #[serde(rename="isDefaultBroadcast")] + pub is_default_broadcast: Option<bool>, /// Priority of the live broadcast event (internal state). #[serde(rename="liveBroadcastPriority")] - pub live_broadcast_priority: String, + pub live_broadcast_priority: Option<String>, } impl Part for LiveBroadcastStatus {} +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct VideoAbuseReportReasonId { + /// no description provided + pub value: Option<String>, +} + +impl Part for VideoAbuseReportReasonId {} + + /// Geographical coordinates of a point, in WGS84. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3115,11 +3740,11 @@ impl Part for LiveBroadcastStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoPoint { /// Latitude in degrees. - pub latitude: f64, + pub latitude: Option<f64>, /// Altitude above the reference ellipsoid, in meters. - pub altitude: f64, + pub altitude: Option<f64>, /// Longitude in degrees. - pub longitude: f64, + pub longitude: Option<f64>, } impl Part for GeoPoint {} @@ -3132,13 +3757,13 @@ impl Part for GeoPoint {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoAgeGating { /// Age-restricted trailers. For redband trailers and adult-rated video-games. Only users aged 18+ can view the content. The the field is true the content is restricted to viewers aged 18+. Otherwise The field won't be present. - pub restricted: bool, + pub restricted: Option<bool>, /// Indicates whether or not the video has alcoholic beverage content. Only users of legal purchasing age in a particular country, as identified by ICAP, can view the content. #[serde(rename="alcoholContent")] - pub alcohol_content: bool, + pub alcohol_content: Option<bool>, /// Video game rating, if any. #[serde(rename="videoGameRating")] - pub video_game_rating: String, + pub video_game_rating: Option<String>, } impl Part for VideoAgeGating {} @@ -3152,7 +3777,7 @@ impl Part for VideoAgeGating {} pub struct VideoPlayer { /// An <iframe> tag that embeds a player that will play the video. #[serde(rename="embedHtml")] - pub embed_html: String, + pub embed_html: Option<String>, } impl Part for VideoPlayer {} @@ -3166,18 +3791,20 @@ impl Part for VideoPlayer {} pub struct ChannelSnippet { /// The date and time that the channel was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, - /// The description of the channel. - pub description: String, + pub published_at: Option<String>, + /// A map of thumbnail images associated with the channel. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + pub thumbnails: Option<ThumbnailDetails>, /// The channel's title. - pub title: String, + pub title: Option<String>, + /// The country of the channel. + pub country: Option<String>, /// Localized title and description, read-only. - pub localized: ChannelLocalization, + pub localized: Option<ChannelLocalization>, /// The language of the channel's default title and description. #[serde(rename="defaultLanguage")] - pub default_language: String, - /// A map of thumbnail images associated with the channel. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub default_language: Option<String>, + /// The description of the channel. + pub description: Option<String>, } impl Part for ChannelSnippet {} @@ -3191,13 +3818,13 @@ impl Part for ChannelSnippet {} pub struct WatchSettings { /// The background color for the video watch page's branded area. #[serde(rename="textColor")] - pub text_color: String, + pub text_color: Option<String>, /// An ID that uniquely identifies a playlist that displays next to the video player. #[serde(rename="featuredPlaylistId")] - pub featured_playlist_id: String, + pub featured_playlist_id: Option<String>, /// The text color for the video watch page's branded area. #[serde(rename="backgroundColor")] - pub background_color: String, + pub background_color: Option<String>, } impl Part for WatchSettings {} @@ -3211,6 +3838,7 @@ impl Part for WatchSettings {} /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [rate videos](struct.VideoRateCall.html) (none) +/// * [report abuse videos](struct.VideoReportAbuseCall.html) (none) /// * [get rating videos](struct.VideoGetRatingCall.html) (none) /// * [list videos](struct.VideoListCall.html) (none) /// * [insert videos](struct.VideoInsertCall.html) (request|response) @@ -3312,30 +3940,75 @@ impl ToParts for Video { #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoContentDetails { /// The value of definition indicates whether the video is available in high definition or only in standard definition. - pub definition: String, + pub definition: Option<String>, /// The countryRestriction object contains information about the countries where a video is (or is not) viewable. #[serde(rename="countryRestriction")] - pub country_restriction: AccessPolicy, + pub country_restriction: Option<AccessPolicy>, /// Specifies the ratings that the video received under various rating schemes. #[serde(rename="contentRating")] - pub content_rating: ContentRating, + pub content_rating: Option<ContentRating>, /// The value of captions indicates whether the video has captions or not. - pub caption: String, + pub caption: Option<String>, /// The regionRestriction object contains information about the countries where a video is (or is not) viewable. The object will contain either the contentDetails.regionRestriction.allowed property or the contentDetails.regionRestriction.blocked property. #[serde(rename="regionRestriction")] - pub region_restriction: VideoContentDetailsRegionRestriction, + pub region_restriction: Option<VideoContentDetailsRegionRestriction>, /// The length of the video. The tag value is an ISO 8601 duration in the format PT#M#S, in which the letters PT indicate that the value specifies a period of time, and the letters M and S refer to length in minutes and seconds, respectively. The # characters preceding the M and S letters are both integers that specify the number of minutes (or seconds) of the video. For example, a value of PT15M51S indicates that the video is 15 minutes and 51 seconds long. - pub duration: String, + pub duration: Option<String>, /// The value of is_license_content indicates whether the video is licensed content. #[serde(rename="licensedContent")] - pub licensed_content: bool, + pub licensed_content: Option<bool>, /// The value of dimension indicates whether the video is available in 3D or in 2D. - pub dimension: String, + pub dimension: Option<String>, } impl Part for VideoContentDetails {} +/// A comment thread represents information that applies to a top level comment and all its replies. It can also include the top level comment itself and some of the replies. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [update comment threads](struct.CommentThreadUpdateCall.html) (request|response) +/// * [list comment threads](struct.CommentThreadListCall.html) (none) +/// * [insert comment threads](struct.CommentThreadInsertCall.html) (request|response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThread { + /// The snippet object contains basic details about the comment thread and also the top level comment. + pub snippet: Option<CommentThreadSnippet>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThread". + pub kind: Option<String>, + /// Etag of this resource. + pub etag: Option<String>, + /// The ID that YouTube uses to uniquely identify the comment thread. + pub id: Option<String>, + /// The replies object contains a limited number of replies (if any) to the top level comment found in the snippet. + pub replies: Option<CommentThreadReplies>, +} + +impl RequestValue for CommentThread {} +impl Resource for CommentThread {} +impl ResponseResult for CommentThread {} + +impl ToParts for CommentThread { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.replies.is_some() { r = r + "replies,"; } + r.pop(); + r + } +} + /// Describes a single promoted item id. It is a union of various possible types. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3344,16 +4017,16 @@ impl Part for VideoContentDetails {} pub struct PromotedItemId { /// If the promoted item represents a website, this field represents the url pointing to the website. This field will be present only if type has the value website. #[serde(rename="websiteUrl")] - pub website_url: String, + pub website_url: Option<String>, /// If type is recentUpload, this field identifies the channel from which to take the recent upload. If missing, the channel is assumed to be the same channel for which the invideoPromotion is set. #[serde(rename="recentlyUploadedBy")] - pub recently_uploaded_by: String, + pub recently_uploaded_by: Option<String>, /// Describes the type of the promoted item. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// If the promoted item represents a video, this field represents the unique YouTube ID identifying it. This field will be present only if type has the value video. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, } impl Part for PromotedItemId {} @@ -3367,36 +4040,36 @@ impl Part for PromotedItemId {} pub struct VideoFileDetails { /// The uploaded video file's combined (video and audio) bitrate in bits per second. #[serde(rename="bitrateBps")] - pub bitrate_bps: String, + pub bitrate_bps: Option<String>, /// The uploaded video file's container format. - pub container: String, + pub container: Option<String>, /// Geographic coordinates that identify the place where the uploaded video was recorded. Coordinates are defined using WGS 84. #[serde(rename="recordingLocation")] - pub recording_location: GeoPoint, + pub recording_location: Option<GeoPoint>, /// The uploaded file's type as detected by YouTube's video processing engine. Currently, YouTube only processes video files, but this field is present whether a video file or another type of file was uploaded. #[serde(rename="fileType")] - pub file_type: String, + pub file_type: Option<String>, /// The date and time when the uploaded video file was created. The value is specified in ISO 8601 format. Currently, the following ISO 8601 formats are supported: /// - Date only: YYYY-MM-DD /// - Naive time: YYYY-MM-DDTHH:MM:SS /// - Time with timezone: YYYY-MM-DDTHH:MM:SS+HH:MM #[serde(rename="creationTime")] - pub creation_time: String, + pub creation_time: Option<String>, /// The length of the uploaded video in milliseconds. #[serde(rename="durationMs")] - pub duration_ms: String, + pub duration_ms: Option<String>, /// The uploaded file's name. This field is present whether a video file or another type of file was uploaded. #[serde(rename="fileName")] - pub file_name: String, + pub file_name: Option<String>, /// The uploaded file's size in bytes. This field is present whether a video file or another type of file was uploaded. #[serde(rename="fileSize")] - pub file_size: String, + pub file_size: Option<String>, /// A list of video streams contained in the uploaded video file. Each item in the list contains detailed metadata about a video stream. #[serde(rename="videoStreams")] - pub video_streams: Vec<VideoFileDetailsVideoStream>, + pub video_streams: Option<Vec<VideoFileDetailsVideoStream>>, /// A list of audio streams contained in the uploaded video file. Each item in the list contains detailed metadata about an audio stream. #[serde(rename="audioStreams")] - pub audio_streams: Vec<VideoFileDetailsAudioStream>, + pub audio_streams: Option<Vec<VideoFileDetailsAudioStream>>, } impl Part for VideoFileDetails {} @@ -3410,10 +4083,10 @@ impl Part for VideoFileDetails {} pub struct InvideoPosition { /// Describes in which corner of the video the visual widget will appear. #[serde(rename="cornerPosition")] - pub corner_position: String, + pub corner_position: Option<String>, /// Defines the position type. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, } impl Part for InvideoPosition {} @@ -3426,7 +4099,7 @@ impl Part for InvideoPosition {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoProjectDetails { /// A list of project tags associated with the video during the upload. - pub tags: Vec<String>, + pub tags: Option<Vec<String>>, } impl Part for VideoProjectDetails {} @@ -3439,27 +4112,27 @@ impl Part for VideoProjectDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoStatus { /// The video's license. - pub license: String, + pub license: Option<String>, /// This value indicates if the video can be embedded on another website. - pub embeddable: bool, + pub embeddable: Option<bool>, /// The video's privacy status. #[serde(rename="privacyStatus")] - pub privacy_status: String, + pub privacy_status: Option<String>, /// The date and time when the video is scheduled to publish. It can be set only if the privacy status of the video is private. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishAt")] - pub publish_at: String, + pub publish_at: Option<String>, /// This value indicates if the extended video statistics on the watch page can be viewed by everyone. Note that the view count, likes, etc will still be visible if this is disabled. #[serde(rename="publicStatsViewable")] - pub public_stats_viewable: bool, + pub public_stats_viewable: Option<bool>, /// The status of the uploaded video. #[serde(rename="uploadStatus")] - pub upload_status: String, + pub upload_status: Option<String>, /// This value explains why YouTube rejected an uploaded video. This property is only present if the uploadStatus property indicates that the upload was rejected. #[serde(rename="rejectionReason")] - pub rejection_reason: String, + pub rejection_reason: Option<String>, /// This value explains why a video failed to upload. This property is only present if the uploadStatus property indicates that the upload failed. #[serde(rename="failureReason")] - pub failure_reason: String, + pub failure_reason: Option<String>, } impl Part for VideoStatus {} @@ -3472,9 +4145,9 @@ impl Part for VideoStatus {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoLocalization { /// Localized version of the video's description. - pub description: String, + pub description: Option<String>, /// Localized version of the video's title. - pub title: String, + pub title: Option<String>, } impl Part for VideoLocalization {} @@ -3488,7 +4161,7 @@ impl Part for VideoLocalization {} pub struct ActivityContentDetailsSubscription { /// The resourceId object contains information that identifies the resource that the user subscribed to. #[serde(rename="resourceId")] - pub resource_id: ResourceId, + pub resource_id: Option<ResourceId>, } impl Part for ActivityContentDetailsSubscription {} @@ -3555,19 +4228,19 @@ impl ToParts for LiveBroadcast { pub struct ChannelStatistics { /// The number of comments for the channel. #[serde(rename="commentCount")] - pub comment_count: i64, + pub comment_count: Option<i64>, /// The number of subscribers that the channel has. #[serde(rename="subscriberCount")] - pub subscriber_count: i64, + pub subscriber_count: Option<i64>, /// The number of videos uploaded to the channel. #[serde(rename="videoCount")] - pub video_count: i64, + pub video_count: Option<i64>, /// Whether or not the number of subscribers is shown for this user. #[serde(rename="hiddenSubscriberCount")] - pub hidden_subscriber_count: bool, + pub hidden_subscriber_count: Option<bool>, /// The number of times the channel has been viewed. #[serde(rename="viewCount")] - pub view_count: i64, + pub view_count: Option<i64>, } impl Part for ChannelStatistics {} @@ -3580,16 +4253,16 @@ impl Part for ChannelStatistics {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResourceId { /// The type of the API resource. - pub kind: String, + pub kind: Option<String>, /// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a channel. This property is only present if the resourceId.kind value is youtube#channel. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a playlist. This property is only present if the resourceId.kind value is youtube#playlist. #[serde(rename="playlistId")] - pub playlist_id: String, + pub playlist_id: Option<String>, /// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a video. This property is only present if the resourceId.kind value is youtube#video. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, } impl Part for ResourceId {} @@ -3603,7 +4276,7 @@ impl Part for ResourceId {} pub struct ActivityContentDetailsUpload { /// The ID that YouTube uses to uniquely identify the uploaded video. #[serde(rename="videoId")] - pub video_id: String, + pub video_id: Option<String>, } impl Part for ActivityContentDetailsUpload {} @@ -3622,32 +4295,51 @@ impl Part for ActivityContentDetailsUpload {} pub struct ActivityListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#activityListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of activities, or events, that match the request criteria. - pub items: Vec<Activity>, + pub items: Option<Vec<Activity>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for ActivityListResponse {} +impl ToParts for ActivityListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -3657,7 +4349,7 @@ impl ResponseResult for ActivityListResponse {} pub struct PlaylistPlayer { /// An <iframe> tag that embeds a player that will play the playlist. #[serde(rename="embedHtml")] - pub embed_html: String, + pub embed_html: Option<String>, } impl Part for PlaylistPlayer {} @@ -3671,7 +4363,7 @@ impl Part for PlaylistPlayer {} pub struct ChannelTopicDetails { /// A list of Freebase topic IDs associated with the channel. You can retrieve information about each topic using the Freebase Topic API. #[serde(rename="topicIds")] - pub topic_ids: Vec<String>, + pub topic_ids: Option<Vec<String>>, } impl Part for ChannelTopicDetails {} @@ -3685,12 +4377,12 @@ impl Part for ChannelTopicDetails {} pub struct VideoRecordingDetails { /// The date and time when the video was recorded. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sssZ) format. #[serde(rename="recordingDate")] - pub recording_date: String, + pub recording_date: Option<String>, /// The text description of the location where the video was recorded. #[serde(rename="locationDescription")] - pub location_description: String, + pub location_description: Option<String>, /// The geolocation information associated with the video. - pub location: GeoPoint, + pub location: Option<GeoPoint>, } impl Part for VideoRecordingDetails {} @@ -3704,7 +4396,7 @@ impl Part for VideoRecordingDetails {} pub struct PlaylistStatus { /// The playlist's privacy status. #[serde(rename="privacyStatus")] - pub privacy_status: String, + pub privacy_status: Option<String>, } impl Part for PlaylistStatus {} @@ -3718,17 +4410,17 @@ impl Part for PlaylistStatus {} pub struct MonitorStreamInfo { /// If you have set the enableMonitorStream property to true, then this property determines the length of the live broadcast delay. #[serde(rename="broadcastStreamDelayMs")] - pub broadcast_stream_delay_ms: u32, + pub broadcast_stream_delay_ms: Option<u32>, /// HTML code that embeds a player that plays the monitor stream. #[serde(rename="embedHtml")] - pub embed_html: String, + pub embed_html: Option<String>, /// This value determines whether the monitor stream is enabled for the broadcast. If the monitor stream is enabled, then YouTube will broadcast the event content on a special stream intended only for the broadcaster's consumption. The broadcaster can use the stream to review the event content and also to identify the optimal times to insert cuepoints. /// /// You need to set this value to true if you intend to have a broadcast delay for your event. /// /// Note: This property cannot be updated once the broadcast is in the testing or live state. #[serde(rename="enableMonitorStream")] - pub enable_monitor_stream: bool, + pub enable_monitor_stream: Option<bool>, } impl Part for MonitorStreamInfo {} @@ -3742,19 +4434,19 @@ impl Part for MonitorStreamInfo {} pub struct VideoLiveStreamingDetails { /// The number of viewers currently watching the broadcast. The property and its value will be present if the broadcast has current viewers and the broadcast owner has not hidden the viewcount for the video. Note that YouTube stops tracking the number of concurrent viewers for a broadcast when the broadcast ends. So, this property would not identify the number of viewers watching an archived video of a live broadcast that already ended. #[serde(rename="concurrentViewers")] - pub concurrent_viewers: String, + pub concurrent_viewers: Option<String>, /// The time that the broadcast is scheduled to begin. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="scheduledStartTime")] - pub scheduled_start_time: String, + pub scheduled_start_time: Option<String>, /// The time that the broadcast is scheduled to end. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. If the value is empty or the property is not present, then the broadcast is scheduled to continue indefinitely. #[serde(rename="scheduledEndTime")] - pub scheduled_end_time: String, + pub scheduled_end_time: Option<String>, /// The time that the broadcast actually started. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. This value will not be available until the broadcast begins. #[serde(rename="actualStartTime")] - pub actual_start_time: String, + pub actual_start_time: Option<String>, /// The time that the broadcast actually ended. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. This value will not be available until the broadcast is over. #[serde(rename="actualEndTime")] - pub actual_end_time: String, + pub actual_end_time: Option<String>, } impl Part for VideoLiveStreamingDetails {} @@ -3768,45 +4460,39 @@ impl Part for VideoLiveStreamingDetails {} pub struct VideoTopicDetails { /// A list of Freebase topic IDs that are centrally associated with the video. These are topics that are centrally featured in the video, and it can be said that the video is mainly about each of these. You can retrieve information about each topic using the Freebase Topic API. #[serde(rename="topicIds")] - pub topic_ids: Vec<String>, + pub topic_ids: Option<Vec<String>>, /// Similar to topic_id, except that these topics are merely relevant to the video. These are topics that may be mentioned in, or appear in the video. You can retrieve information about each topic using Freebase Topic API. #[serde(rename="relevantTopicIds")] - pub relevant_topic_ids: Vec<String>, + pub relevant_topic_ids: Option<Vec<String>>, } impl Part for VideoTopicDetails {} -/// A caption resource represents a YouTube caption track. A caption track is associated with exactly one YouTube video. +/// A videoAbuseReportReason resource identifies a reason that a video could be reported as abusive. Video abuse report reasons are used with video.ReportAbuse. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// -/// * [update captions](struct.CaptionUpdateCall.html) (request|response) -/// * [list captions](struct.CaptionListCall.html) (none) -/// * [delete captions](struct.CaptionDeleteCall.html) (none) -/// * [insert captions](struct.CaptionInsertCall.html) (request|response) -/// * [download captions](struct.CaptionDownloadCall.html) (none) +/// * [list video abuse report reasons](struct.VideoAbuseReportReasonListCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] -pub struct Caption { - /// The snippet object contains basic details about the caption. - pub snippet: Option<CaptionSnippet>, - /// Identifies what kind of resource this is. Value: the fixed string "youtube#caption". +pub struct VideoAbuseReportReason { + /// The snippet object contains basic details about the abuse report reason. + pub snippet: Option<VideoAbuseReportReasonSnippet>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoAbuseReportReason". pub kind: Option<String>, /// Etag of this resource. pub etag: Option<String>, - /// The ID that YouTube uses to uniquely identify the caption track. + /// The ID of this abuse report reason. pub id: Option<String>, } -impl RequestValue for Caption {} -impl Resource for Caption {} -impl ResponseResult for Caption {} +impl Resource for VideoAbuseReportReason {} -impl ToParts for Caption { +impl ToParts for VideoAbuseReportReason { /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or /// the parts you want to see in the server response. @@ -3872,18 +4558,73 @@ impl ToParts for Activity { pub struct SubscriptionSubscriberSnippet { /// The channel ID of the subscriber. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The description of the subscriber. - pub description: String, + pub description: Option<String>, /// Thumbnails for this subscriber. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, /// The title of the subscriber. - pub title: String, + pub title: Option<String>, } impl Part for SubscriptionSubscriberSnippet {} +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list comment threads](struct.CommentThreadListCall.html) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadListResponse { + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + pub event_id: Option<String>, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + pub next_page_token: Option<String>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThreadListResponse". + pub kind: Option<String>, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + pub visitor_id: Option<String>, + /// A list of comment threads that match the request criteria. + pub items: Option<Vec<CommentThread>>, + /// no description provided + #[serde(rename="tokenPagination")] + pub token_pagination: Option<TokenPagination>, + /// Etag of this resource. + pub etag: Option<String>, + /// no description provided + #[serde(rename="pageInfo")] + pub page_info: Option<PageInfo>, +} + +impl ResponseResult for CommentThreadListResponse {} + +impl ToParts for CommentThreadListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} + /// Playlist localization setting /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3891,9 +4632,9 @@ impl Part for SubscriptionSubscriberSnippet {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlaylistLocalization { /// The localized strings for playlist's description. - pub description: String, + pub description: Option<String>, /// The localized strings for playlist's title. - pub title: String, + pub title: Option<String>, } impl Part for PlaylistLocalization {} @@ -3906,7 +4647,7 @@ impl Part for PlaylistLocalization {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoConversionPings { /// Pings that the app shall fire for a video (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. - pub pings: Vec<VideoConversionPing>, + pub pings: Option<Vec<VideoConversionPing>>, } impl Part for VideoConversionPings {} @@ -3958,33 +4699,62 @@ impl ToParts for I18nLanguage { pub struct LiveBroadcastSnippet { /// The date and time that the broadcast actually ended. This information is only available once the broadcast's state is complete. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="actualEndTime")] - pub actual_end_time: String, + pub actual_end_time: Option<String>, /// The broadcast's description. As with the title, you can set this field by modifying the broadcast resource or by setting the description field of the corresponding video resource. - pub description: String, + pub description: Option<String>, /// The broadcast's title. Note that the broadcast represents exactly one YouTube video. You can set this field by modifying the broadcast resource or by setting the title field of the corresponding video resource. - pub title: String, + pub title: Option<String>, /// The ID that YouTube uses to uniquely identify the channel that is publishing the broadcast. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The date and time that the broadcast was added to YouTube's live broadcast schedule. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// The date and time that the broadcast is scheduled to start. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="scheduledStartTime")] - pub scheduled_start_time: String, + pub scheduled_start_time: Option<String>, /// The date and time that the broadcast actually started. This information is only available once the broadcast's state is live. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="actualStartTime")] - pub actual_start_time: String, + pub actual_start_time: Option<String>, /// The date and time that the broadcast is scheduled to end. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="scheduledEndTime")] - pub scheduled_end_time: String, + pub scheduled_end_time: Option<String>, /// A map of thumbnail images associated with the broadcast. For each nested object in this object, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, } impl Part for LiveBroadcastSnippet {} +/// Basic details about a comment thread. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadSnippet { + /// The top level comment of this thread. + #[serde(rename="topLevelComment")] + pub top_level_comment: Option<Comment>, + /// Whether the current viewer of the thread can reply to it. This is viewer specific - other viewers may see a different value for this field. + #[serde(rename="canReply")] + pub can_reply: Option<bool>, + /// The YouTube channel the comments in the thread refer to or the channel with the video the comments refer to. If video_id isn't set the comments refer to the channel itself. + #[serde(rename="channelId")] + pub channel_id: Option<String>, + /// The total number of replies (not including the top level comment). + #[serde(rename="totalReplyCount")] + pub total_reply_count: Option<u32>, + /// Whether the thread (and therefore all its comments) is visible to all YouTube users. + #[serde(rename="isPublic")] + pub is_public: Option<bool>, + /// The ID of the video the comments refer to, if any. No video_id implies a channel discussion comment. + #[serde(rename="videoId")] + pub video_id: Option<String>, +} + +impl Part for CommentThreadSnippet {} + + /// Detailed settings of a broadcast. /// /// This type is not used in any activity, and only used as *part* of another schema. @@ -3993,36 +4763,36 @@ impl Part for LiveBroadcastSnippet {} pub struct LiveBroadcastContentDetails { /// This setting indicates whether the broadcast should automatically begin with an in-stream slate when you update the broadcast's status to live. After updating the status, you then need to send a liveCuepoints.insert request that sets the cuepoint's eventState to end to remove the in-stream slate and make your broadcast stream visible to viewers. #[serde(rename="startWithSlate")] - pub start_with_slate: bool, + pub start_with_slate: Option<bool>, /// This value uniquely identifies the live stream bound to the broadcast. #[serde(rename="boundStreamId")] - pub bound_stream_id: String, + pub bound_stream_id: Option<String>, /// This setting indicates whether the broadcast video can be played in an embedded player. If you choose to archive the video (using the enableArchive property), this setting will also apply to the archived video. #[serde(rename="enableEmbed")] - pub enable_embed: bool, + pub enable_embed: Option<bool>, /// This setting indicates whether closed captioning is enabled for this broadcast. The ingestion URL of the closed captions is returned through the liveStreams API. #[serde(rename="enableClosedCaptions")] - pub enable_closed_captions: bool, + pub enable_closed_captions: Option<bool>, /// This setting indicates whether YouTube should enable content encryption for the broadcast. #[serde(rename="enableContentEncryption")] - pub enable_content_encryption: bool, + pub enable_content_encryption: Option<bool>, /// Automatically start recording after the event goes live. The default value for this property is true. /// /// /// /// Important: You must also set the enableDvr property's value to true if you want the playback to be available immediately after the broadcast ends. If you set this property's value to true but do not also set the enableDvr property to true, there may be a delay of around one day before the archived video will be available for playback. #[serde(rename="recordFromStart")] - pub record_from_start: bool, + pub record_from_start: Option<bool>, /// This setting determines whether viewers can access DVR controls while watching the video. DVR controls enable the viewer to control the video playback experience by pausing, rewinding, or fast forwarding content. The default value for this property is true. /// /// /// /// Important: You must set the value to true and also set the enableArchive property's value to true if you want to make playback available immediately after the broadcast ends. #[serde(rename="enableDvr")] - pub enable_dvr: bool, + pub enable_dvr: Option<bool>, /// The monitorStream object contains information about the monitor stream, which the broadcaster can use to review the event content before the broadcast stream is shown publicly. #[serde(rename="monitorStream")] - pub monitor_stream: MonitorStreamInfo, + pub monitor_stream: Option<MonitorStreamInfo>, } impl Part for LiveBroadcastContentDetails {} @@ -4035,10 +4805,10 @@ impl Part for LiveBroadcastContentDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoConversionPing { /// Defines the context of the ping. - pub context: String, + pub context: Option<String>, /// The url (without the schema) that the app shall send the ping to. It's at caller's descretion to decide which schema to use (http vs https) Example of a returned url: //googleads.g.doubleclick.net/pagead/ viewthroughconversion/962985656/?data=path%3DtHe_path%3Btype%3D like%3Butuid%3DGISQtTNGYqaYl4sKxoVvKA%3Bytvid%3DUrIaJUvIQDg&labe=default The caller must append biscotti authentication (ms param in case of mobile, for example) to this ping. #[serde(rename="conversionUrl")] - pub conversion_url: String, + pub conversion_url: Option<String>, } impl Part for VideoConversionPing {} @@ -4051,12 +4821,12 @@ impl Part for VideoConversionPing {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoCategorySnippet { /// no description provided - pub assignable: bool, + pub assignable: Option<bool>, /// The YouTube channel that created the video category. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The video category's title. - pub title: String, + pub title: Option<String>, } impl Part for VideoCategorySnippet {} @@ -4075,32 +4845,51 @@ impl Part for VideoCategorySnippet {} pub struct SearchListResponse { /// Serialized EventId of the request which produced this response. #[serde(rename="eventId")] - pub event_id: String, + pub event_id: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. #[serde(rename="nextPageToken")] - pub next_page_token: String, + pub next_page_token: Option<String>, /// Identifies what kind of resource this is. Value: the fixed string "youtube#searchListResponse". - pub kind: String, + pub kind: Option<String>, /// The visitorId identifies the visitor. #[serde(rename="visitorId")] - pub visitor_id: String, + pub visitor_id: Option<String>, /// A list of results that match the search criteria. - pub items: Vec<SearchResult>, + pub items: Option<Vec<SearchResult>>, /// no description provided #[serde(rename="tokenPagination")] - pub token_pagination: TokenPagination, + pub token_pagination: Option<TokenPagination>, /// Etag of this resource. - pub etag: String, + pub etag: Option<String>, /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. #[serde(rename="prevPageToken")] - pub prev_page_token: String, + pub prev_page_token: Option<String>, /// no description provided #[serde(rename="pageInfo")] - pub page_info: PageInfo, + pub page_info: Option<PageInfo>, } impl ResponseResult for SearchListResponse {} +impl ToParts for SearchListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.event_id.is_some() { r = r + "eventId,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + r.pop(); + r + } +} /// Specifies suggestions on how to improve video content, including encoding hints, tag suggestions, and editor suggestions. /// @@ -4110,19 +4899,19 @@ impl ResponseResult for SearchListResponse {} pub struct VideoSuggestions { /// A list of errors that will prevent YouTube from successfully processing the uploaded video video. These errors indicate that, regardless of the video's current processing status, eventually, that status will almost certainly be failed. #[serde(rename="processingErrors")] - pub processing_errors: Vec<String>, + pub processing_errors: Option<Vec<String>>, /// A list of keyword tags that could be added to the video's metadata to increase the likelihood that users will locate your video when searching or browsing on YouTube. #[serde(rename="tagSuggestions")] - pub tag_suggestions: Vec<VideoSuggestionsTagSuggestion>, + pub tag_suggestions: Option<Vec<VideoSuggestionsTagSuggestion>>, /// A list of video editing operations that might improve the video quality or playback experience of the uploaded video. #[serde(rename="editorSuggestions")] - pub editor_suggestions: Vec<String>, + pub editor_suggestions: Option<Vec<String>>, /// A list of reasons why YouTube may have difficulty transcoding the uploaded video or that might result in an erroneous transcoding. These warnings are generated before YouTube actually processes the uploaded video file. In addition, they identify issues that are unlikely to cause the video processing to fail but that might cause problems such as sync issues, video artifacts, or a missing audio track. #[serde(rename="processingWarnings")] - pub processing_warnings: Vec<String>, + pub processing_warnings: Option<Vec<String>>, /// A list of suggestions that may improve YouTube's ability to process the video. #[serde(rename="processingHints")] - pub processing_hints: Vec<String>, + pub processing_hints: Option<Vec<String>>, } impl Part for VideoSuggestions {} @@ -4136,22 +4925,22 @@ impl Part for VideoSuggestions {} pub struct SearchResultSnippet { /// It indicates if the resource (video or channel) has upcoming/active live broadcast content. Or it's "none" if there is not any upcoming/active live broadcasts. #[serde(rename="liveBroadcastContent")] - pub live_broadcast_content: String, + pub live_broadcast_content: Option<String>, /// A description of the search result. - pub description: String, + pub description: Option<String>, /// The title of the search result. - pub title: String, + pub title: Option<String>, /// A map of thumbnail images associated with the search result. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. - pub thumbnails: ThumbnailDetails, + pub thumbnails: Option<ThumbnailDetails>, /// The value that YouTube uses to uniquely identify the channel that published the resource that the search result identifies. #[serde(rename="channelId")] - pub channel_id: String, + pub channel_id: Option<String>, /// The creation date and time of the resource that the search result identifies. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// The title of the channel that published the resource that the search result identifies. #[serde(rename="channelTitle")] - pub channel_title: String, + pub channel_title: Option<String>, } impl Part for SearchResultSnippet {} @@ -4673,7 +5462,7 @@ impl<'a, C, A> ThumbnailMethods<'a, C, A> { /// <MemoryStorage as Default>::default(), None); /// let mut hub = YouTube::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* -/// // like `delete(...)`, `get_rating(...)`, `insert(...)`, `list(...)`, `rate(...)` and `update(...)` +/// // like `delete(...)`, `get_rating(...)`, `insert(...)`, `list(...)`, `rate(...)`, `report_abuse(...)` and `update(...)` /// // to build up your call. /// let rb = hub.videos(); /// # } @@ -4688,6 +5477,24 @@ impl<'a, C, A> MethodsBuilder for VideoMethods<'a, C, A> {} impl<'a, C, A> VideoMethods<'a, C, A> { + /// Create a builder to help you perform the following task: + /// + /// Report abuse for a video. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn report_abuse(&self, request: &VideoAbuseReport) -> VideoReportAbuseCall<'a, C, A> { + VideoReportAbuseCall { + hub: self.hub, + _request: request.clone(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + /// Create a builder to help you perform the following task: /// /// Returns a list of videos that match the API request parameters. @@ -5069,6 +5876,110 @@ impl<'a, C, A> I18nRegionMethods<'a, C, A> { +/// A builder providing access to all methods supported on *commentThread* resources. +/// It is not used directly, but through the `YouTube` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_youtube3 as youtube3; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use youtube3::YouTube; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.comment_threads(); +/// # } +/// ``` +pub struct CommentThreadMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, +} + +impl<'a, C, A> MethodsBuilder for CommentThreadMethods<'a, C, A> {} + +impl<'a, C, A> CommentThreadMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of comment threads that match the API request parameters. + /// + /// # Arguments + /// + /// * `part` - The part parameter specifies the commentThread resource parts that the API response will include. Supported values are id, snippet and replies. + pub fn list(&self, part: &str) -> CommentThreadListCall<'a, C, A> { + CommentThreadListCall { + hub: self.hub, + _part: part.to_string(), + _video_id: Default::default(), + _text_format: Default::default(), + _search_terms: Default::default(), + _page_token: Default::default(), + _moderation_status: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _channel_id: Default::default(), + _all_threads_related_to_channel_id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Modifies an existing comment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: &CommentThread) -> CommentThreadUpdateCall<'a, C, A> { + CommentThreadUpdateCall { + hub: self.hub, + _request: request.clone(), + _part: request.to_parts(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Creates a new comment thread and top level comment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: &CommentThread) -> CommentThreadInsertCall<'a, C, A> { + CommentThreadInsertCall { + hub: self.hub, + _request: request.clone(), + _part: request.to_parts(), + _share_on_google_plus: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *liveStream* resources. /// It is not used directly, but through the `YouTube` hub. /// @@ -5192,6 +6103,161 @@ impl<'a, C, A> LiveStreamMethods<'a, C, A> { +/// A builder providing access to all methods supported on *comment* resources. +/// It is not used directly, but through the `YouTube` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_youtube3 as youtube3; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use youtube3::YouTube; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)`, `mark_as_spam(...)`, `set_moderation_status(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.comments(); +/// # } +/// ``` +pub struct CommentMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, +} + +impl<'a, C, A> MethodsBuilder for CommentMethods<'a, C, A> {} + +impl<'a, C, A> CommentMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Creates a new comment. + /// + /// Note: to create a top level comment it is also necessary to create a comment thread. Both are accomplished through the commentThreads resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: &Comment) -> CommentInsertCall<'a, C, A> { + CommentInsertCall { + hub: self.hub, + _request: request.clone(), + _part: request.to_parts(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Sets the moderation status of one or more comments. + /// + /// # Arguments + /// + /// * `id` - The id parameter specifies a comma-separated list of IDs of comments whose moderation status should be updated. + /// * `moderationStatus` - Determines the new moderation status of the specified comments. + pub fn set_moderation_status(&self, id: &str, moderation_status: &str) -> CommentSetModerationStatuCall<'a, C, A> { + CommentSetModerationStatuCall { + hub: self.hub, + _id: id.to_string(), + _moderation_status: moderation_status.to_string(), + _ban_author: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a comment. + /// + /// # Arguments + /// + /// * `id` - The id parameter specifies the comment ID for the resource that should be deleted. + pub fn delete(&self, id: &str) -> CommentDeleteCall<'a, C, A> { + CommentDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of comments that match the API request parameters. + /// + /// # Arguments + /// + /// * `part` - The part parameter specifies the comment resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, part: &str) -> CommentListCall<'a, C, A> { + CommentListCall { + hub: self.hub, + _part: part.to_string(), + _text_format: Default::default(), + _parent_id: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Modifies an existing comment. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: &Comment) -> CommentUpdateCall<'a, C, A> { + CommentUpdateCall { + hub: self.hub, + _request: request.clone(), + _part: request.to_parts(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Expresses the caller's opinion that a comment is spam. + /// + /// # Arguments + /// + /// * `id` - The id parameter specifies a comma-separated list of IDs of comments which should get flagged as spam. + pub fn mark_as_spam(&self, id: &str) -> CommentMarkAsSpamCall<'a, C, A> { + CommentMarkAsSpamCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *channel* resources. /// It is not used directly, but through the `YouTube` hub. /// @@ -5280,6 +6346,65 @@ impl<'a, C, A> ChannelMethods<'a, C, A> { +/// A builder providing access to all methods supported on *videoAbuseReportReason* resources. +/// It is not used directly, but through the `YouTube` hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate yup_oauth2 as oauth2; +/// extern crate google_youtube3 as youtube3; +/// +/// # #[test] fn egal() { +/// use std::default::Default; +/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// use youtube3::YouTube; +/// +/// let secret: ApplicationSecret = Default::default(); +/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// hyper::Client::new(), +/// <MemoryStorage as Default>::default(), None); +/// let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.video_abuse_report_reasons(); +/// # } +/// ``` +pub struct VideoAbuseReportReasonMethods<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, +} + +impl<'a, C, A> MethodsBuilder for VideoAbuseReportReasonMethods<'a, C, A> {} + +impl<'a, C, A> VideoAbuseReportReasonMethods<'a, C, A> { + + /// Create a builder to help you perform the following task: + /// + /// Returns a list of abuse reasons that can be used for reporting abusive videos. + /// + /// # Arguments + /// + /// * `part` - The part parameter specifies the videoCategory resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, part: &str) -> VideoAbuseReportReasonListCall<'a, C, A> { + VideoAbuseReportReasonListCall { + hub: self.hub, + _part: part.to_string(), + _hl: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } +} + + + /// A builder providing access to all methods supported on *playlistItem* resources. /// It is not used directly, but through the `YouTube` hub. /// @@ -5580,28 +6705,6 @@ impl<'a, C, A> LiveBroadcastMethods<'a, C, A> { } } - /// Create a builder to help you perform the following task: - /// - /// Binds a YouTube broadcast to a stream or removes an existing binding between a broadcast and a stream. A broadcast can only be bound to one video stream. - /// - /// # Arguments - /// - /// * `id` - The id parameter specifies the unique ID of the broadcast that is being bound to a video stream. - /// * `part` - The part parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. - pub fn bind(&self, id: &str, part: &str) -> LiveBroadcastBindCall<'a, C, A> { - LiveBroadcastBindCall { - hub: self.hub, - _id: id.to_string(), - _part: part.to_string(), - _stream_id: Default::default(), - _on_behalf_of_content_owner_channel: Default::default(), - _on_behalf_of_content_owner: Default::default(), - _delegate: Default::default(), - _scopes: Default::default(), - _additional_params: Default::default(), - } - } - /// Create a builder to help you perform the following task: /// /// Returns a list of YouTube broadcasts that match the API request parameters. @@ -5667,6 +6770,28 @@ impl<'a, C, A> LiveBroadcastMethods<'a, C, A> { _additional_params: Default::default(), } } + + /// Create a builder to help you perform the following task: + /// + /// Binds a YouTube broadcast to a stream or removes an existing binding between a broadcast and a stream. A broadcast can only be bound to one video stream. + /// + /// # Arguments + /// + /// * `id` - The id parameter specifies the unique ID of the broadcast that is being bound to a video stream. + /// * `part` - The part parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + pub fn bind(&self, id: &str, part: &str) -> LiveBroadcastBindCall<'a, C, A> { + LiveBroadcastBindCall { + hub: self.hub, + _id: id.to_string(), + _part: part.to_string(), + _stream_id: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _scopes: Default::default(), + _additional_params: Default::default(), + } + } } @@ -5755,7 +6880,7 @@ impl<'a, C, A> CaptionMethods<'a, C, A> { /// /// # Arguments /// - /// * `part` - The part parameter specifies the caption resource parts that the API response will include. + /// * `part` - The part parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet. /// * `videoId` - The videoId parameter specifies the YouTube video ID of the video for which the API should return caption tracks. pub fn list(&self, part: &str, video_id: &str) -> CaptionListCall<'a, C, A> { CaptionListCall { @@ -6013,7 +7138,7 @@ impl<'a, C, A> ActivityMethods<'a, C, A> { /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.i18n_languages().list("part") -/// .hl("diam") +/// .hl("erat") /// .doit(); /// # } /// ``` @@ -6075,16 +7200,20 @@ impl<'a, C, A> I18nLanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6241,13 +7370,13 @@ impl<'a, C, A> I18nLanguageListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChannelBannerResource = Default::default(); +/// let mut req = ChannelBannerResource::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.channel_banners().insert(&req) -/// .on_behalf_of_content_owner("ipsum") +/// .on_behalf_of_content_owner("sadipscing") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -6323,16 +7452,20 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -6604,11 +7737,11 @@ impl<'a, C, A> ChannelBannerInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channel_sections().list("part") -/// .on_behalf_of_content_owner("et") -/// .mine(false) -/// .id("aliquyam") -/// .hl("sea") -/// .channel_id("Lorem") +/// .on_behalf_of_content_owner("eirmod") +/// .mine(true) +/// .id("amet") +/// .hl("no") +/// .channel_id("labore") /// .doit(); /// # } /// ``` @@ -6686,16 +7819,20 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -6895,7 +8032,7 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChannelSection = Default::default(); +/// let mut req = ChannelSection::default(); /// req.snippet = Default::default(); // is ChannelSectionSnippet /// req.content_details = Default::default(); // is ChannelSectionContentDetails /// @@ -6903,8 +8040,8 @@ impl<'a, C, A> ChannelSectionListCall<'a, C, A> where C: BorrowMut<hyper::Client /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channel_sections().insert(&req) -/// .on_behalf_of_content_owner_channel("eos") -/// .on_behalf_of_content_owner("erat") +/// .on_behalf_of_content_owner_channel("eirmod") +/// .on_behalf_of_content_owner("dolore") /// .doit(); /// # } /// ``` @@ -6978,16 +8115,20 @@ impl<'a, C, A> ChannelSectionInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7175,7 +8316,7 @@ impl<'a, C, A> ChannelSectionInsertCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channel_sections().delete("id") -/// .on_behalf_of_content_owner("dolor") +/// .on_behalf_of_content_owner("aliquyam") /// .doit(); /// # } /// ``` @@ -7236,16 +8377,20 @@ impl<'a, C, A> ChannelSectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -7399,7 +8544,7 @@ impl<'a, C, A> ChannelSectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: ChannelSection = Default::default(); +/// let mut req = ChannelSection::default(); /// req.snippet = Default::default(); // is ChannelSectionSnippet /// req.content_details = Default::default(); // is ChannelSectionContentDetails /// @@ -7407,7 +8552,7 @@ impl<'a, C, A> ChannelSectionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channel_sections().update(&req) -/// .on_behalf_of_content_owner("eirmod") +/// .on_behalf_of_content_owner("accusam") /// .doit(); /// # } /// ``` @@ -7477,16 +8622,20 @@ impl<'a, C, A> ChannelSectionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -7679,9 +8828,9 @@ impl<'a, C, A> ChannelSectionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.guide_categories().list("part") -/// .region_code("amet") -/// .id("no") -/// .hl("labore") +/// .region_code("sea") +/// .id("et") +/// .hl("duo") /// .doit(); /// # } /// ``` @@ -7751,16 +8900,20 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -7943,7 +9096,7 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Playlist = Default::default(); +/// let mut req = Playlist::default(); /// req.status = Default::default(); // is PlaylistStatus /// req.snippet = Default::default(); // is PlaylistSnippet /// @@ -7951,8 +9104,8 @@ impl<'a, C, A> GuideCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlists().insert(&req) -/// .on_behalf_of_content_owner_channel("eirmod") -/// .on_behalf_of_content_owner("dolore") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("eirmod") /// .doit(); /// # } /// ``` @@ -8026,16 +9179,20 @@ impl<'a, C, A> PlaylistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -8241,14 +9398,14 @@ impl<'a, C, A> PlaylistInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlists().list("part") -/// .page_token("aliquyam") -/// .on_behalf_of_content_owner_channel("accusam") -/// .on_behalf_of_content_owner("Lorem") +/// .page_token("et") +/// .on_behalf_of_content_owner_channel("amet") +/// .on_behalf_of_content_owner("et") /// .mine(true) -/// .max_results(80) -/// .id("duo") -/// .hl("et") -/// .channel_id("eirmod") +/// .max_results(65) +/// .id("ea") +/// .hl("sed") +/// .channel_id("dolor") /// .doit(); /// # } /// ``` @@ -8338,16 +9495,20 @@ impl<'a, C, A> PlaylistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -8558,7 +9719,7 @@ impl<'a, C, A> PlaylistListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlists().delete("id") -/// .on_behalf_of_content_owner("et") +/// .on_behalf_of_content_owner("dolor") /// .doit(); /// # } /// ``` @@ -8619,16 +9780,20 @@ impl<'a, C, A> PlaylistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -8782,7 +9947,7 @@ impl<'a, C, A> PlaylistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Playlist = Default::default(); +/// let mut req = Playlist::default(); /// req.status = Default::default(); // is PlaylistStatus /// req.snippet = Default::default(); // is PlaylistSnippet /// @@ -8790,7 +9955,7 @@ impl<'a, C, A> PlaylistDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlists().update(&req) -/// .on_behalf_of_content_owner("amet") +/// .on_behalf_of_content_owner("et") /// .doit(); /// # } /// ``` @@ -8860,16 +10025,20 @@ impl<'a, C, A> PlaylistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -9049,7 +10218,7 @@ impl<'a, C, A> PlaylistUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.thumbnails().set("videoId") -/// .on_behalf_of_content_owner("consetetur") +/// .on_behalf_of_content_owner("amet.") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -9122,16 +10291,20 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; @@ -9349,6 +10522,231 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: } +/// Report abuse for a video. +/// +/// A builder for the *reportAbuse* method supported by a *video* resource. +/// It is not used directly, but through a `VideoMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::VideoAbuseReport; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = VideoAbuseReport::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.videos().report_abuse(&req) +/// .on_behalf_of_content_owner("voluptua.") +/// .doit(); +/// # } +/// ``` +pub struct VideoReportAbuseCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _request: VideoAbuseReport, + _on_behalf_of_content_owner: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for VideoReportAbuseCall<'a, C, A> {} + +impl<'a, C, A> VideoReportAbuseCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.videos.reportAbuse", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); + if let Some(value) = self._on_behalf_of_content_owner { + params.push(("onBehalfOfContentOwner", value.to_string())); + } + for &field in ["onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/youtube/v3/videos/reportAbuse".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though 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(); + self + } + /// Note: This parameter is intended exclusively for YouTube content partners. + /// + /// The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoReportAbuseCall<'a, C, A> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> VideoReportAbuseCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> VideoReportAbuseCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> VideoReportAbuseCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Returns a list of videos that match the API request parameters. /// /// A builder for the *list* method supported by a *video* resource. @@ -9403,16 +10801,16 @@ impl<'a, C, A> ThumbnailSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().list("part") -/// .video_category_id("ea") -/// .region_code("sed") -/// .page_token("dolor") -/// .on_behalf_of_content_owner("dolor") -/// .my_rating("dolor") -/// .max_results(78) +/// .video_category_id("gubergren") +/// .region_code("justo") +/// .page_token("sit") +/// .on_behalf_of_content_owner("vero") +/// .my_rating("diam") +/// .max_results(35) /// .locale("consetetur") -/// .id("amet.") -/// .hl("voluptua.") -/// .chart("Lorem") +/// .id("sadipscing") +/// .hl("vero") +/// .chart("sadipscing") /// .doit(); /// # } /// ``` @@ -9510,16 +10908,20 @@ impl<'a, C, A> VideoListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -9753,7 +11155,7 @@ impl<'a, C, A> VideoListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().rate("id", "rating") -/// .on_behalf_of_content_owner("sit") +/// .on_behalf_of_content_owner("dolore") /// .doit(); /// # } /// ``` @@ -9816,16 +11218,20 @@ impl<'a, C, A> VideoRateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -9974,7 +11380,7 @@ impl<'a, C, A> VideoRateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().get_rating("id") -/// .on_behalf_of_content_owner("diam") +/// .on_behalf_of_content_owner("aliquyam") /// .doit(); /// # } /// ``` @@ -10036,16 +11442,20 @@ impl<'a, C, A> VideoGetRatingCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -10194,7 +11604,7 @@ impl<'a, C, A> VideoGetRatingCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().delete("id") -/// .on_behalf_of_content_owner("consetetur") +/// .on_behalf_of_content_owner("et") /// .doit(); /// # } /// ``` @@ -10255,16 +11665,20 @@ impl<'a, C, A> VideoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -10428,7 +11842,7 @@ impl<'a, C, A> VideoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Video = Default::default(); +/// let mut req = Video::default(); /// req.status = Default::default(); // is VideoStatus /// req.topic_details = Default::default(); // is VideoTopicDetails /// req.suggestions = Default::default(); // is VideoSuggestions @@ -10446,7 +11860,7 @@ impl<'a, C, A> VideoDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().update(&req) -/// .on_behalf_of_content_owner("sadipscing") +/// .on_behalf_of_content_owner("clita") /// .doit(); /// # } /// ``` @@ -10516,16 +11930,20 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -10753,7 +12171,7 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Video = Default::default(); +/// let mut req = Video::default(); /// req.status = Default::default(); // is VideoStatus /// req.topic_details = Default::default(); // is VideoTopicDetails /// req.suggestions = Default::default(); // is VideoSuggestions @@ -10771,11 +12189,11 @@ impl<'a, C, A> VideoUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `upload_resumable(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.videos().insert(&req) -/// .stabilize(false) -/// .on_behalf_of_content_owner_channel("sadipscing") -/// .on_behalf_of_content_owner("invidunt") -/// .notify_subscribers(false) -/// .auto_levels(false) +/// .stabilize(true) +/// .on_behalf_of_content_owner_channel("takimata") +/// .on_behalf_of_content_owner("nonumy") +/// .notify_subscribers(true) +/// .auto_levels(true) /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -10872,16 +12290,20 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -11228,7 +12650,7 @@ impl<'a, C, A> VideoInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Subscription = Default::default(); +/// let mut req = Subscription::default(); /// req.snippet = Default::default(); // is SubscriptionSnippet /// req.content_details = Default::default(); // is SubscriptionContentDetails /// @@ -11301,16 +12723,20 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -11495,16 +12921,16 @@ impl<'a, C, A> SubscriptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subscriptions().list("part") -/// .page_token("aliquyam") -/// .order("Lorem") -/// .on_behalf_of_content_owner_channel("et") -/// .on_behalf_of_content_owner("clita") -/// .my_subscribers(true) +/// .page_token("At") +/// .order("labore") +/// .on_behalf_of_content_owner_channel("invidunt") +/// .on_behalf_of_content_owner("ea") +/// .my_subscribers(false) /// .mine(false) -/// .max_results(61) -/// .id("kasd") -/// .for_channel_id("sanctus") -/// .channel_id("takimata") +/// .max_results(68) +/// .id("nonumy") +/// .for_channel_id("sed") +/// .channel_id("aliquyam") /// .doit(); /// # } /// ``` @@ -11602,16 +13028,20 @@ impl<'a, C, A> SubscriptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -11891,16 +13321,20 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -12046,36 +13480,36 @@ impl<'a, C, A> SubscriptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.search().list("part") -/// .video_type("invidunt") -/// .video_syndicated("ea") -/// .video_license("sadipscing") -/// .video_embeddable("rebum.") -/// .video_duration("dolore") -/// .video_dimension("nonumy") -/// .video_definition("sed") -/// .video_category_id("aliquyam") -/// .video_caption("sit") -/// .type_("eirmod") -/// .topic_id("consetetur") -/// .safe_search("labore") -/// .relevance_language("sed") -/// .related_to_video_id("ea") -/// .region_code("gubergren") -/// .q("aliquyam") -/// .published_before("eos") -/// .published_after("tempor") -/// .page_token("sea") -/// .order("labore") -/// .on_behalf_of_content_owner("ipsum") -/// .max_results(70) -/// .location_radius("dolores") -/// .location("sit") -/// .for_mine(true) +/// .video_type("consetetur") +/// .video_syndicated("labore") +/// .video_license("sed") +/// .video_embeddable("ea") +/// .video_duration("gubergren") +/// .video_dimension("aliquyam") +/// .video_definition("eos") +/// .video_category_id("tempor") +/// .video_caption("sea") +/// .type_("labore") +/// .topic_id("ipsum") +/// .safe_search("aliquyam") +/// .relevance_language("dolores") +/// .related_to_video_id("sit") +/// .region_code("diam") +/// .q("ut") +/// .published_before("justo") +/// .published_after("est") +/// .page_token("amet") +/// .order("accusam") +/// .on_behalf_of_content_owner("clita") +/// .max_results(22) +/// .location_radius("justo") +/// .location("est") +/// .for_mine(false) /// .for_developer(true) /// .for_content_owner(false) -/// .event_type("est") -/// .channel_type("amet") -/// .channel_id("accusam") +/// .event_type("dolores") +/// .channel_type("eos") +/// .channel_id("voluptua.") /// .doit(); /// # } /// ``` @@ -12253,16 +13687,20 @@ impl<'a, C, A> SearchListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12639,7 +14077,7 @@ impl<'a, C, A> SearchListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oa /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.i18n_regions().list("part") -/// .hl("diam") +/// .hl("sed") /// .doit(); /// # } /// ``` @@ -12701,16 +14139,20 @@ impl<'a, C, A> I18nRegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -12835,6 +14277,896 @@ impl<'a, C, A> I18nRegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A } +/// Returns a list of comment threads that match the API request parameters. +/// +/// A builder for the *list* method supported by a *commentThread* resource. +/// It is not used directly, but through a `CommentThreadMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *replies* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("part") +/// .video_id("ea") +/// .text_format("ea") +/// .search_terms("et") +/// .page_token("dolor") +/// .moderation_status("diam") +/// .max_results(39) +/// .id("invidunt") +/// .channel_id("rebum.") +/// .all_threads_related_to_channel_id("Lorem") +/// .doit(); +/// # } +/// ``` +pub struct CommentThreadListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _part: String, + _video_id: Option<String>, + _text_format: Option<String>, + _search_terms: Option<String>, + _page_token: Option<String>, + _moderation_status: Option<String>, + _max_results: Option<u32>, + _id: Option<String>, + _channel_id: Option<String>, + _all_threads_related_to_channel_id: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentThreadListCall<'a, C, A> {} + +impl<'a, C, A> CommentThreadListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CommentThreadListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.commentThreads.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len())); + params.push(("part", self._part.to_string())); + if let Some(value) = self._video_id { + params.push(("videoId", value.to_string())); + } + if let Some(value) = self._text_format { + params.push(("textFormat", value.to_string())); + } + if let Some(value) = self._search_terms { + params.push(("searchTerms", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._moderation_status { + params.push(("moderationStatus", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._id { + params.push(("id", value.to_string())); + } + if let Some(value) = self._channel_id { + params.push(("channelId", value.to_string())); + } + if let Some(value) = self._all_threads_related_to_channel_id { + params.push(("allThreadsRelatedToChannelId", value.to_string())); + } + for &field in ["alt", "part", "videoId", "textFormat", "searchTerms", "pageToken", "moderationStatus", "maxResults", "id", "channelId", "allThreadsRelatedToChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/commentThreads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The part parameter specifies the commentThread resource parts that the API response will include. Supported values are id, snippet and replies. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *replies* + pub fn part(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The videoId parameter instructs the API to return the comment threads for the video specified by the video id. + /// + /// Sets the *video id* query property to the given value. + pub fn video_id(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._video_id = Some(new_value.to_string()); + self + } + /// Set this parameter's value to html or plainText to instruct the API to return the comments left by users in html formatted or in plain text. + /// + /// Sets the *text format* query property to the given value. + pub fn text_format(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._text_format = Some(new_value.to_string()); + self + } + /// The searchTerms parameter instructs the API to limit the returned comments to those which contain the specified search terms. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *search terms* query property to the given value. + pub fn search_terms(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._search_terms = Some(new_value.to_string()); + self + } + /// The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// Set this parameter to limit the returned comment threads to a particular moderation state. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *moderation status* query property to the given value. + pub fn moderation_status(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._moderation_status = Some(new_value.to_string()); + self + } + /// The maxResults parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> CommentThreadListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// The id parameter specifies a comma-separated list of comment thread IDs for the resources that should be retrieved. + /// + /// Sets the *id* query property to the given value. + pub fn id(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._id = Some(new_value.to_string()); + self + } + /// The channelId parameter instructs the API to return the comment threads for all the channel comments (not including comments left on videos). + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._channel_id = Some(new_value.to_string()); + self + } + /// The allThreadsRelatedToChannelId parameter instructs the API to return the comment threads of all videos of the channel and the channel comments as well. + /// + /// Sets the *all threads related to channel id* query property to the given value. + pub fn all_threads_related_to_channel_id(mut self, new_value: &str) -> CommentThreadListCall<'a, C, A> { + self._all_threads_related_to_channel_id = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentThreadListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentThreadListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentThreadListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Modifies an existing comment. +/// +/// A builder for the *update* method supported by a *commentThread* resource. +/// It is not used directly, but through a `CommentThreadMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *replies* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::CommentThread; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CommentThread::default(); +/// req.snippet = Default::default(); // is CommentThreadSnippet +/// req.id = Some("clita".to_string()); +/// req.replies = Default::default(); // is CommentThreadReplies +/// +/// // You can configure optional parameters by calling 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) +/// .doit(); +/// # } +/// ``` +pub struct CommentThreadUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _request: CommentThread, + _part: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentThreadUpdateCall<'a, C, A> {} + +impl<'a, C, A> CommentThreadUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CommentThread)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.commentThreads.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if self._part.len() == 0 { + self._part = self._request.to_parts(); + } + params.push(("part", self._part.to_string())); + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/commentThreads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *replies* + pub fn request(mut self, new_value: &CommentThread) -> CommentThreadUpdateCall<'a, C, A> { + self._request = new_value.clone(); + 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. + /// + /// The part names that you can include in the parameter value are id, snippet and replies. However only snippet contains properties that can be updated. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *replies* + pub fn part(mut self, new_value: &str) -> CommentThreadUpdateCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentThreadUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentThreadUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentThreadUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Creates a new comment thread and top level comment. +/// +/// A builder for the *insert* method supported by a *commentThread* resource. +/// It is not used directly, but through a `CommentThreadMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::CommentThread; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CommentThread::default(); +/// req.snippet = Default::default(); // is CommentThreadSnippet +/// req.id = Some("invidunt".to_string()); +/// +/// // You can configure optional parameters by calling 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) +/// .share_on_google_plus(false) +/// .doit(); +/// # } +/// ``` +pub struct CommentThreadInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _request: CommentThread, + _part: String, + _share_on_google_plus: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentThreadInsertCall<'a, C, A> {} + +impl<'a, C, A> CommentThreadInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CommentThread)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.commentThreads.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len())); + if self._part.len() == 0 { + self._part = self._request.to_parts(); + } + params.push(("part", self._part.to_string())); + if let Some(value) = self._share_on_google_plus { + params.push(("shareOnGooglePlus", value.to_string())); + } + for &field in ["alt", "part", "shareOnGooglePlus"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/commentThreads".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn request(mut self, new_value: &CommentThread) -> CommentThreadInsertCall<'a, C, A> { + self._request = new_value.clone(); + 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. + /// + /// The part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be set. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn part(mut self, new_value: &str) -> CommentThreadInsertCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The shareOnGooglePlus determines whether this thread should also be posted on Google+. + /// + /// Sets the *share on google plus* query property to the given value. + pub fn share_on_google_plus(mut self, new_value: bool) -> CommentThreadInsertCall<'a, C, A> { + self._share_on_google_plus = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentThreadInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentThreadInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentThreadInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates a video stream. If the properties that you want to change cannot be updated, then you need to create a new stream with the proper settings. /// /// A builder for the *update* method supported by a *liveStream* resource. @@ -12878,18 +15210,18 @@ impl<'a, C, A> I18nRegionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LiveStream = Default::default(); +/// let mut req = LiveStream::default(); /// req.status = Default::default(); // is LiveStreamStatus /// req.snippet = Default::default(); // is LiveStreamSnippet /// req.cdn = Default::default(); // is CdnSettings -/// req.id = Some("justo".to_string()); +/// req.id = Some("At".to_string()); /// /// // You can configure optional parameters by calling 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) -/// .on_behalf_of_content_owner_channel("est") -/// .on_behalf_of_content_owner("clita") +/// .on_behalf_of_content_owner_channel("consetetur") +/// .on_behalf_of_content_owner("et") /// .doit(); /// # } /// ``` @@ -12963,16 +15295,20 @@ impl<'a, C, A> LiveStreamUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13166,8 +15502,8 @@ impl<'a, C, A> LiveStreamUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_streams().delete("id") -/// .on_behalf_of_content_owner_channel("ut") -/// .on_behalf_of_content_owner("dolores") +/// .on_behalf_of_content_owner_channel("sit") +/// .on_behalf_of_content_owner("takimata") /// .doit(); /// # } /// ``` @@ -13232,16 +15568,20 @@ impl<'a, C, A> LiveStreamDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -13408,12 +15748,12 @@ impl<'a, C, A> LiveStreamDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_streams().list("part") -/// .page_token("voluptua.") -/// .on_behalf_of_content_owner_channel("duo") -/// .on_behalf_of_content_owner("sed") +/// .page_token("nonumy") +/// .on_behalf_of_content_owner_channel("rebum.") +/// .on_behalf_of_content_owner("Lorem") /// .mine(true) -/// .max_results(34) -/// .id("ea") +/// .max_results(59) +/// .id("ut") /// .doit(); /// # } /// ``` @@ -13495,16 +15835,20 @@ impl<'a, C, A> LiveStreamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -13715,18 +16059,18 @@ impl<'a, C, A> LiveStreamListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LiveStream = Default::default(); +/// let mut req = LiveStream::default(); /// req.status = Default::default(); // is LiveStreamStatus /// req.snippet = Default::default(); // is LiveStreamSnippet /// req.cdn = Default::default(); // is CdnSettings -/// req.id = Some("et".to_string()); +/// req.id = Some("ut".to_string()); /// /// // You can configure optional parameters by calling 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) -/// .on_behalf_of_content_owner_channel("dolor") -/// .on_behalf_of_content_owner("diam") +/// .on_behalf_of_content_owner_channel("amet.") +/// .on_behalf_of_content_owner("ipsum") /// .doit(); /// # } /// ``` @@ -13800,16 +16144,20 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -13974,6 +16322,1453 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, } +/// Creates a new comment. +/// +/// Note: to create a top level comment it is also necessary to create a comment thread. Both are accomplished through the commentThreads resource. +/// +/// A builder for the *insert* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::Comment; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Comment::default(); +/// req.snippet = Default::default(); // is CommentSnippet +/// req.id = Some("ut".to_string()); +/// +/// // You can configure optional parameters by calling 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) +/// .doit(); +/// # } +/// ``` +pub struct CommentInsertCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _request: Comment, + _part: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentInsertCall<'a, C, A> {} + +impl<'a, C, A> CommentInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Comment)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.insert", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if self._part.len() == 0 { + self._part = self._request.to_parts(); + } + params.push(("part", self._part.to_string())); + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/comments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn request(mut self, new_value: &Comment) -> CommentInsertCall<'a, C, A> { + self._request = new_value.clone(); + 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. + /// + /// The part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be set. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn part(mut self, new_value: &str) -> CommentInsertCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentInsertCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentInsertCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentInsertCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Sets the moderation status of one or more comments. +/// +/// A builder for the *setModerationStatus* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().set_moderation_status("id", "moderationStatus") +/// .ban_author(true) +/// .doit(); +/// # } +/// ``` +pub struct CommentSetModerationStatuCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _id: String, + _moderation_status: String, + _ban_author: Option<bool>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentSetModerationStatuCall<'a, C, A> {} + +impl<'a, C, A> CommentSetModerationStatuCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.setModerationStatus", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("id", self._id.to_string())); + params.push(("moderationStatus", self._moderation_status.to_string())); + if let Some(value) = self._ban_author { + params.push(("banAuthor", value.to_string())); + } + for &field in ["id", "moderationStatus", "banAuthor"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/youtube/v3/comments/setModerationStatus".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id parameter specifies a comma-separated list of IDs of comments whose moderation status should be updated. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CommentSetModerationStatuCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// Determines the new moderation status of the specified comments. + /// + /// Sets the *moderation status* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn moderation_status(mut self, new_value: &str) -> CommentSetModerationStatuCall<'a, C, A> { + self._moderation_status = new_value.to_string(); + self + } + /// The banAuthor paramter, if set to true, adds the author of the comment to the ban list. This means all future comments of the author will autmomatically be rejected. + /// + /// Note: This parameter is only valid in combination with moderationStatus 'rejected'. + /// + /// Sets the *ban author* query property to the given value. + pub fn ban_author(mut self, new_value: bool) -> CommentSetModerationStatuCall<'a, C, A> { + self._ban_author = Some(new_value); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentSetModerationStatuCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentSetModerationStatuCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentSetModerationStatuCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Deletes a comment. +/// +/// A builder for the *delete* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().delete("id") +/// .doit(); +/// # } +/// ``` +pub struct CommentDeleteCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentDeleteCall<'a, C, A> {} + +impl<'a, C, A> CommentDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.delete", + http_method: hyper::method::Method::Delete }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + params.push(("id", self._id.to_string())); + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/youtube/v3/comments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id parameter specifies the comment ID for the resource that should be deleted. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CommentDeleteCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentDeleteCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentDeleteCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Returns a list of comments that match the API request parameters. +/// +/// A builder for the *list* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().list("part") +/// .text_format("voluptua.") +/// .parent_id("dolor") +/// .page_token("et") +/// .max_results(16) +/// .id("vero") +/// .doit(); +/// # } +/// ``` +pub struct CommentListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _part: String, + _text_format: Option<String>, + _parent_id: Option<String>, + _page_token: Option<String>, + _max_results: Option<u32>, + _id: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentListCall<'a, C, A> {} + +impl<'a, C, A> CommentListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, CommentListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len())); + params.push(("part", self._part.to_string())); + if let Some(value) = self._text_format { + params.push(("textFormat", value.to_string())); + } + if let Some(value) = self._parent_id { + params.push(("parentId", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._id { + params.push(("id", value.to_string())); + } + for &field in ["alt", "part", "textFormat", "parentId", "pageToken", "maxResults", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/comments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The part parameter specifies the comment resource parts that the API response will include. Supported values are id and snippet. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn part(mut self, new_value: &str) -> CommentListCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// Set this parameter's value to html or plainText to instruct the API to return the comments left by users formatted as HTML or as plain text. + /// + /// Sets the *text format* query property to the given value. + pub fn text_format(mut self, new_value: &str) -> CommentListCall<'a, C, A> { + self._text_format = Some(new_value.to_string()); + self + } + /// The parentId parameter specifies the ID of the comment for which replies should be retrieved. + /// + /// Note: Currently YouTube features only one level of replies (ie replies to top level comments). However replies to replies may be supported in the future. + /// + /// Sets the *parent id* query property to the given value. + pub fn parent_id(mut self, new_value: &str) -> CommentListCall<'a, C, A> { + self._parent_id = Some(new_value.to_string()); + self + } + /// The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, C, A> { + self._page_token = Some(new_value.to_string()); + self + } + /// The maxResults parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Note: This parameter is not supported for use in conjunction with the id parameter. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> CommentListCall<'a, C, A> { + self._max_results = Some(new_value); + self + } + /// The id parameter specifies a comma-separated list of comment IDs for the resources that should be retrieved. + /// + /// Sets the *id* query property to the given value. + pub fn id(mut self, new_value: &str) -> CommentListCall<'a, C, A> { + self._id = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Modifies an existing comment. +/// +/// A builder for the *update* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::Comment; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Comment::default(); +/// req.snippet = Default::default(); // is CommentSnippet +/// req.id = Some("ut".to_string()); +/// +/// // You can configure optional parameters by calling 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) +/// .doit(); +/// # } +/// ``` +pub struct CommentUpdateCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _request: Comment, + _part: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentUpdateCall<'a, C, A> {} + +impl<'a, C, A> CommentUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, Comment)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.update", + http_method: hyper::method::Method::Put }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + if self._part.len() == 0 { + self._part = self._request.to_parts(); + } + params.push(("part", self._part.to_string())); + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/comments".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); + let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request)); + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()) + .header(ContentType(json_mime_type.clone())) + .header(ContentLength(request_size as u64)) + .body(&mut request_value_reader); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn request(mut self, new_value: &Comment) -> CommentUpdateCall<'a, C, A> { + self._request = new_value.clone(); + 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. + /// + /// The part names that you can include in the parameter value are id and snippet. However only snippet contains properties that can be updated. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn part(mut self, new_value: &str) -> CommentUpdateCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentUpdateCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentUpdateCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentUpdateCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + +/// Expresses the caller's opinion that a comment is spam. +/// +/// A builder for the *markAsSpam* method supported by a *comment* resource. +/// It is not used directly, but through a `CommentMethods` instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().mark_as_spam("id") +/// .doit(); +/// # } +/// ``` +pub struct CommentMarkAsSpamCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _id: String, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for CommentMarkAsSpamCall<'a, C, A> {} + +impl<'a, C, A> CommentMarkAsSpamCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<hyper::client::Response> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.comments.markAsSpam", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); + params.push(("id", self._id.to_string())); + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = "https://www.googleapis.com/youtube/v3/comments/markAsSpam".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id parameter specifies a comma-separated list of IDs of comments which should get flagged as spam. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> CommentMarkAsSpamCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> CommentMarkAsSpamCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> CommentMarkAsSpamCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::ForceSsl`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> CommentMarkAsSpamCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Updates a channel's metadata. /// /// A builder for the *update* method supported by a *channel* resource. @@ -14016,15 +17811,15 @@ impl<'a, C, A> LiveStreamInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Channel = Default::default(); +/// let mut req = Channel::default(); /// req.invideo_promotion = Default::default(); // is InvideoPromotion -/// req.id = Some("kasd".to_string()); +/// req.id = Some("et".to_string()); /// /// // You can configure optional parameters by calling 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) -/// .on_behalf_of_content_owner("invidunt") +/// .on_behalf_of_content_owner("ipsum") /// .doit(); /// # } /// ``` @@ -14094,16 +17889,20 @@ impl<'a, C, A> ChannelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14301,16 +18100,16 @@ impl<'a, C, A> ChannelUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.channels().list("part") -/// .page_token("Lorem") -/// .on_behalf_of_content_owner("clita") -/// .my_subscribers(true) +/// .page_token("dolore") +/// .on_behalf_of_content_owner("vero") +/// .my_subscribers(false) /// .mine(false) -/// .max_results(24) +/// .max_results(80) /// .managed_by_me(false) /// .id("et") /// .hl("sed") -/// .for_username("sit") -/// .category_id("takimata") +/// .for_username("no") +/// .category_id("invidunt") /// .doit(); /// # } /// ``` @@ -14408,16 +18207,20 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -14611,6 +18414,248 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } +/// Returns a list of abuse reasons that can be used for reporting abusive videos. +/// +/// A builder for the *list* method supported by a *videoAbuseReportReason* resource. +/// It is not used directly, but through a `VideoAbuseReportReasonMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.video_abuse_report_reasons().list("part") +/// .hl("labore") +/// .doit(); +/// # } +/// ``` +pub struct VideoAbuseReportReasonListCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _part: String, + _hl: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for VideoAbuseReportReasonListCall<'a, C, A> {} + +impl<'a, C, A> VideoAbuseReportReasonListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, VideoAbuseReportReasonListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.videoAbuseReportReasons.list", + http_method: hyper::method::Method::Get }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len())); + params.push(("part", self._part.to_string())); + if let Some(value) = self._hl { + params.push(("hl", value.to_string())); + } + for &field in ["alt", "part", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/videoAbuseReportReasons".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Readonly.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The part parameter specifies the videoCategory resource parts that the API response will include. Supported values are id and snippet. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn part(mut self, new_value: &str) -> VideoAbuseReportReasonListCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The hl parameter specifies the language that should be used for text values in the API response. + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> VideoAbuseReportReasonListCall<'a, C, A> { + self._hl = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> VideoAbuseReportReasonListCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> VideoAbuseReportReasonListCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Readonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> VideoAbuseReportReasonListCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Adds a resource to a playlist. /// /// A builder for the *insert* method supported by a *playlistItem* resource. @@ -14654,7 +18699,7 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlaylistItem = Default::default(); +/// let mut req = PlaylistItem::default(); /// req.status = Default::default(); // is PlaylistItemStatus /// req.snippet = Default::default(); // is PlaylistItemSnippet /// req.content_details = Default::default(); // is PlaylistItemContentDetails @@ -14663,7 +18708,7 @@ impl<'a, C, A> ChannelListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlist_items().insert(&req) -/// .on_behalf_of_content_owner("elitr") +/// .on_behalf_of_content_owner("aliquyam") /// .doit(); /// # } /// ``` @@ -14733,16 +18778,20 @@ impl<'a, C, A> PlaylistItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -14977,16 +19026,20 @@ impl<'a, C, A> PlaylistItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -15134,12 +19187,12 @@ impl<'a, C, A> PlaylistItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.playlist_items().list("part") -/// .video_id("Lorem") -/// .playlist_id("Lorem") -/// .page_token("diam") -/// .on_behalf_of_content_owner("ut") -/// .max_results(64) -/// .id("amet.") +/// .video_id("sea") +/// .playlist_id("elitr") +/// .page_token("At") +/// .on_behalf_of_content_owner("sea") +/// .max_results(5) +/// .id("diam") /// .doit(); /// # } /// ``` @@ -15221,16 +19274,20 @@ impl<'a, C, A> PlaylistItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -15439,7 +19496,7 @@ impl<'a, C, A> PlaylistItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: PlaylistItem = Default::default(); +/// let mut req = PlaylistItem::default(); /// req.status = Default::default(); // is PlaylistItemStatus /// req.snippet = Default::default(); // is PlaylistItemSnippet /// req.content_details = Default::default(); // is PlaylistItemContentDetails @@ -15513,16 +19570,20 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -15695,13 +19756,13 @@ impl<'a, C, A> PlaylistItemUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: InvideoBranding = Default::default(); +/// let mut req = InvideoBranding::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.watermarks().set(&req, "channelId") -/// .on_behalf_of_content_owner("ut") +/// .on_behalf_of_content_owner("dolores") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -15778,16 +19839,20 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -16040,7 +20105,7 @@ impl<'a, C, A> WatermarkSetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.watermarks().unset("channelId") -/// .on_behalf_of_content_owner("sea") +/// .on_behalf_of_content_owner("dolor") /// .doit(); /// # } /// ``` @@ -16101,16 +20166,20 @@ impl<'a, C, A> WatermarkUnsetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -16263,10 +20332,10 @@ impl<'a, C, A> WatermarkUnsetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().control("id", "part") -/// .walltime("sanctus") -/// .on_behalf_of_content_owner_channel("voluptua.") -/// .on_behalf_of_content_owner("dolor") -/// .offset_time_ms("et") +/// .walltime("ea") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("Stet") +/// .offset_time_ms("sed") /// .display_slate(false) /// .doit(); /// # } @@ -16347,16 +20416,20 @@ impl<'a, C, A> LiveBroadcastControlCall<'a, C, A> where C: BorrowMut<hyper::Clie loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -16574,18 +20647,18 @@ impl<'a, C, A> LiveBroadcastControlCall<'a, C, A> where C: BorrowMut<hyper::Clie /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LiveBroadcast = Default::default(); +/// let mut req = LiveBroadcast::default(); /// req.status = Default::default(); // is LiveBroadcastStatus /// req.snippet = Default::default(); // is LiveBroadcastSnippet /// req.content_details = Default::default(); // is LiveBroadcastContentDetails -/// req.id = Some("vero".to_string()); +/// req.id = Some("sanctus".to_string()); /// /// // You can configure optional parameters by calling 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) -/// .on_behalf_of_content_owner_channel("ut") -/// .on_behalf_of_content_owner("sed") +/// .on_behalf_of_content_owner_channel("dolore") +/// .on_behalf_of_content_owner("Lorem") /// .doit(); /// # } /// ``` @@ -16659,16 +20732,20 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -16878,18 +20955,18 @@ impl<'a, C, A> LiveBroadcastUpdateCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: LiveBroadcast = Default::default(); +/// let mut req = LiveBroadcast::default(); /// req.status = Default::default(); // is LiveBroadcastStatus /// req.snippet = Default::default(); // is LiveBroadcastSnippet /// req.content_details = Default::default(); // is LiveBroadcastContentDetails -/// req.id = Some("et".to_string()); +/// req.id = Some("consetetur".to_string()); /// /// // You can configure optional parameters by calling 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) -/// .on_behalf_of_content_owner_channel("ipsum") -/// .on_behalf_of_content_owner("justo") +/// .on_behalf_of_content_owner_channel("consetetur") +/// .on_behalf_of_content_owner("eirmod") /// .doit(); /// # } /// ``` @@ -16963,16 +21040,20 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -17137,289 +21218,6 @@ impl<'a, C, A> LiveBroadcastInsertCall<'a, C, A> where C: BorrowMut<hyper::Clien } -/// Binds a YouTube broadcast to a stream or removes an existing binding between a broadcast and a stream. A broadcast can only be bound to one video stream. -/// -/// A builder for the *bind* method supported by a *liveBroadcast* resource. -/// It is not used directly, but through a `LiveBroadcastMethods` instance. -/// -/// **Settable Parts** -/// -/// * *id* -/// * *snippet* -/// * *contentDetails* -/// * *status* -/// -/// # Scopes -/// -/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: -/// -/// * *https://www.googleapis.com/auth/youtube* -/// * *https://www.googleapis.com/auth/youtube.force-ssl* -/// -/// The default scope will be `Scope::Full`. -/// -/// # Example -/// -/// Instantiate a resource method builder -/// -/// ```test_harness,no_run -/// # extern crate hyper; -/// # extern crate yup_oauth2 as oauth2; -/// # extern crate google_youtube3 as youtube3; -/// # #[test] fn egal() { -/// # use std::default::Default; -/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; -/// # use youtube3::YouTube; -/// -/// # let secret: ApplicationSecret = Default::default(); -/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, -/// # hyper::Client::new(), -/// # <MemoryStorage as Default>::default(), None); -/// # let mut hub = YouTube::new(hyper::Client::new(), auth); -/// // You can configure optional parameters by calling 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().bind("id", "part") -/// .stream_id("dolor") -/// .on_behalf_of_content_owner_channel("takimata") -/// .on_behalf_of_content_owner("et") -/// .doit(); -/// # } -/// ``` -pub struct LiveBroadcastBindCall<'a, C, A> - where C: 'a, A: 'a { - - hub: &'a YouTube<C, A>, - _id: String, - _part: String, - _stream_id: Option<String>, - _on_behalf_of_content_owner_channel: Option<String>, - _on_behalf_of_content_owner: Option<String>, - _delegate: Option<&'a mut Delegate>, - _additional_params: HashMap<String, String>, - _scopes: BTreeMap<String, ()> -} - -impl<'a, C, A> CallBuilder for LiveBroadcastBindCall<'a, C, A> {} - -impl<'a, C, A> LiveBroadcastBindCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { - - - /// Perform the operation you have build so far. - pub fn doit(mut self) -> Result<(hyper::client::Response, LiveBroadcast)> { - use std::io::{Read, Seek}; - use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; - let mut dd = DefaultDelegate; - let mut dlg: &mut Delegate = match self._delegate { - Some(d) => d, - None => &mut dd - }; - dlg.begin(MethodInfo { id: "youtube.liveBroadcasts.bind", - http_method: hyper::method::Method::Post }); - let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); - params.push(("id", self._id.to_string())); - params.push(("part", self._part.to_string())); - if let Some(value) = self._stream_id { - params.push(("streamId", value.to_string())); - } - if let Some(value) = self._on_behalf_of_content_owner_channel { - params.push(("onBehalfOfContentOwnerChannel", value.to_string())); - } - if let Some(value) = self._on_behalf_of_content_owner { - params.push(("onBehalfOfContentOwner", value.to_string())); - } - for &field in ["alt", "id", "part", "streamId", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { - if self._additional_params.contains_key(field) { - dlg.finished(false); - return Err(Error::FieldClash(field)); - } - } - for (name, value) in self._additional_params.iter() { - params.push((&name, value.clone())); - } - - params.push(("alt", "json".to_string())); - - let mut url = "https://www.googleapis.com/youtube/v3/liveBroadcasts/bind".to_string(); - if self._scopes.len() == 0 { - self._scopes.insert(Scope::Full.as_ref().to_string(), ()); - } - - - if params.len() > 0 { - url.push('?'); - url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); - } - - - - loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } - let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); - let mut req_result = { - let mut client = &mut *self.hub.client.borrow_mut(); - let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) - .header(UserAgent(self.hub._user_agent.clone())) - .header(auth_header.clone()); - - dlg.pre_request(); - req.send() - }; - - match req_result { - Err(err) => { - if let oauth2::Retry::After(d) = dlg.http_error(&err) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::HttpError(err)) - } - Ok(mut res) => { - if !res.status.is_success() { - let mut json_err = String::new(); - res.read_to_string(&mut json_err).unwrap(); - if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { - sleep_ms(d.num_milliseconds() as u32); - continue; - } - dlg.finished(false); - return Err(Error::Failure(res)) - } - let result_value = { - let mut json_response = String::new(); - res.read_to_string(&mut json_response).unwrap(); - match json::from_str(&json_response) { - Ok(decoded) => (res, decoded), - Err(err) => { - dlg.response_json_decode_error(&json_response, &err); - return Err(Error::JsonDecodeError(err)); - } - } - }; - - dlg.finished(true); - return Ok(result_value) - } - } - } - } - - - /// The id parameter specifies the unique ID of the broadcast that is being bound to a video stream. - /// - /// Sets the *id* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - pub fn id(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { - self._id = new_value.to_string(); - self - } - /// The part parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. - /// - /// Sets the *part* query property to the given value. - /// - /// Even though the property as already been set when instantiating this call, - /// we provide this method for API completeness. - /// - /// **Settable Parts** - /// - /// * *id* - /// * *snippet* - /// * *contentDetails* - /// * *status* - pub fn part(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { - self._part = new_value.to_string(); - self - } - /// The streamId parameter specifies the unique ID of the video stream that is being bound to a broadcast. If this parameter is omitted, the API will remove any existing binding between the broadcast and a video stream. - /// - /// Sets the *stream id* query property to the given value. - pub fn stream_id(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { - self._stream_id = Some(new_value.to_string()); - self - } - /// This parameter can only be used in a properly authorized request. Note: This parameter is intended exclusively for YouTube content partners. - /// - /// The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. - /// - /// This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. - /// - /// Sets the *on behalf of content owner channel* query property to the given value. - pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { - self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); - self - } - /// Note: This parameter is intended exclusively for YouTube content partners. - /// - /// The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. - /// - /// Sets the *on behalf of content owner* query property to the given value. - pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { - self._on_behalf_of_content_owner = Some(new_value.to_string()); - self - } - /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong - /// while executing the actual API request. - /// - /// It should be used to handle progress information, and to implement a certain level of resilience. - /// - /// Sets the *delegate* property to the given value. - pub fn delegate(mut self, new_value: &'a mut Delegate) -> LiveBroadcastBindCall<'a, C, A> { - self._delegate = Some(new_value); - self - } - - /// Set any additional parameter of the query string used in the request. - /// It should be used to set parameters which are not yet available through their own - /// setters. - /// - /// Please note that this method must not be used to set any of the known paramters - /// which have their own setter method. If done anyway, the request will fail. - /// - /// # Additional Parameters - /// - /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. - /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. - /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. - /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. - /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. - /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. - /// * *alt* (query-string) - Data format for the response. - pub fn param<T>(mut self, name: T, value: T) -> LiveBroadcastBindCall<'a, C, A> - where T: AsRef<str> { - self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); - self - } - - /// Identifies the authorization scope for the method you are building. - /// - /// Use this method to actively specify which scope should be used, instead the default `Scope` variant - /// `Scope::Full`. - /// - /// The `scope` will be added to a set of scopes. This is important as one can maintain access - /// tokens for more than one scope. - /// - /// Usually there is more than one suitable scope to authorize an operation, some of which may - /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be - /// sufficient, a read-write scope will do as well. - pub fn add_scope<T>(mut self, scope: T) -> LiveBroadcastBindCall<'a, C, A> - where T: AsRef<str> { - self._scopes.insert(scope.as_ref().to_string(), ()); - self - } -} - - /// Returns a list of YouTube broadcasts that match the API request parameters. /// /// A builder for the *list* method supported by a *liveBroadcast* resource. @@ -17464,13 +21262,13 @@ impl<'a, C, A> LiveBroadcastBindCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().list("part") -/// .page_token("et") -/// .on_behalf_of_content_owner_channel("sed") -/// .on_behalf_of_content_owner("no") -/// .mine(true) -/// .max_results(86) -/// .id("labore") -/// .broadcast_status("aliquyam") +/// .page_token("gubergren") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("sadipscing") +/// .mine(false) +/// .max_results(69) +/// .id("Lorem") +/// .broadcast_status("rebum.") /// .doit(); /// # } /// ``` @@ -17556,16 +21354,20 @@ impl<'a, C, A> LiveBroadcastListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -17767,8 +21569,8 @@ impl<'a, C, A> LiveBroadcastListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().delete("id") -/// .on_behalf_of_content_owner_channel("consetetur") -/// .on_behalf_of_content_owner("sea") +/// .on_behalf_of_content_owner_channel("clita") +/// .on_behalf_of_content_owner("eos") /// .doit(); /// # } /// ``` @@ -17833,16 +21635,20 @@ impl<'a, C, A> LiveBroadcastDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -18008,8 +21814,8 @@ impl<'a, C, A> LiveBroadcastDeleteCall<'a, C, A> where C: BorrowMut<hyper::Clien /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.live_broadcasts().transition("broadcastStatus", "id", "part") -/// .on_behalf_of_content_owner_channel("consetetur") -/// .on_behalf_of_content_owner("diam") +/// .on_behalf_of_content_owner_channel("vero") +/// .on_behalf_of_content_owner("consetetur") /// .doit(); /// # } /// ``` @@ -18079,16 +21885,20 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut<hyper::C loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) @@ -18248,6 +22058,293 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut<hyper::C } +/// Binds a YouTube broadcast to a stream or removes an existing binding between a broadcast and a stream. A broadcast can only be bound to one video stream. +/// +/// A builder for the *bind* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a `LiveBroadcastMethods` instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate yup_oauth2 as oauth2; +/// # extern crate google_youtube3 as youtube3; +/// # #[test] fn egal() { +/// # use std::default::Default; +/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; +/// # use youtube3::YouTube; +/// +/// # let secret: ApplicationSecret = Default::default(); +/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, +/// # hyper::Client::new(), +/// # <MemoryStorage as Default>::default(), None); +/// # let mut hub = YouTube::new(hyper::Client::new(), auth); +/// // You can configure optional parameters by calling 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().bind("id", "part") +/// .stream_id("tempor") +/// .on_behalf_of_content_owner_channel("gubergren") +/// .on_behalf_of_content_owner("dolore") +/// .doit(); +/// # } +/// ``` +pub struct LiveBroadcastBindCall<'a, C, A> + where C: 'a, A: 'a { + + hub: &'a YouTube<C, A>, + _id: String, + _part: String, + _stream_id: Option<String>, + _on_behalf_of_content_owner_channel: Option<String>, + _on_behalf_of_content_owner: Option<String>, + _delegate: Option<&'a mut Delegate>, + _additional_params: HashMap<String, String>, + _scopes: BTreeMap<String, ()> +} + +impl<'a, C, A> CallBuilder for LiveBroadcastBindCall<'a, C, A> {} + +impl<'a, C, A> LiveBroadcastBindCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken { + + + /// Perform the operation you have build so far. + pub fn doit(mut self) -> Result<(hyper::client::Response, LiveBroadcast)> { + use std::io::{Read, Seek}; + use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location}; + let mut dd = DefaultDelegate; + let mut dlg: &mut Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(MethodInfo { id: "youtube.liveBroadcasts.bind", + http_method: hyper::method::Method::Post }); + let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len())); + params.push(("id", self._id.to_string())); + params.push(("part", self._part.to_string())); + if let Some(value) = self._stream_id { + params.push(("streamId", value.to_string())); + } + if let Some(value) = self._on_behalf_of_content_owner_channel { + params.push(("onBehalfOfContentOwnerChannel", value.to_string())); + } + if let Some(value) = self._on_behalf_of_content_owner { + params.push(("onBehalfOfContentOwner", value.to_string())); + } + for &field in ["alt", "id", "part", "streamId", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + params.push(("alt", "json".to_string())); + + let mut url = "https://www.googleapis.com/youtube/v3/liveBroadcasts/bind".to_string(); + if self._scopes.len() == 0 { + self._scopes.insert(Scope::Full.as_ref().to_string(), ()); + } + + + if params.len() > 0 { + url.push('?'); + url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref())))); + } + + + + loop { + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; + let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, + access_token: token.access_token }); + let mut req_result = { + let mut client = &mut *self.hub.client.borrow_mut(); + let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref()) + .header(UserAgent(self.hub._user_agent.clone())) + .header(auth_header.clone()); + + dlg.pre_request(); + req.send() + }; + + match req_result { + Err(err) => { + if let oauth2::Retry::After(d) = dlg.http_error(&err) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status.is_success() { + let mut json_err = String::new(); + res.read_to_string(&mut json_err).unwrap(); + if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) { + sleep_ms(d.num_milliseconds() as u32); + continue; + } + dlg.finished(false); + return Err(Error::Failure(res)) + } + let result_value = { + let mut json_response = String::new(); + res.read_to_string(&mut json_response).unwrap(); + match json::from_str(&json_response) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&json_response, &err); + return Err(Error::JsonDecodeError(err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id parameter specifies the unique ID of the broadcast that is being bound to a video stream. + /// + /// Sets the *id* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn id(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { + self._id = new_value.to_string(); + self + } + /// The part parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + /// + /// Sets the *part* query property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn part(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { + self._part = new_value.to_string(); + self + } + /// The streamId parameter specifies the unique ID of the video stream that is being bound to a broadcast. If this parameter is omitted, the API will remove any existing binding between the broadcast and a video stream. + /// + /// Sets the *stream id* query property to the given value. + pub fn stream_id(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { + self._stream_id = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. Note: This parameter is intended exclusively for YouTube content partners. + /// + /// The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. + /// + /// This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// Note: This parameter is intended exclusively for YouTube content partners. + /// + /// The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, C, A> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut Delegate) -> LiveBroadcastBindCall<'a, C, A> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known paramters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits. + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *alt* (query-string) - Data format for the response. + pub fn param<T>(mut self, name: T, value: T) -> LiveBroadcastBindCall<'a, C, A> + where T: AsRef<str> { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::Full`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope<T>(mut self, scope: T) -> LiveBroadcastBindCall<'a, C, A> + where T: AsRef<str> { + self._scopes.insert(scope.as_ref().to_string(), ()); + self + } +} + + /// Deletes a specified caption track. /// /// A builder for the *delete* method supported by a *caption* resource. @@ -18275,8 +22372,8 @@ impl<'a, C, A> LiveBroadcastTransitionCall<'a, C, A> where C: BorrowMut<hyper::C /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.captions().delete("id") -/// .on_behalf_of("dolores") -/// .debug_project_id_override("consetetur") +/// .on_behalf_of("dolore") +/// .debug_project_id_override("magna") /// .doit(); /// # } /// ``` @@ -18341,16 +22438,20 @@ impl<'a, C, A> CaptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -18495,15 +22596,15 @@ impl<'a, C, A> CaptionDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Caption = Default::default(); +/// let mut req = Caption::default(); /// /// // 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) /// .sync(false) -/// .on_behalf_of("aliquyam") -/// .debug_project_id_override("elitr") +/// .on_behalf_of("magna") +/// .debug_project_id_override("ipsum") /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -18592,16 +22693,20 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -18861,6 +22966,17 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// A builder for the *list* method supported by a *caption* resource. /// It is not used directly, but through a `CaptionMethods` instance. /// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.force-ssl* scope to make a valid call. +/// +/// The default scope will be `Scope::ForceSsl`. +/// /// # Example /// /// Instantiate a resource method builder @@ -18883,9 +22999,9 @@ impl<'a, C, A> CaptionInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.captions().list("part", "videoId") -/// .on_behalf_of("Stet") -/// .id("sed") -/// .debug_project_id_override("dolor") +/// .on_behalf_of("labore") +/// .id("diam") +/// .debug_project_id_override("nonumy") /// .doit(); /// # } /// ``` @@ -18957,16 +23073,20 @@ impl<'a, C, A> CaptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19017,12 +23137,17 @@ impl<'a, C, A> CaptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o } - /// The part parameter specifies the caption resource parts that the API response will include. + /// The part parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet. /// /// Sets the *part* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* pub fn part(mut self, new_value: &str) -> CaptionListCall<'a, C, A> { self._part = new_value.to_string(); self @@ -19140,10 +23265,10 @@ impl<'a, C, A> CaptionListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.captions().download("id") -/// .tlang("dolore") -/// .tfmt("Lorem") -/// .on_behalf_of("consetetur") -/// .debug_project_id_override("consetetur") +/// .tlang("diam") +/// .tfmt("magna") +/// .on_behalf_of("dolor") +/// .debug_project_id_override("Lorem") /// .doit(); /// # } /// ``` @@ -19240,16 +23365,20 @@ impl<'a, C, A> CaptionDownloadCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -19408,15 +23537,15 @@ impl<'a, C, A> CaptionDownloadCall<'a, C, A> where C: BorrowMut<hyper::Client>, /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Caption = Default::default(); +/// let mut req = Caption::default(); /// /// // 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) -/// .sync(false) -/// .on_behalf_of("labore") -/// .debug_project_id_override("gubergren") +/// .sync(true) +/// .on_behalf_of("vero") +/// .debug_project_id_override("nonumy") /// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()); /// # } /// ``` @@ -19505,16 +23634,20 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: let mut upload_url: Option<String> = None; loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { @@ -19812,9 +23945,9 @@ impl<'a, C, A> CaptionUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.video_categories().list("part") -/// .region_code("sadipscing") -/// .id("accusam") -/// .hl("magna") +/// .region_code("dolores") +/// .id("consetetur") +/// .hl("erat") /// .doit(); /// # } /// ``` @@ -19884,16 +24017,20 @@ impl<'a, C, A> VideoCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -20075,14 +24212,14 @@ impl<'a, C, A> VideoCategoryListCall<'a, C, A> where C: BorrowMut<hyper::Client> /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.activities().list("part") -/// .region_code("rebum.") -/// .published_before("et") -/// .published_after("clita") -/// .page_token("eos") +/// .region_code("dolores") +/// .published_before("dolores") +/// .published_after("et") +/// .page_token("sed") /// .mine(false) -/// .max_results(76) +/// .max_results(70) /// .home(false) -/// .channel_id("vero") +/// .channel_id("sit") /// .doit(); /// # } /// ``` @@ -20172,16 +24309,20 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -20401,7 +24542,7 @@ impl<'a, C, A> ActivityListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Activity = Default::default(); +/// let mut req = Activity::default(); /// req.snippet = Default::default(); // is ActivitySnippet /// req.content_details = Default::default(); // is ActivityContentDetails /// @@ -20474,16 +24615,20 @@ impl<'a, C, A> ActivityInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); diff --git a/gen/youtubeanalytics1-cli/Cargo.toml b/gen/youtubeanalytics1-cli/Cargo.toml index a055227e8d..c57e24dec3 100644 --- a/gen/youtubeanalytics1-cli/Cargo.toml +++ b/gen/youtubeanalytics1-cli/Cargo.toml @@ -5,7 +5,7 @@ name = "google-youtubeanalytics1-cli" version = "0.0.1+20150304" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/youtube/analytics/" @@ -23,6 +23,7 @@ yup-oauth2 = "*" docopt = "*" docopt_macros = "*" rustc-serialize = "*" +yup-hyper-mock = "*" serde = ">= 0.3.0" serde_macros = "*" diff --git a/gen/youtubeanalytics1-cli/src/cmn.rs b/gen/youtubeanalytics1-cli/src/cmn.rs index fd8d66fa4c..a8d3f46368 100644 --- a/gen/youtubeanalytics1-cli/src/cmn.rs +++ b/gen/youtubeanalytics1-cli/src/cmn.rs @@ -93,10 +93,10 @@ impl FieldCursor { } } -pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError) +pub fn parse_kv_arg<'a>(kv: &'a str, err: &mut InvalidOptionsError, for_hashmap: bool) -> (&'a str, Option<&'a str>) { - let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string())); - match kv.rfind('=') { + let mut add_err = || err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(),for_hashmap)); + match kv.find('=') { None => { add_err(); return (kv, None) @@ -171,25 +171,52 @@ impl JsonTokenStorage { } impl TokenStorage for JsonTokenStorage { - // NOTE: logging might be interesting, currently we swallow all errors - fn set(&mut self, scope_hash: u64, token: Option<Token>) { - let json_token = json::encode(&token).unwrap(); - let res = fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)); - if let Ok(mut f) = res { - f.write(json_token.as_bytes()).ok(); - } - } + type Error = io::Error; - fn get(&self, scope_hash: u64) -> Option<Token> { - if let Ok(mut f) = fs::File::open(&self.path(scope_hash)) { - let mut json_string = String::new(); - if let Ok(_) = f.read_to_string(&mut json_string) { - if let Ok(token) = json::decode::<Token>(&json_string) { - return Some(token) + // NOTE: logging might be interesting, currently we swallow all errors + fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<io::Error> { + match token { + None => { + match fs::remove_file(self.path(scope_hash)) { + Err(err) => + match err.kind() { + io::ErrorKind::NotFound => None, + _ => Some(err) + }, + Ok(_) => None + } + } + Some(token) => { + let json_token = json::encode(&token).unwrap(); + match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) { + Ok(mut f) => { + match f.write(json_token.as_bytes()) { + Ok(_) => None, + Err(io_err) => Some(io_err), + } + }, + Err(io_err) => Some(io_err) + } + } + } + } + + fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, io::Error> { + match fs::File::open(&self.path(scope_hash)) { + Ok(mut f) => { + let mut json_string = String::new(); + match f.read_to_string(&mut json_string) { + Ok(_) => Ok(Some(json::decode::<Token>(&json_string).unwrap())), + Err(io_err) => Err(io_err), + } + }, + Err(io_err) => { + match io_err.kind() { + io::ErrorKind::NotFound => Ok(None), + _ => Err(io_err) } } } - None } } @@ -286,7 +313,7 @@ pub enum CLIError { Configuration(ConfigurationError), ParseError((&'static str, &'static str, String, String)), UnknownParameter(String), - InvalidKeyValueSyntax(String), + InvalidKeyValueSyntax(String, bool), Input(InputError), Field(FieldError), } @@ -302,9 +329,10 @@ impl fmt::Display for CLIError { arg_name, value, type_name, err_desc), CLIError::UnknownParameter(ref param_name) => writeln!(f, "Parameter '{}' is unknown.", param_name), - CLIError::InvalidKeyValueSyntax(ref kv) - => writeln!(f, "'{}' does not match pattern <key>=<value>", kv), - + CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => { + let hashmap_info = if is_hashmap { "hashmap " } else { "" }; + writeln!(f, "'{}' does not match {}pattern <key>=<value>", kv, hashmap_info) + }, } } } @@ -369,7 +397,10 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> { Ok(expanded_config_dir) } -pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Result<ApplicationSecret, CLIError> { +pub fn application_secret_from_directory(dir: &str, + secret_basename: &str, + json_app_secret: &str) + -> Result<ApplicationSecret, CLIError> { let secret_path = Path::new(dir).join(secret_basename); let secret_str = || secret_path.as_path().to_str().unwrap().to_string(); let secret_io_error = |io_err: io::Error| { @@ -383,27 +414,11 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re Err(mut err) => { if err.kind() == io::ErrorKind::NotFound { // Write our built-in one - user may adjust the written file at will - let secret = ApplicationSecret { - client_id: "14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com".to_string(), - client_secret: "UqkDJd5RFwnHoiG5x5Rub8SI".to_string(), - token_uri: "https://accounts.google.com/o/oauth2/token".to_string(), - auth_uri: Default::default(), - redirect_uris: Default::default(), - client_email: None, - auth_provider_x509_cert_url: None, - client_x509_cert_url: Some("https://www.googleapis.com/oauth2/v1/certs".to_string()) - }; - let app_secret = ConsoleApplicationSecret { - installed: Some(secret), - web: None, - }; - - let json_enocded_secret = json::encode(&app_secret).unwrap(); err = match fs::OpenOptions::new().create(true).write(true).open(&secret_path) { Err(cfe) => cfe, Ok(mut f) => { - match f.write(json_enocded_secret.as_bytes()) { + match f.write(json_app_secret.as_bytes()) { Err(io_err) => io_err, Ok(_) => continue, } diff --git a/gen/youtubeanalytics1-cli/src/main.rs b/gen/youtubeanalytics1-cli/src/main.rs index e4ef6914df..6619dcaabc 100644 --- a/gen/youtubeanalytics1-cli/src/main.rs +++ b/gen/youtubeanalytics1-cli/src/main.rs @@ -7,6 +7,7 @@ extern crate docopt; extern crate yup_oauth2 as oauth2; +extern crate yup_hyper_mock as mock; extern crate rustc_serialize; extern crate serde; extern crate hyper; @@ -41,6 +42,12 @@ Configuration: 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. "); mod cmn; @@ -64,7 +71,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.batch_report_definitions().list(&self.opt.arg_on_behalf_of_content_owner); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -96,8 +103,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -108,7 +114,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.batch_reports().list(&self.opt.arg_batch_report_definition_id, &self.opt.arg_on_behalf_of_content_owner); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "alt" |"fields" @@ -140,8 +146,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -152,7 +157,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.group_items().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -186,7 +191,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -195,10 +199,10 @@ impl Engine { fn _group_items_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::GroupItem = Default::default(); + let mut request = api::GroupItem::default(); 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); + 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("")); @@ -221,9 +225,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -242,11 +247,11 @@ impl Engine { }, "resource.kind" => { request_resource_init(&mut request); - request.resource.as_mut().unwrap().kind = value.unwrap_or("").to_string(); + 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 = value.unwrap_or("").to_string(); + request.resource.as_mut().unwrap().id = Some(value.unwrap_or("").to_string()); }, "group-id" => { request_resource_init(&mut request); @@ -273,8 +278,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -285,7 +289,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.group_items().list(&self.opt.arg_group_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -320,8 +324,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -332,7 +335,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.groups().delete(&self.opt.arg_id); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -366,7 +369,6 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok(mut response) => { - println!("DEBUG: REMOVE ME {:?}", response); None } } @@ -375,10 +377,10 @@ impl Engine { fn _groups_insert(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Group = Default::default(); + 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); + 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("")); @@ -401,9 +403,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -422,19 +425,19 @@ impl Engine { match &field_name.to_string()[..] { "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "content-details.item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "int64"); + request.content_details.as_mut().unwrap().item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "int64")); }, "content-details.item-type" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_type = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().item_type = Some(value.unwrap_or("").to_string()); }, "kind" => { request_content_details_init(&mut request); @@ -465,8 +468,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -477,7 +479,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.groups().list(); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + 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("")); @@ -518,8 +520,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -528,10 +529,10 @@ impl Engine { fn _groups_update(&self, dry_run: bool, err: &mut InvalidOptionsError) -> Option<api::Error> { - let mut request: api::Group = Default::default(); + 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); + 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("")); @@ -554,9 +555,10 @@ impl Engine { _ => err.issues.push(CLIError::UnknownParameter(key.to_string())), } } - let mut field_name: FieldCursor = Default::default(); + + let mut field_name = FieldCursor::default(); for kvarg in self.opt.arg_kv.iter() { - let (key, value) = parse_kv_arg(&*kvarg, err); + let (key, value) = parse_kv_arg(&*kvarg, err, false); if let Err(field_err) = field_name.set(&*key) { err.issues.push(field_err); } @@ -575,19 +577,19 @@ impl Engine { match &field_name.to_string()[..] { "snippet.published-at" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().published_at = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().published_at = Some(value.unwrap_or("").to_string()); }, "snippet.title" => { request_snippet_init(&mut request); - request.snippet.as_mut().unwrap().title = value.unwrap_or("").to_string(); + request.snippet.as_mut().unwrap().title = Some(value.unwrap_or("").to_string()); }, "content-details.item-count" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_count = arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "int64"); + request.content_details.as_mut().unwrap().item_count = Some(arg_from_str(value.unwrap_or("-0"), err, "content-details.item-count", "int64")); }, "content-details.item-type" => { request_content_details_init(&mut request); - request.content_details.as_mut().unwrap().item_type = value.unwrap_or("").to_string(); + request.content_details.as_mut().unwrap().item_type = Some(value.unwrap_or("").to_string()); }, "kind" => { request_content_details_init(&mut request); @@ -618,8 +620,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -630,7 +631,7 @@ impl Engine { -> Option<api::Error> { let mut call = self.hub.reports().query(&self.opt.arg_ids, &self.opt.arg_start_date, &self.opt.arg_end_date, &self.opt.arg_metrics); for parg in self.opt.arg_v.iter() { - let (key, value) = parse_kv_arg(&*parg, err); + let (key, value) = parse_kv_arg(&*parg, err, false); match key { "start-index" => { call = call.start_index(arg_from_str(value.unwrap_or("-0"), err, "start-index", "integer")); @@ -680,8 +681,7 @@ impl Engine { } { Err(api_err) => Some(api_err), Ok((mut response, output_schema)) => { - println!("DEBUG: REMOVE ME {:?}", response); - serde::json::to_writer(&mut ostream, &output_schema).unwrap(); + serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap(); None } } @@ -699,13 +699,15 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_batch_reports { + } + else if self.opt.cmd_batch_reports { if self.opt.cmd_list { call_result = self._batch_reports_list(dry_run, &mut err); } else { unreachable!(); } - } else if self.opt.cmd_group_items { + } + else if self.opt.cmd_group_items { if self.opt.cmd_delete { call_result = self._group_items_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -715,7 +717,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_groups { + } + else if self.opt.cmd_groups { if self.opt.cmd_delete { call_result = self._groups_delete(dry_run, &mut err); } else if self.opt.cmd_insert { @@ -727,7 +730,8 @@ impl Engine { } else { unreachable!(); } - } else if self.opt.cmd_reports { + } + else if self.opt.cmd_reports { if self.opt.cmd_query { call_result = self._reports_query(dry_run, &mut err); } else { @@ -753,21 +757,37 @@ impl Engine { Ok(p) => p, }; - match cmn::application_secret_from_directory(&config_dir, "youtubeanalytics1-secret.json") { + match cmn::application_secret_from_directory(&config_dir, "youtubeanalytics1-secret.json", + "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") { Ok(secret) => (config_dir, secret), Err(e) => return Err(InvalidOptionsError::single(e, 4)) } }; - let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, - hyper::Client::new(), - JsonTokenStorage { - program_name: "youtubeanalytics1", - db_dir: config_dir.clone(), - }, None); + let auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, + if opt.flag_debug_auth { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }, + JsonTokenStorage { + program_name: "youtubeanalytics1", + db_dir: config_dir.clone(), + }, None); + + let client = + if opt.flag_debug { + hyper::Client::with_connector(mock::TeeConnector { + connector: hyper::net::HttpConnector(None) + }) + } else { + hyper::Client::new() + }; let engine = Engine { opt: opt, - hub: api::YouTubeAnalytics::new(hyper::Client::new(), auth), + hub: api::YouTubeAnalytics::new(client, auth), }; match engine._doit(true) { @@ -787,12 +807,13 @@ fn main() { let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit()); match Engine::new(opts) { Err(err) => { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(err.exit_code); }, Ok(engine) => { if let Some(err) = engine.doit() { - write!(io::stderr(), "{}", err).ok(); + writeln!(io::stderr(), "{:?}", err).ok(); + writeln!(io::stderr(), "{}", err).ok(); env::set_exit_status(1); } } diff --git a/gen/youtubeanalytics1/Cargo.toml b/gen/youtubeanalytics1/Cargo.toml index 599c24a160..aa39a3c660 100644 --- a/gen/youtubeanalytics1/Cargo.toml +++ b/gen/youtubeanalytics1/Cargo.toml @@ -5,7 +5,7 @@ name = "google-youtubeanalytics1" version = "0.1.5+20150304" -authors = ["Sebastian Thiel <byronimo@gmail>"] +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" homepage = "http://developers.google.com/youtube/analytics/" diff --git a/gen/youtubeanalytics1/src/cmn.rs b/gen/youtubeanalytics1/src/cmn.rs index 5d9b5ebbf8..aee3fb3f4b 100644 --- a/gen/youtubeanalytics1/src/cmn.rs +++ b/gen/youtubeanalytics1/src/cmn.rs @@ -127,9 +127,12 @@ pub trait Delegate { } /// Called whenever the Authenticator didn't yield a token. The delegate - /// may attempt to provide one, or just take is a general information about the - /// pending impending failure - fn token(&mut self) -> Option<oauth2::Token> { + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> { + let _ = err; None } @@ -232,7 +235,7 @@ pub enum Error { MissingAPIKey, /// We required a Token, but didn't get one from the Authenticator - MissingToken, + MissingToken(Box<error::Error>), /// The delgate instructed to cancel the operation Cancelled, @@ -260,8 +263,8 @@ 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::MissingToken => - writeln!(f, "Didn't obtain authentication token from authenticator"), + Error::MissingToken(ref err) => + writeln!(f, "Token retrieval failed with error: {}", err), Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), Error::FieldClash(field) => diff --git a/gen/youtubeanalytics1/src/lib.rs b/gen/youtubeanalytics1/src/lib.rs index b68d6feb56..32610dd308 100644 --- a/gen/youtubeanalytics1/src/lib.rs +++ b/gen/youtubeanalytics1/src/lib.rs @@ -377,9 +377,9 @@ impl<'a, C, A> YouTubeAnalytics<C, A> #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BatchReportDefinitionList { /// A list of batchReportDefinition resources that match the request criteria. - pub items: Vec<BatchReportDefinition>, + pub items: Option<Vec<BatchReportDefinition>>, /// This value specifies the type of data included in the API response. For the list method, the kind property value is youtubeAnalytics#batchReportDefinitionList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for BatchReportDefinitionList {} @@ -425,10 +425,10 @@ impl ResponseResult for Group {} pub struct GroupContentDetails { /// no description provided #[serde(rename="itemCount")] - pub item_count: i64, + pub item_count: Option<i64>, /// no description provided #[serde(rename="itemType")] - pub item_type: String, + pub item_type: Option<String>, } impl NestedType for GroupContentDetails {} @@ -447,11 +447,11 @@ impl Part for GroupContentDetails {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GroupListResponse { /// no description provided - pub items: Vec<Group>, + pub items: Option<Vec<Group>>, /// no description provided - pub kind: String, + pub kind: Option<String>, /// no description provided - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for GroupListResponse {} @@ -465,12 +465,12 @@ impl ResponseResult for GroupListResponse {} pub struct ResultTableColumnHeaders { /// The type of the data in the column (STRING, INTEGER, FLOAT, etc.). #[serde(rename="dataType")] - pub data_type: String, + pub data_type: Option<String>, /// The type of the column (DIMENSION or METRIC). #[serde(rename="columnType")] - pub column_type: String, + pub column_type: Option<String>, /// The name of the dimension or metric. - pub name: String, + pub name: Option<String>, } impl NestedType for ResultTableColumnHeaders {} @@ -489,11 +489,11 @@ impl Part for ResultTableColumnHeaders {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GroupItemListResponse { /// no description provided - pub items: Vec<GroupItem>, + pub items: Option<Vec<GroupItem>>, /// no description provided - pub kind: String, + pub kind: Option<String>, /// no description provided - pub etag: String, + pub etag: Option<String>, } impl ResponseResult for GroupItemListResponse {} @@ -507,12 +507,12 @@ impl ResponseResult for GroupItemListResponse {} pub struct BatchReportOutputs { /// Cloud storage URL to download this report. This URL is valid for 30 minutes. #[serde(rename="downloadUrl")] - pub download_url: String, + pub download_url: Option<String>, /// Type of the output. #[serde(rename="type")] - pub type_: String, + pub type_: Option<String>, /// Format of the output. - pub format: String, + pub format: Option<String>, } impl NestedType for BatchReportOutputs {} @@ -527,9 +527,9 @@ impl Part for BatchReportOutputs {} pub struct GroupSnippet { /// no description provided #[serde(rename="publishedAt")] - pub published_at: String, + pub published_at: Option<String>, /// no description provided - pub title: String, + pub title: Option<String>, } impl NestedType for GroupSnippet {} @@ -574,9 +574,9 @@ impl ResponseResult for GroupItem {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GroupItemResource { /// no description provided - pub kind: String, + pub kind: Option<String>, /// no description provided - pub id: String, + pub id: Option<String>, } impl NestedType for GroupItemResource {} @@ -622,12 +622,12 @@ impl Resource for BatchReportDefinition {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ResultTable { /// This value specifies the type of data included in the API response. For the query method, the kind property value will be youtubeAnalytics#resultTable. - pub kind: String, + pub kind: Option<String>, /// The list contains all rows of the result table. Each item in the list is an array that contains comma-delimited data corresponding to a single row of data. The order of the comma-delimited data fields will match the order of the columns listed in the columnHeaders field. If no data is available for the given query, the rows element will be omitted from the response. The response for a query with the day dimension will not contain rows for the most recent days. - pub rows: Vec<Vec<String>>, + pub rows: Option<Vec<Vec<String>>>, /// This value specifies information about the data returned in the rows fields. Each item in the columnHeaders list identifies a field returned in the rows value, which contains a list of comma-delimited data. The columnHeaders list will begin with the dimensions specified in the API request, which will be followed by the metrics specified in the API request. The order of both dimensions and metrics will match the ordering in the API request. For example, if the API request contains the parameters dimensions=ageGroup,gender&metrics=viewerPercentage, the API response will return columns in this order: ageGroup,gender,viewerPercentage. #[serde(rename="columnHeaders")] - pub column_headers: Vec<ResultTableColumnHeaders>, + pub column_headers: Option<Vec<ResultTableColumnHeaders>>, } impl ResponseResult for ResultTable {} @@ -672,10 +672,10 @@ impl Resource for BatchReport {} pub struct BatchReportTimeSpan { /// End of the period included in the report. Inclusive. For reports containing all entities endTime is not set. #[serde(rename="endTime")] - pub end_time: String, + pub end_time: Option<String>, /// Start of the period included in the report. Inclusive. #[serde(rename="startTime")] - pub start_time: String, + pub start_time: Option<String>, } impl NestedType for BatchReportTimeSpan {} @@ -694,9 +694,9 @@ impl Part for BatchReportTimeSpan {} #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BatchReportList { /// A list of batchReport resources that match the request criteria. - pub items: Vec<BatchReport>, + pub items: Option<Vec<BatchReport>>, /// This value specifies the type of data included in the API response. For the list method, the kind property value is youtubeAnalytics#batchReportList. - pub kind: String, + pub kind: Option<String>, } impl ResponseResult for BatchReportList {} @@ -1228,16 +1228,20 @@ impl<'a, C, A> ReportQueryCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1508,16 +1512,20 @@ impl<'a, C, A> BatchReportDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -1657,7 +1665,7 @@ impl<'a, C, A> BatchReportDefinitionListCall<'a, C, A> where C: BorrowMut<hyper: /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: GroupItem = Default::default(); +/// let mut req = GroupItem::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -1728,16 +1736,20 @@ impl<'a, C, A> GroupItemInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -1951,16 +1963,20 @@ impl<'a, C, A> GroupItemListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2170,16 +2186,20 @@ impl<'a, C, A> GroupItemDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2379,16 +2399,20 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref()) @@ -2527,7 +2551,7 @@ impl<'a, C, A> GroupDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Group = Default::default(); +/// let mut req = Group::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -2598,16 +2622,20 @@ impl<'a, C, A> GroupInsertCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -2829,16 +2857,20 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) @@ -2991,7 +3023,7 @@ impl<'a, C, A> GroupListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oau /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! -/// let mut req: Group = Default::default(); +/// let mut req = Group::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. @@ -3062,16 +3094,20 @@ impl<'a, C, A> GroupUpdateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: o loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); @@ -3282,16 +3318,20 @@ impl<'a, C, A> BatchReportListCall<'a, C, A> where C: BorrowMut<hyper::Client>, loop { - let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys()); - if token.is_none() { - token = dlg.token(); - } - if token.is_none() { - dlg.finished(false); - return Err(Error::MissingToken) - } + let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) { + Ok(token) => token, + Err(err) => { + match dlg.token(&*err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(Error::MissingToken(err)) + } + } + } + }; let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer, - access_token: token.unwrap().access_token }); + access_token: token.access_token }); let mut req_result = { let mut client = &mut *self.hub.client.borrow_mut(); let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref()) diff --git a/src/mako/cli/docs/commands.md.mako b/src/mako/cli/docs/commands.md.mako index 225694dc97..491f9c0006 100644 --- a/src/mako/cli/docs/commands.md.mako +++ b/src/mako/cli/docs/commands.md.mako @@ -104,6 +104,7 @@ This method supports the upload of data, using the following protocol${len(mc.me + the mime type, like 'application/octet-stream', which is the default % endif # have upload capabilities % if mc.response_schema or smd: + # Optional Output Flags % if mc.response_schema: